qubes-builder-alpine/prepare-chroot-base
2022-03-04 14:33:13 -05:00

36 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# vim: set ts=4 sw=4 sts=4 et :
### prepare-chroot-base : Create a (any) chroot instance of Archlinux
### May be called from ./scripts/01_install_core.sh or ./prepare-chroot-archlinux
echo "--> Alpine linux prepare-chroot-base"
INSTALLDIR="$1"
DISTRO="$2" # aka elsewhere as $DIST
BOOTSTRAP_DIR="${CACHEDIR}/bootstrap"
ALPINELINUX_PLUGIN_DIR="${ALPINELINUX_PLUGIN_DIR:-"${SCRIPTSDIR}/.."}"
ALPINELINUX_VERSION=${ALPINELINUX_VERSION:-latest-stable}
ALPINELINUX_MIRROR=${ALPINELINUX_MIRROR:-http://dl-cdn.alpinelinux.org/alpine}
set -e
if [ "$VERBOSE" -ge 2 ] || [ "$DEBUG" -gt 0 ]; then
set -x
fi
exit_prepare() {
local exit_code=$?
echo " --> Unbinding INSTALLDIR..."
umount ${BOOTSTRAP_DIR}/mnt || true
exit $exit_code
}
trap 'exit_prepare' 0 1 2 3 6 15
echo " --> Binding INSTALLDIR '${INSTALLDIR}' to bootstrap environment..."
mkdir -p "${BOOTSTRAP_DIR}/mnt"
mount --bind "$INSTALLDIR" "${BOOTSTRAP_DIR}/mnt"
echo " --> Installing core apk packages..."
"$BOOTSTRAP_DIR"/sbin/apk.static -X $ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/main -U --allow-untrusted -p "$INSTALLDIR" --initdb add alpine-base
touch "${INSTALLDIR}/.prepared_base"