summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <awilcox@wilcox-tech.com>2020-05-25 03:09:32 +0000
committerA. Wilcox <awilcox@wilcox-tech.com>2020-05-25 03:09:32 +0000
commit90ebd04eb5fa2c3cc46b0768cf92d1fca6e5522e (patch)
tree7ab5201eac117a0842e3a9ce35eabc9870d5b688
parent8dabe8373558c656a84eb921694e57f967408da0 (diff)
parent3fb12f36c8136c7abd998322d900d6e01214e4dc (diff)
downloadimage-90ebd04eb5fa2c3cc46b0768cf92d1fca6e5522e.tar.gz
image-90ebd04eb5fa2c3cc46b0768cf92d1fca6e5522e.tar.bz2
image-90ebd04eb5fa2c3cc46b0768cf92d1fca6e5522e.tar.xz
image-90ebd04eb5fa2c3cc46b0768cf92d1fca6e5522e.zip
Merge branch 'apk-caching' into 'master'
Add cache to apk invocation See merge request adelie/image!4
-rwxr-xr-xadelie-build-cd15
-rw-r--r--adelie-build-cd.812
-rwxr-xr-xadelie-build-txz13
-rw-r--r--adelie-build-txz.812
4 files changed, 50 insertions, 2 deletions
diff --git a/adelie-build-cd b/adelie-build-cd
index 0e57a03..f7d97a0 100755
--- a/adelie-build-cd
+++ b/adelie-build-cd
@@ -74,7 +74,6 @@ usage() {
printf 'Valid phases: clean install initrd iso all\n'
}
-
while [ -n "$1" ]; do
case $1 in
-a | --arch)
@@ -103,6 +102,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
@@ -111,6 +117,9 @@ while [ -n "$1" ]; do
shift
done
+[ -d /etc/apk/cache ] && def_cache=/etc/apk/cache
+[ -z "${MY_ARCH}" -o "${MY_ARCH}" = "${def_arch}" ] || unset def_cache
+
set -a
readonly ARCH=${MY_ARCH:-$def_arch}
readonly KIND=${MY_KIND:-live}
@@ -119,6 +128,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 +171,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
@@ -244,6 +255,7 @@ make_structure() {
if test -n "${DO_FULL+full}"; then
# This ensures we have documentation available on-disc, and to install.
apk --arch $ARCH \
+ ${CACHE:+--cache-dir "${CACHE}"} \
-X "$URL/system/$EXTRA_MIRROR" \
-X "$URL/user/$EXTRA_MIRROR" \
--root squashroot-$ARCH add docs
@@ -251,6 +263,7 @@ make_structure() {
mkdir -p $PACKAGES_DIR
# Fetch all APKs.
apk --arch $ARCH \
+ ${CACHE:+--cache-dir "${CACHE}"} \
-X "$URL/system/$EXTRA_MIRROR" \
-X "$URL/user/$EXTRA_MIRROR" \
--root squashroot-$ARCH fetch -o $PACKAGES_DIR $(apk --root squashroot-$ARCH info)
diff --git a/adelie-build-cd.8 b/adelie-build-cd.8
index 885e29e..76f3184 100644
--- a/adelie-build-cd.8
+++ b/adelie-build-cd.8
@@ -12,6 +12,8 @@
.Op Fl p Ar PHASE
.Op Fl s
.Op Fl v Ar VERSION
+.Op Fl -cache Ar CACHE
+.Op Fl -no-cache
.Sh DESCRIPTION
.Nm
creates a live CD image or installer CD image for Adélie Linux using
@@ -52,6 +54,16 @@ This requires the
suite of utilities to be available.
.It Fl v Ar VERSION
Specifies the version of Adélie Linux to use for the created ISO.
+.It Fl -cache Ar CACHE
+Specifies the location of the cache directory to use, to speed up
+.Xr apk 8
+runs. Defaults to the system cache in
+.Pa /etc/apk/cache
+for the same architecture, or none. This directory must exist, or it is ignored.
+.It Fl -no-cache
+Do not use any cache directory for this
+.Xr apk 8
+run; pull all packages from the repository.
.El
.Ss Phases
The
diff --git a/adelie-build-txz b/adelie-build-txz
index 15d81bf..4387af2 100755
--- a/adelie-build-txz
+++ b/adelie-build-txz
@@ -57,7 +57,6 @@ usage() {
printf 'Default VERSION: %s\n' $def_ver
}
-
while [ -n "$1" ]; do
case $1 in
-a | --arch)
@@ -75,6 +74,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
@@ -83,6 +89,9 @@ while [ -n "$1" ]; do
shift
done
+[ -d /etc/apk/cache ] && def_cache=/etc/apk/cache
+[ -z "${MY_ARCH}" -o "${MY_ARCH}" = "${def_arch}" ] || unset def_cache
+
set -a
readonly ARCH=${MY_ARCH:-$def_arch}
readonly LDARCH=${LDARCH:-$ARCH}
@@ -90,6 +99,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 +142,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
diff --git a/adelie-build-txz.8 b/adelie-build-txz.8
index 4dcc4ca..6dfa9d5 100644
--- a/adelie-build-txz.8
+++ b/adelie-build-txz.8
@@ -9,6 +9,8 @@
.Op Fl a Ar ARCH
.Op Fl -mini
.Op Fl v Ar VERSION
+.Op Fl -cache Ar CACHE
+.Op Fl -no-cache
.Sh DESCRIPTION
.Nm
creates a rootfs tarball, similar to a Gentoo stage3 or Alpine miniroot, using
@@ -29,6 +31,16 @@ Specifies that a mini rootfs (no kernel or live media tools installed) is
desired.
.It Fl v Ar VERSION
Specifies the version of Adélie Linux to use for the created rootfs tarball.
+.It Fl -cache Ar CACHE
+Specifies the location of the cache directory to use, to speed up
+.Xr apk 8
+runs. Defaults to the system cache in
+.Pa /etc/apk/cache
+for the same architecture, or none. This directory must exist, or it is ignored.
+.It Fl -no-cache
+Do not use any cache directory for this
+.Xr apk 8
+run; pull all packages from the repository.
.El
.Sh ENVIRONMENT
.Bl -tag -width "EXTRA_MIRROR" -offset indent -compact