qubes-builder-alpine/prepare-chroot-base

49 lines
1.4 KiB
Text
Raw Permalink Normal View History

2022-03-04 19:33:13 +00:00
#!/bin/sh
# vim: set ts=4 sw=4 sts=4 et :
### prepare-chroot-base : Create a (any) chroot instance of Alpine Linux
### May be called from ./scripts/01_install_core.sh or ./prepare-chroot-base
2023-08-26 21:14:13 +00:00
echo "--> Alpine Linux prepare-chroot-base"
2022-03-04 19:33:13 +00:00
INSTALLDIR="$1"
2023-08-26 21:14:13 +00:00
DIST="$2"
DIST_NAME="alpinelinux"
DIST_VER="v${DIST#alpine}"
DIST_VER="${DIST_VER/3/3.}"
if [ -z "${DIST_NAME}" ]; then
error "Please provide DIST_NAME in environment."
fi
if [ -z "${DIST_VER}" ]; then
error "Please provide DIST_VER in environment."
fi
2022-03-04 19:33:13 +00:00
BOOTSTRAP_DIR="${CACHEDIR}/bootstrap"
ALPINELINUX_PLUGIN_DIR="${ALPINELINUX_PLUGIN_DIR:-"${SCRIPTSDIR}/.."}"
2023-08-26 21:14:13 +00:00
ALPINELINUX_VERSION=${DIST_VER:-latest-stable}
2022-03-04 19:33:13 +00:00
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"