Skip to content

Commit

Permalink
proot: add -g GNU libc and -u GNU Ubuntu roots
Browse files Browse the repository at this point in the history
it assumes the roots are installed and has a runnable bash

the Ubuntu root is installed with this dpkg wrapper that ignore all
script errors

https://github.com/john-peterson/glibc-packages/commits/ubuntu

i only did this to convince myself that roots are pointless without
installing ten gig useless filesfrom proot distro
  • Loading branch information
john-peterson committed Feb 11, 2025
1 parent 1561c12 commit 2d877c4
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions packages/proot/termux-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,38 @@ show_usage () {
echo "Execute a command in a chroot with traditional file system hierarchy"
echo "(having e.g. the folders /bin, /etc and /usr) within Termux."
echo "If run without argument, the default shell will be executed"
echo '-g GNU root $PREFIX/glibc '
echo '-u Ubuntu root $PREFIX/../ubuntu bash has to be installed and runnable'
exit 0
}

while getopts :h option
gnu=false
ubuntu=false
while getopts hgu option
do
case "$option" in
h) show_usage;;
g) gnu=true;;
u) ubuntu=true;;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
esac
done
shift $(($OPTIND-1))

if $gnu; then
ROOT=$PREFIX/glibc
ROOT0=
name=GNU
elif $ubuntu; then
ROOT=$PREFIX/../ubuntu
ROOT0=
name=ubuntu
else
ROOT=$PREFIX
ROOT0=/..
name=bionic
fi

# Kill processes on exit to avoid hanging on exit
ARGS="--kill-on-exit"

Expand Down Expand Up @@ -66,11 +86,11 @@ if [ -d /storage ]; then
fi

# Mimic traditional Linux file system hierarchy - /usr:
ARGS="$ARGS -b $PREFIX:/usr"
ARGS="$ARGS -b $ROOT:/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"
ARGS="$ARGS -b $ROOT/$f:/$f"
done

# Mimic traditional Linux file system hierarchy- system dirs:
Expand All @@ -80,17 +100,22 @@ done

# Set /home as current directory:
ARGS="$ARGS --cwd=/home"
ARGS+=" -b $HOME:/home"

# Root of the file system:
ARGS="$ARGS -r $PREFIX/.."
ARGS="$ARGS -r $ROOT$ROOT0"

# Shell to execute:
PROGRAM=/bin/bash
if [ -x $HOME/.termux/shell ]; then
PROGRAM=`readlink -f $HOME/.termux/shell`
fi

# export to the new shell
export HOME=/home
export PATH=/bin:$PATH
export PROOT=$ROOT PROOT_NAME=$name
export PS1="$name \w "

# Execute shell if no command has been supplied
if [ -z "$1" ];then
Expand Down

0 comments on commit 2d877c4

Please sign in to comment.