diff options
author | CyberLeo <cyberleo@cyberleo.net> | 2020-03-27 02:57:41 -0500 |
---|---|---|
committer | CyberLeo <cyberleo@cyberleo.net> | 2020-03-27 03:09:42 -0500 |
commit | 616ec11d32e253059f49509ccc65fd61698316c8 (patch) | |
tree | 2f47feaa38ed04d461621b2583a879171cc4419f /adelie-build-cd | |
parent | 8dabe8373558c656a84eb921694e57f967408da0 (diff) | |
download | image-616ec11d32e253059f49509ccc65fd61698316c8.tar.gz image-616ec11d32e253059f49509ccc65fd61698316c8.tar.bz2 image-616ec11d32e253059f49509ccc65fd61698316c8.tar.xz image-616ec11d32e253059f49509ccc65fd61698316c8.zip |
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.
Diffstat (limited to 'adelie-build-cd')
-rwxr-xr-x | adelie-build-cd | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/adelie-build-cd b/adelie-build-cd index 0e57a03..b5870e2 100755 --- a/adelie-build-cd +++ b/adelie-build-cd @@ -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 |