alpine-chroot-install(8)

πŸ’– alpine-chroot-install β€” like, the NAME section but make it cute πŸ’–

okay bestie, gather round 🫢 this is alpine-chroot-install, a lil script from the System Manager's Manual (section 8, system admin tools, very demure, very mindful) and what it does is bootstrap an Alpine Linux chroot. that's it, that's the whole vibe. ✨


🌸 SYNOPSIS 🌸

alpine-chroot-install -d /directory [options]

like yes, you gotta give it a directory, and then optionally a whole lil bouquet of options. πŸ’


πŸ¦‹ DESCRIPTION πŸ¦‹

So this script installs Alpine Linux into a chroot, and then β€” if you want β€” it sets up qemu-user and binfmt so you can emulate a different architecture (think armhf, the little ARM girlies 🧚). no cap, it really does that.


✨ OPTIONS AND ENVIRONMENT VARIABLES ✨

every single one, we're not skipping a single one, periodt:

  • -a ARCH β€” the CPU architecture for the chroot. don't set it? then it just matches your host's architecture, easy. but if it's different from the host's, bestie it gets emulated with qemu-user. the options are: x86_64, x86, aarch64, armhf, armv7, ppc64le, riscv64, s390x. πŸ’…
  • -b ALPINE_BRANCH β€” which Alpine branch to install. default is latest-stable. πŸ“
  • -d CHROOT_DIR β€” absolute path to the directory where the Alpine chroot should be installed. ngl, Debian's version of this script requires you to give this explicitly β€” like -d /alpine. no skipping it there. πŸ™ˆ
  • -i BIND_DIR β€” absolute path to the directory on the host system that should be mounted on the same path inside the chroot. default is PWD, but only if it's under /home β€” otherwise, none. πŸŽ€
  • -k CHROOT_KEEP_VARS β€” the names of the environment variables to pass from the host environment into the chroot, courtesy of the enter-chroot script. a name can be an extended regular expression, fancy! default: ARCH CI QEMU_EMULATOR TRAVIS_.*. πŸ‘‘
  • -m ALPINE_MIRROR β€” URI of the Aports mirror to fetch packages from. default is http://dl-cdn.alpinelinux.org/alpine. 🌈
  • -p ALPINE_PACKAGES β€” Alpine packages to install into the chroot. default is build-base ca-certificates ssl_client. ⭐
  • -r EXTRA_REPOS β€” Alpine repositories to be added to /etc/apk/repositories (main and community from $ALPINE_MIRROR are always added, no exceptions). πŸ”₯
  • -t TEMP_DIR β€” absolute path to the directory where temporary files get stored. defaults to mktemp -d. πŸ’œ
  • -h β€” show this help message and exit. the classic. 😌
  • -v β€” print version and exit. πŸ’€
  • APK_TOOLS_URI β€” URL of apk.static to download. default is the x86_64 binary from https://gitlab.alpinelinux.org/alpine/apk-tools/-/packages. πŸ¦‹
  • APK_TOOLS_SHA256 β€” the SHA-256 checksum of $APK_TOOLS_URI. for the safety girlies. πŸ”’

and here's the tea, bestie: each option can also be provided by an environment variable. but if both the option and the variable are specified, and the option only accepts one argument, then the option takes precedence. iykyk. πŸ’…


🌟 AFTER INSTALL 🌟

this tool is generous, it also creates a script called enter-chroot inside the chroot directory, so you can actually enter the chroot environment. that script does the following, in order:

  1. saves environment variables specified by $CHROOT_KEEP_VARS and PWD,
  2. chroots into $CHROOT_DIR,
  3. starts clean environment using env -i,
  4. switches user and simulates full login using su -l,
  5. loads saved environment variables and changes directory to saved PWD,
  6. executes specified command or sh if not provided.

main character energy, honestly. πŸ‘‘

Example, because examples ate:

sudo alpine-chroot-install -d /alpine -p build-base -p cmake
/alpine/enter-chroot -u $USER ./build

⚠️ heads up bestie: -d CHROOT_DIR is the one thing you really can't fumble β€” it's an absolute path, and on Debian's version of this script it is required. don't come crying to me. 😭

and that's the whole page, fr fr πŸŽ€ this was alpine-chroot-install(8), straight from the Alpine Linux girlies, dated 2022-07-22 β€” that's the source and the date and the version all wrapped up in one cute lil sign-off. slay, bye!! πŸ’–βœ¨

πŸ“¦ where this page comes from