Verified Commit 616ec11d authored by CyberLeo's avatar CyberLeo
Browse files

Add cache to apk invocation

Repeated test-image creation hammers the repository servers and slows
down image creation. If the host has an apk cache set up in
/etc/apk/cache, use that; otherwise, allow a directory to be specified.
parent 8dabe837
......@@ -74,6 +74,7 @@ usage() {
printf 'Valid phases: clean install initrd iso all\n'
}
[ -d /etc/apk/cache ] && def_cache=/etc/apk/cache
while [ -n "$1" ]; do
case $1 in
......@@ -103,6 +104,13 @@ while [ -n "$1" ]; do
shift
readonly MY_VER=$1
;;
-c | --cache)
shift
readonly MY_CACHE=$1
;;
--no-cache)
unset def_cache
;;
*)
usage >&2
exit 127
......@@ -119,6 +127,7 @@ readonly PHASE=${MY_PHASE:-all}
readonly VERSION=${MY_VER:-$def_ver}
readonly APKVER=${MY_APKVER:-$VERSION}
readonly URL=${MY_URL:-https://distfiles.adelielinux.org/adelie/$APKVER/}
readonly CACHE=${MY_CACHE:-$def_cache}
set +a
ensure_commands
......@@ -161,6 +170,7 @@ install_pkgs() {
mknod squashroot-$ARCH/dev/urandom c 1 9
mkdir -p squashroot-$ARCH/usr/sbin
apk --arch $ARCH \
${CACHE:+--cache-dir "${CACHE}"} \
-X "$URL/system/$EXTRA_MIRROR" \
-X "$URL/user/$EXTRA_MIRROR" \
-U --root squashroot-$ARCH --initdb add $PACKAGES $ARCH_PKGS $KIND_PKGS
......
......@@ -57,6 +57,7 @@ usage() {
printf 'Default VERSION: %s\n' $def_ver
}
[ -d /etc/apk/cache ] && def_cache=/etc/apk/cache
while [ -n "$1" ]; do
case $1 in
......@@ -75,6 +76,13 @@ while [ -n "$1" ]; do
shift
readonly MY_VER=$1
;;
-c | --cache)
shift
readonly MY_CACHE=$1
;;
--no-cache)
unset def_cache
;;
*)
usage >&2
exit 127
......@@ -90,6 +98,7 @@ readonly PHASE=${MY_PHASE:-all}
readonly VERSION=${MY_VER:-$def_ver}
readonly APKVER=${MY_APKVER:-$VERSION}
readonly URL=${MY_URL:-https://distfiles.adelielinux.org/adelie/$VERSION/}
readonly CACHE=${MY_CACHE:-$def_cache}
set +a
ensure_commands
......@@ -132,6 +141,7 @@ install_pkgs() {
mknod rootfs-$ARCH/dev/urandom c 1 9
mkdir -p rootfs-$ARCH/usr/sbin
apk --arch $ARCH \
${CACHE:+--cache-dir "${CACHE}"} \
-X "$URL/system/$EXTRA_MIRROR" \
-X "$URL/user/$EXTRA_MIRROR" \
-U --root rootfs-$ARCH --initdb add $PACKAGES $ARCH_PKGS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment