qubes-builder-alpine/scripts/00_prepare.sh

42 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2022-03-04 19:33:13 +00:00
#! /bin/bash --
set -euo pipefail
echo "--> Alpine Linux 00_prepare.sh"
2023-08-26 21:14:13 +00:00
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."
2022-03-04 19:33:13 +00:00
fi
2023-08-26 21:14:13 +00:00
if [ -z "${DIST_VER}" ]; then
error "Please provide DIST_VER in environment."
fi
2022-03-04 19:33:13 +00:00
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:-https://dl-cdn.alpinelinux.org/alpine}
ALPINELINUX_ARCH=${ALPINELINUX_ARCH:-x86_64}
[ "$VERBOSE" -ge 2 -o "$DEBUG" -gt 0 ] && set -x
mkdir -p "${CACHEDIR}/apk_cache"
2022-03-04 19:33:13 +00:00
2023-08-26 21:14:13 +00:00
echo " --> Downloading Alpine Linux bootstrap..."
2022-03-04 19:33:13 +00:00
2023-08-26 21:14:13 +00:00
wget -nd -N -P "$CACHEDIR" -r -l1 -np "$ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/main/$ALPINELINUX_ARCH/" -A "apk-tools-static-*apk"
2022-03-04 19:33:13 +00:00
2023-08-26 21:14:13 +00:00
if [ "${CACHEDIR}/apk-tools-static"* -nt "${CACHEDIR}/bootstrap/.extracted" ]; then
2022-03-04 19:33:13 +00:00
echo " --> Extracting bootstrap tarball (nuking previous directory)..."
rm -rf "${CACHEDIR}/bootstrap/"
mkdir -p "${CACHEDIR}/bootstrap"
# By default will extract to a "root.x86_64" directory; strip that off
2023-08-26 21:14:13 +00:00
tar -xzC "${CACHEDIR}/bootstrap" -f "${CACHEDIR}/apk-tools-static"*.apk
2022-03-04 19:33:13 +00:00
touch "${CACHEDIR}/bootstrap/.extracted"
else
echo " --> NB: Bootstrap tarball not newer than bootstrap directory, will use existing!"
fi