2022-03-04 19:33:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|
2023-08-25 21:44:09 +00:00
|
|
|
### prepare-chroot-base : Create a (any) chroot instance of Alpine Linux
|
|
|
|
### May be called from ./scripts/01_install_core.sh or ./prepare-chroot-base
|
2022-03-04 19:33:13 +00:00
|
|
|
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"
|