From 5a979ce68711aedc3b93fd674e39f084e6f6fc2d Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 21 Mar 2016 21:39:26 -0400 Subject: [PATCH] proot: Add termux-chroot utility script --- disabled-packages/proot/build.sh | 2 ++ disabled-packages/proot/termux-chroot | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 disabled-packages/proot/termux-chroot diff --git a/disabled-packages/proot/build.sh b/disabled-packages/proot/build.sh index f2f05873..5004d729 100644 --- a/disabled-packages/proot/build.sh +++ b/disabled-packages/proot/build.sh @@ -16,4 +16,6 @@ termux_step_make_install () { mkdir -p $TERMUX_PREFIX/share/man/man1 cp $TERMUX_PKG_SRCDIR/doc/proot/man.1 $TERMUX_PREFIX/share/man/man1/proot.1 + + cp $TERMUX_PKG_BUILDER_DIR/termux-chroot $TERMUX_PREFIX/bin/ } diff --git a/disabled-packages/proot/termux-chroot b/disabled-packages/proot/termux-chroot new file mode 100755 index 00000000..5dde068e --- /dev/null +++ b/disabled-packages/proot/termux-chroot @@ -0,0 +1,45 @@ +#!/bin/sh + +if [ $# != 0 ]; then + echo "termux-chroot: Setup a chroot to mimic a normal Linux file system" + echo "" + echo "Execute without arguments to run a chroot with traditional file system" + echo "hierarchy (having e.g. the folders /bin, /etc and /usr) within Termux." + exit +fi + +# For the /system/bin/linker(64) to be found: +ARGS="-b /system:/system" + +# Bind $PREFIX so Termux programs expecting +# to find e.g. configurations files there work. +ARGS="$ARGS -b $PREFIX/..:$PREFIX/.." + +# Mimic traditional Linux file system hierarchy - /usr: +ARGS="$ARGS -b $PREFIX:/usr" + +# Mimic traditional Linux file system hierarchy - other Termux dirs: +for f in bin etc lib share tmp var; do + ARGS="$ARGS -b $PREFIX/$f:/$f" +done + +# Mimic traditional Linux file system hierarchy- system dirs: +for f in dev proc; do + ARGS="$ARGS -b /$f:/$f" +done + +# Set /home as current directory: +ARGS="$ARGS --cwd=/home" + +# Root of the file system: +ARGS="$ARGS -r $PREFIX/.." + +# Program to execute: +PROGRAM=/bin/bash +if [ -x $HOME/.termux/shell ]; then + PROGRAM=`readlink -f $HOME/.termux/shell` +fi +ARGS="$ARGS $PROGRAM -l" + +export HOME=/home +$PREFIX/bin/proot $ARGS -- 2.11.0