commit 7fe85ba7b0dd4e56edae7a6934fc4aa3ff22cf5c
parent 739318f934569fc67055b4d0fed27aa4ab73f208
Author: Robin Bron <robin.bron@yourhosting.nl>
Date: Sun, 27 Sep 2026 22:44:54 +0200
sysroot doesn't rely on APKINDEX being up-to-date during pkg build
Diffstat:
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/mk/deps.sh b/mk/deps.sh
@@ -60,6 +60,8 @@ read_vars() {
makedepends=
hostmakedepends=
subpackages=
+ version=
+ revision=0
# Templates reference these; define them so sourcing cannot fail on an
# unset variable under `set -u`.
SYSROOT=; DESTDIR=; WRKSRC=; FILESDIR=; WORK=; SRCDEST=
@@ -72,7 +74,8 @@ read_vars() {
vmkdir() { :; }
# shellcheck disable=SC1090
. "${t}" >/dev/null 2>&1 || true
- printf '%s|%s|%s|%s\n' "${depends}" "${makedepends}" "${hostmakedepends}" "${subpackages}"
+ printf '%s|%s|%s|%s|%s|%s\n' "${depends}" "${makedepends}" "${hostmakedepends}" \
+ "${subpackages}" "${version}" "${revision}"
)
}
@@ -289,6 +292,13 @@ case "${1:-}" in
seed) shift; cmd_seed "$@" ;;
owner) shift; owner_of "${1:?usage: deps.sh owner <name>}" ;;
subpkgs) shift; field "${1:?usage: deps.sh subpkgs <pkg>}" 4 ;;
+ # A subpackage carries its owning template's version.
+ pkgver) shift
+ _o=$(owner_of "${1:?usage: deps.sh pkgver <name>}") || die "no such package: $1"
+ _v=$(field "${_o}" 5)
+ [ -n "${_v}" ] || die "${_o}: template sets no version"
+ printf '%s-r%s\n' "${_v}" "$(field "${_o}" 6)"
+ ;;
rdeps) shift; cmd_rdeps "$@" ;;
changed) shift; cmd_changed "$@" ;;
check) cmd_check ;;
diff --git a/mk/sysroot.sh b/mk/sysroot.sh
@@ -112,7 +112,39 @@ done
# Strategy: try to install all, but if apk fails due to missing pkg, retry
# without the leaf targets.
-REPO_ARGS=""
+# The published APKINDEX only gains a package once the index task reruns, so
+# within a single pipeline run it lags behind what has actually been uploaded.
+# Fetch the exact version each template pins straight from the repo and index
+# it locally; anything missing here still resolves through APKINDEX below.
+STAGE_BASE="${ROOT}/build/sysroot-stage"
+STAGE="${STAGE_BASE}/${ARCH}"
+STAGE_ARGS=""
+for r in ${REPOS}; do
+ case "${r}" in http://*|https://*) ;; *) continue ;; esac
+ command -v curl >/dev/null 2>&1 || break
+ mkdir -p "${STAGE}"
+ staged=0
+ for n in ${PKGS_TO_INSTALL}; do
+ pv=$("${ROOT}/mk/deps.sh" pkgver "${n}" 2>/dev/null) || continue
+ apk_name="${n}-${pv}.apk"
+ if [ -f "${STAGE}/${apk_name}" ]; then staged=$((staged + 1)); continue; fi
+ url=$(printf '%s' "${r%/}/${ARCH}/${apk_name}" \
+ | sed 's#://#___PROTO___#; s#//*#/#g; s#___PROTO___#://#')
+ if curl -fsSL -o "${STAGE}/${apk_name}" "${url}" 2>/dev/null; then
+ echo " staged ${apk_name}"
+ staged=$((staged + 1))
+ else
+ rm -f "${STAGE}/${apk_name}"
+ fi
+ done
+ if [ "${staged}" -gt 0 ]; then
+ ( cd "${STAGE}" && "${APK}" index --allow-untrusted -o APKINDEX.tar.gz ./*.apk >/dev/null )
+ STAGE_ARGS=" --repository file://${STAGE_BASE}"
+ fi
+ break
+done
+
+REPO_ARGS="${STAGE_ARGS}"
for r in ${REPOS}; do
case "${r}" in
http://*|https://*|file://*) REPO_ARGS="${REPO_ARGS} --repository ${r}" ;;