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-txz | |
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-txz')
-rwxr-xr-x | adelie-build-txz | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/adelie-build-txz b/adelie-build-txz index 15d81bf..b419de1 100755 --- a/adelie-build-txz +++ b/adelie-build-txz @@ -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 |