/easychroot

easy, hackable, understandable chroot manager in pure Python

Primary LanguagePython

Usage

mount_with_home.py:

Usage:
  mount_with_home.py CHROOT_PATH [options] [ADDITIONAL_VOLUMES...]
  mount_with_home.py --help
  mount_with_home.py --version

Options:
  --help        Show this screen.
  --version     Show version.
  --root        Don't drop privs to executing user, maintain root permissions in chroot.
  --no_ro       Don't bind-mount readonly files necessary for consistent environment usage, like /etc/password or /etc/hosts. (implies --root)
  --use_home=x  Use the specified directory as the chroot user's home directory.
  --share_home  Use the executing user's home directory as the chroot user's home directory.

Build Alpine chroot

wget http://dl-5.alpinelinux.org/alpine/v3.9/main/aarch64/apk-tools-static-2.10.3-r1.apk
mkdir alpine && cd alpine
sudo tar -xzf ../apk-tools-static-2.10.3-r1.apk
sudo ./sbin/apk.static -X http://dl-5.alpinelinux.org/alpine/v3.9/main -U --allow-untrusted --root . --initdb add alpine-base alpine-sdk

Build Ubuntu chroot (32b or 64b)

wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.1-base-arm64.tar.gz http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.1-base-armhf.tar.gz
mkdir ubuntu-1804-arm64 && cd ubuntu-1804-arm64
sudo tar -xvf ../../ubuntu-base-18.04.1-base-arm64.tar.gz

NB: Corrected -h to --help via abbreviation (case change: None)

Example invocation

With pulse configured for audio in chroot.

wget http://mirror.siena.edu/fedora/linux/releases/30/Container/aarch64/images/Fedora-Container-Base-30-1.2.aarch64.tar.xz
mkdir f30 && cd f30 && sudo tar -xvf Fedora-Container-Base-30-1.2.aarch64.tar.xz
sudo ~/projects/easychroot/mount_with_home.py f30 /run/user/1000/wayland-0 \
   /var/run/user/1000/pulse:/run/user/1000/pulse pulse-client.conf:/etc/pulse/client.conf \
   --share_home```