Commit | Line | Data |
---|---|---|
5a979ce6 FF |
1 | #!/bin/sh |
2 | ||
3 | if [ $# != 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 | |
9 | fi | |
10 | ||
11 | # For the /system/bin/linker(64) to be found: | |
12 | ARGS="-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 | |
16 | ARGS="$ARGS -b /vendor:/vendor" | |
17 | ||
293296c4 FF |
18 | # Bind /data to include system folders such as /data/misc. Also $PREFIX |
19 | # and $HOME so that Termux programs with hard-coded paths continue to work: | |
20 | ARGS="$ARGS -b /data:/data" | |
21 | ||
22 | # Used by getprop (see https://github.com/termux/termux-packages/issues/1076): | |
23 | ARGS="$ARGS -b /property_contexts:/property_contexts" | |
5a979ce6 | 24 | |
c491cc49 FF |
25 | # Expose external and internal storage: |
26 | if [ -d /storage ]; then | |
27 | ARGS="$ARGS -b /storage:/storage" | |
28 | fi | |
29 | ||
5a979ce6 FF |
30 | # Mimic traditional Linux file system hierarchy - /usr: |
31 | ARGS="$ARGS -b $PREFIX:/usr" | |
32 | ||
33 | # Mimic traditional Linux file system hierarchy - other Termux dirs: | |
34 | for f in bin etc lib share tmp var; do | |
35 | ARGS="$ARGS -b $PREFIX/$f:/$f" | |
36 | done | |
37 | ||
38 | # Mimic traditional Linux file system hierarchy- system dirs: | |
39 | for f in dev proc; do | |
40 | ARGS="$ARGS -b /$f:/$f" | |
41 | done | |
42 | ||
43 | # Set /home as current directory: | |
44 | ARGS="$ARGS --cwd=/home" | |
45 | ||
46 | # Root of the file system: | |
47 | ARGS="$ARGS -r $PREFIX/.." | |
48 | ||
49 | # Program to execute: | |
50 | PROGRAM=/bin/bash | |
51 | if [ -x $HOME/.termux/shell ]; then | |
52 | PROGRAM=`readlink -f $HOME/.termux/shell` | |
53 | fi | |
54 | ARGS="$ARGS $PROGRAM -l" | |
55 | ||
56 | export HOME=/home | |
57 | $PREFIX/bin/proot $ARGS |