Support different alpine versions

This commit is contained in:
Antoine Martin 2023-08-26 17:14:13 -04:00
parent 026f49b6d8
commit 249bafed35
Signed by: forge
GPG key ID: D62A472A4AA7D541
5 changed files with 67 additions and 18 deletions

View file

@ -1,4 +1,4 @@
ifeq ($(DIST),alpinelinux)
ifneq (,$(findstring alpine,$(DIST)))
ALPINELINUX_PLUGIN_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
DISTRIBUTION := alpinelinux
BUILDER_MAKEFILE = $(ALPINELINUX_PLUGIN_DIR)Makefile.alpinelinux

View file

@ -2,14 +2,26 @@
# 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
echo "--> Alpine linux prepare-chroot-base"
echo "--> Alpine Linux prepare-chroot-base"
INSTALLDIR="$1"
DISTRO="$2" # aka elsewhere as $DIST
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
BOOTSTRAP_DIR="${CACHEDIR}/bootstrap"
ALPINELINUX_PLUGIN_DIR="${ALPINELINUX_PLUGIN_DIR:-"${SCRIPTSDIR}/.."}"
ALPINELINUX_VERSION=${ALPINELINUX_VERSION:-latest-stable}
ALPINELINUX_VERSION=${DIST_VER:-latest-stable}
ALPINELINUX_MIRROR=${ALPINELINUX_MIRROR:-http://dl-cdn.alpinelinux.org/alpine}
set -e

View file

@ -3,31 +3,38 @@
set -euo pipefail
echo "--> Alpine Linux 00_prepare.sh"
if [[ -n "${REPO_PROXY+x}" ]]; then
export "https_proxy=$REPO_PROXY" "http_proxy=$REPO_PROXY"
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
ALPINELINUX_PLUGIN_DIR="${ALPINELINUX_PLUGIN_DIR:-"${SCRIPTSDIR}/.."}"
ALPINELINUX_VERSION=${ALPINELINUX_VERSION:-latest-stable}
ALPINELINUX_VERSION=${DIST_VER:-latest-stable}
ALPINELINUX_MIRROR=${ALPINELINUX_MIRROR:-https://dl-cdn.alpinelinux.org/alpine}
ALPINELINUX_ARCH=${ALPINELINUX_ARCH:-x86_64}
APKTOOLS_VERSION=${APKTOOLS_VERSION:-2.14.0-r2}
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}/apk_cache"
echo " --> Downloading Alpine Linux bootstrap (v${APKTOOLS_VERSION-})..."
echo " --> Downloading Alpine Linux bootstrap..."
wget -N -P "$CACHEDIR" "$APKTOOLS_URL"
wget -nd -N -P "$CACHEDIR" -r -l1 -np "$ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/main/$ALPINELINUX_ARCH/" -A "apk-tools-static-*apk"
if [ "${CACHEDIR}/${APKTOOLS_FILE}" -nt "${CACHEDIR}/bootstrap/.extracted" ]; then
if [ "${CACHEDIR}/apk-tools-static"* -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}"
tar -xzC "${CACHEDIR}/bootstrap" -f "${CACHEDIR}/apk-tools-static"*.apk
touch "${CACHEDIR}/bootstrap/.extracted"
else
echo " --> NB: Bootstrap tarball not newer than bootstrap directory, will use existing!"

View file

@ -3,6 +3,18 @@
### 02_install_groups.sh : Install specified additional packages into chroot
echo "--> Alpine Linux 02_install_groups.sh"
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
set -e
if [ "${VERBOSE:-0}" -ge 2 ] || [ "${DEBUG:-0}" -eq 1 ]; then
set -x
@ -22,11 +34,13 @@ fi
PKGGROUPS="$(sed '/^ *#/d; s/ *#.*//' "${PKGLISTFILE}" | sed ':a;N;$!ba; s/\n/ /g; s/ */ /g')"
APKTOOLS_CACHE_DIR="${CACHE_DIR}/apk_cache"
ALPINELINUX_VERSION=${DIST_VER:-latest-stable}
ALPINELINUX_MIRROR=${ALPINELINUX_MIRROR:-https://dl-cdn.alpinelinux.org/alpine}
export APKTOOLS_CACHE_DIR
echo " --> Enabling main and community repos..."
su -c "echo 'https://dl-cdn.alpinelinux.org/alpine/v3.18/main' > $INSTALLDIR/etc/apk/repositories"
su -c "echo 'https://dl-cdn.alpinelinux.org/alpine/v3.18/community' >> $INSTALLDIR/etc/apk/repositories"
su -c "echo '$ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/main' > $INSTALLDIR/etc/apk/repositories"
su -c "echo '$ALPINELINUX_MIRROR/$ALPINELINUX_VERSION/community' >> $INSTALLDIR/etc/apk/repositories"
echo " --> Synchronize resolv.conf..."
cp /etc/resolv.conf "${INSTALL_DIR}/etc/resolv.conf"

View file

@ -3,7 +3,23 @@
### 04_install_qubes.sh : Prepare chroot instance as a Qubes template
echo "--> Alpine linux 04_install_qubes.sh"
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
APKTOOLS_CACHE_DIR="${CACHEDIR}/apk_cache"
ALPINELINUX_VERSION=${DIST_VER:-latest-stable}
QUBESALPINE_MIRROR="${QUBESALPINE_MIRROR:-https://lab.ilot.io/ayakael/repo-apk/-/raw}"
QUBESALPINE_KEYFILE="${QUBESALPINE_KEYFILE:-antoine.martin@protonmail.com-5b3109ad.rsa.pub}"
QUBES_REL="${QUBES_REL:-r4.1}"
export APK_CACHE_DIR
set -e
@ -12,8 +28,8 @@ if [ "$VERBOSE" -ge 2 ] || [ "$DEBUG" -gt 0 ]; then
fi
echo " --> Adding Qubes custom repository..."
su -c "echo 'https://lab.ilot.io/ayakael/repo-apk/-/raw/v3.18/qubes/r4.1' >> $INSTALLDIR/etc/apk/repositories"
wget "https://lab.ilot.io/ayakael/repo-apk/-/raw/v3.18/antoine.martin@protonmail.com-5b3109ad.rsa.pub" -P "$INSTALLDIR"/etc/apk/keys
su -c "echo '$QUBESALPINE_MIRROR/$ALPINELINUX_VERSION/qubes/$QUBES_REL' >> $INSTALLDIR/etc/apk/repositories"
wget "$QUBESALPINE_MIRROR/$ALPINELINUX_VERSION/$QUBESALPINE_KEYFILE" -P "$INSTALLDIR"/etc/apk/keys
echo " --> Synchronize resolv.conf..."
cp /etc/resolv.conf "${INSTALLDIR}/etc/resolv.conf"