aboutsummaryrefslogtreecommitdiffstats
path: root/.extras/test-build
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-14 16:13:04 +0200
committerDanilo M. <danix@danix.xyz>2026-07-14 16:13:04 +0200
commitb50ad8786a116bf4d30324b1bdfa65db71699e83 (patch)
tree59943e672f3c36db85cd2990317171f36b82bfe5 /.extras/test-build
parent2b75214a975be9b9bef4824b78304a23fbe5f078 (diff)
downloadsbo-slackbuilds-b50ad8786a116bf4d30324b1bdfa65db71699e83.tar.gz
sbo-slackbuilds-b50ad8786a116bf4d30324b1bdfa65db71699e83.zip
test-build: variant-namespace the dep cache and prune stale digests
The dep cache was keyed on image digest alone, so a nightly image rebuild orphaned the old digest's cache dir forever (disk creep). Namespace it as <variant>-<digest> and, on each run, prune superseded digests of the SAME variant. Scoping to the variant means a --current run does not wipe the 15.0 cache, so testing both trees back-to-back still reuses built deps (e.g. google-go-lang). Correctness was already fine (digest self-invalidates); this just stops the accumulation, matching sbo-batch-test's invalidate-on-base-update. Add three prune self-checks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to '.extras/test-build')
-rwxr-xr-x.extras/test-build22
1 files changed, 19 insertions, 3 deletions
diff --git a/.extras/test-build b/.extras/test-build
index 26bf2a4..6c2d580 100755
--- a/.extras/test-build
+++ b/.extras/test-build
@@ -425,16 +425,32 @@ cache_label() {
fi
}
-# Compute CACHE_ROOT from the image's digest. Falls back to the tag if the
-# digest cannot be read (still isolates per image reference).
+# Compute CACHE_ROOT from the image's digest, namespaced by variant. Falls back
+# to the tag if the digest cannot be read (still isolates per image reference).
+# The dir is "<variant>-<digest>", so an image rebuild changes the digest and
+# self-invalidates the cache (deps built against the old base are never reused).
+#
+# Prune stale digests of THIS variant on the way in: a base update leaves the
+# old <variant>-<olddigest> dir orphaned, so drop it. Scoped to the variant so a
+# --current run does not wipe the 15.0 cache (both live caches survive, and
+# testing both trees back-to-back still reuses built deps).
resolve_cache_root() {
[[ -z "$PKG_CACHE" ]] && { CACHE_ROOT=""; return; }
local digest
digest="$(docker image inspect --format '{{index .Id}}' "$ACTIVE_IMAGE" 2>/dev/null)"
[[ -z "$digest" ]] && digest="tag-${ACTIVE_IMAGE//[^a-zA-Z0-9._-]/_}"
digest="${digest//[^a-zA-Z0-9._-]/_}"
- CACHE_ROOT="$PKG_CACHE/$digest"
+ local name="${VERSION_ID}-${digest}"
+ CACHE_ROOT="$PKG_CACHE/$name"
mkdir -p "$CACHE_ROOT"
+
+ # drop superseded caches for this variant only
+ local d
+ for d in "$PKG_CACHE/${VERSION_ID}-"*; do
+ [[ -d "$d" ]] || continue
+ [[ "$(basename "$d")" == "$name" ]] && continue
+ rm -rf "$d"
+ done
}
# Does SlackBuild dir $1 directly require any prog in the dead list (nameref $2)?