php-apache: add package (#1075)
[termux-packages] / packages / proot / termux-chroot
CommitLineData
5a979ce6
FF
1#!/bin/sh
2
3if [ $# != 0 ]; then
4 echo "termux-chroot: Setup a chroot to mimic a normal Linux file system"
5 echo ""
6 echo "Execute without arguments to run a chroot with traditional file system"
7 echo "hierarchy (having e.g. the folders /bin, /etc and /usr) within Termux."
8 exit
9fi
10
11# For the /system/bin/linker(64) to be found:
12ARGS="-b /system:/system"
13
4480f511 14# On some devices /vendor is required for termux packages to work correctly
15# See https://github.com/termux/proot/issues/2#issuecomment-303995382
16ARGS="$ARGS -b /vendor:/vendor"
17
5a979ce6
FF
18# Bind $PREFIX so Termux programs expecting
19# to find e.g. configurations files there work.
20ARGS="$ARGS -b $PREFIX/..:$PREFIX/.."
21
c491cc49
FF
22# Expose external and internal storage:
23if [ -d /storage ]; then
24 ARGS="$ARGS -b /storage:/storage"
25fi
26
5a979ce6
FF
27# Mimic traditional Linux file system hierarchy - /usr:
28ARGS="$ARGS -b $PREFIX:/usr"
29
30# Mimic traditional Linux file system hierarchy - other Termux dirs:
31for f in bin etc lib share tmp var; do
32 ARGS="$ARGS -b $PREFIX/$f:/$f"
33done
34
35# Mimic traditional Linux file system hierarchy- system dirs:
36for f in dev proc; do
37 ARGS="$ARGS -b /$f:/$f"
38done
39
40# Set /home as current directory:
41ARGS="$ARGS --cwd=/home"
42
43# Root of the file system:
44ARGS="$ARGS -r $PREFIX/.."
45
46# Program to execute:
47PROGRAM=/bin/bash
48if [ -x $HOME/.termux/shell ]; then
49 PROGRAM=`readlink -f $HOME/.termux/shell`
50fi
51ARGS="$ARGS $PROGRAM -l"
52
53export HOME=/home
54$PREFIX/bin/proot $ARGS