proot: Add termux-chroot utility script
[termux-packages] / disabled-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
14# Bind $PREFIX so Termux programs expecting
15# to find e.g. configurations files there work.
16ARGS="$ARGS -b $PREFIX/..:$PREFIX/.."
17
18# Mimic traditional Linux file system hierarchy - /usr:
19ARGS="$ARGS -b $PREFIX:/usr"
20
21# Mimic traditional Linux file system hierarchy - other Termux dirs:
22for f in bin etc lib share tmp var; do
23 ARGS="$ARGS -b $PREFIX/$f:/$f"
24done
25
26# Mimic traditional Linux file system hierarchy- system dirs:
27for f in dev proc; do
28 ARGS="$ARGS -b /$f:/$f"
29done
30
31# Set /home as current directory:
32ARGS="$ARGS --cwd=/home"
33
34# Root of the file system:
35ARGS="$ARGS -r $PREFIX/.."
36
37# Program to execute:
38PROGRAM=/bin/bash
39if [ -x $HOME/.termux/shell ]; then
40 PROGRAM=`readlink -f $HOME/.termux/shell`
41fi
42ARGS="$ARGS $PROGRAM -l"
43
44export HOME=/home
45$PREFIX/bin/proot $ARGS