Commit 90ebd04e authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

Merge branch 'apk-caching' into 'master'

Add cache to apk invocation

See merge request !4
parents 8dabe837 3fb12f36
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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