qubes-builder-alpine/scripts/00_prepare.sh
2022-03-04 14:33:13 -05:00

34 lines
1.3 KiB
Bash
Executable file

#! /bin/bash --
set -euo pipefail
echo "--> Alpine Linux 00_prepare.sh"
if [[ -n "${REPO_PROXY+x}" ]]; then
export "https_proxy=$REPO_PROXY" "http_proxy=$REPO_PROXY"
fi
ALPINELINUX_PLUGIN_DIR="${ALPINELINUX_PLUGIN_DIR:-"${SCRIPTSDIR}/.."}"
ALPINELINUX_VERSION=${ALPINELINUX_VERSION:-latest-stable}
ALPINELINUX_MIRROR=${ALPINELINUX_MIRROR:-https://dl-cdn.alpinelinux.org/alpine}
ALPINELINUX_ARCH=${ALPINELINUX_ARCH:-x86_64}
APKTOOLS_VERSION=${APKTOOLS_VERSION:-2.12.7-r3}
APKTOOLS_FILE="${APKTOOLS_FILE:-apk-tools-static-"$APKTOOLS_VERSION".apk}"
APKTOOLS_URL="$ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/main/$ALPINELINUX_ARCH/$APKTOOLS_FILE"
[ "$VERBOSE" -ge 2 -o "$DEBUG" -gt 0 ] && set -x
mkdir -p "${CACHEDIR}/pacman_cache"
echo " --> Downloading Alpine Linux bootstrap (v${APKTOOLS_VERSION-})..."
wget -N -P "$CACHEDIR" "$APKTOOLS_URL"
if [ "${CACHEDIR}/${APKTOOLS_FILE}" -nt "${CACHEDIR}/bootstrap/.extracted" ]; then
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
tar -xzC "${CACHEDIR}/bootstrap" -f "${CACHEDIR}/${APKTOOLS_FILE}"
touch "${CACHEDIR}/bootstrap/.extracted"
else
echo " --> NB: Bootstrap tarball not newer than bootstrap directory, will use existing!"
fi