aboutsummaryrefslogtreecommitdiffstats
path: root/sbo-batch-test
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-24 16:57:53 +0200
committerDanilo M. <danix@danix.xyz>2026-06-24 16:57:53 +0200
commit07af9957bd9d7d273e922323e6469e077b7e7f1d (patch)
tree5a8f223385ba5a07d2d0d657b0c6362aee5a33b6 /sbo-batch-test
parentba13b0ad5b24ff1d508235a4855ae054c9b51900 (diff)
downloadsbo-batch-tester-07af9957bd9d7d273e922323e6469e077b7e7f1d.tar.gz
sbo-batch-tester-07af9957bd9d7d273e922323e6469e077b7e7f1d.zip
Wire cache into build_one: install cached deps, store builds
build_one gains a third arg is_target (default 0). Dependencies with a version-matching cached package are installed from cache (status CACHED) and skip the build entirely. The target always builds. After any successful build, the produced package is copied into PKG_CACHE via cache_store before overlay teardown, making it available for future runs or sibling targets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'sbo-batch-test')
-rwxr-xr-xsbo-batch-test47
1 files changed, 41 insertions, 6 deletions
diff --git a/sbo-batch-test b/sbo-batch-test
index 051e18f..f7ec3e9 100755
--- a/sbo-batch-test
+++ b/sbo-batch-test
@@ -556,21 +556,44 @@ trap cleanup_trap EXIT INT TERM
# Returns 0 on SUCCESS, 1 otherwise.
# =============================================================================
build_one() {
- local tmpdir="$1" dir="$2"
+ local tmpdir="$1" dir="$2" is_target="${3:-0}"
local c="$tmpdir/chroot"
local prog cat key
prog="$(basename "$dir")"; cat="$(category_of "$dir")"; key="$cat/$prog"
local logf="$RUN_DIR/${cat}_${prog}.log"
local start; start=$(date +%s)
+ local version; version="$(version_of "$dir")"
+
+ # %README% reminder carries through to summary
+ [[ "${HAS_README[$dir]:-}" == "1" ]] && ST_README["$key"]=1
+
+ # Dependency with a version-matching cached package: installpkg it into the
+ # overlay and skip the build entirely. The target never takes this path.
+ if [[ "$is_target" != "1" ]]; then
+ local cached; cached="$(cache_path "$cat" "$prog" "$version")"
+ if [[ -n "$cached" ]]; then
+ local workroot="/sbo-work"
+ mkdir -p "$c$workroot"
+ cp -a "$cached" "$c$workroot/"
+ {
+ echo "===== sbo-batch-test: $prog (from cache) ====="
+ echo "cached package: $(basename "$cached")"
+ } >> "$logf"
+ if chroot "$c" /bin/bash -c "installpkg --terse '$workroot/$(basename "$cached")'" >>"$logf" 2>&1; then
+ ST_TIME["$key"]=$(( $(date +%s) - start ))
+ ST_STATUS["$key"]="CACHED"
+ return 0
+ fi
+ # Cache install failed: fall through and build fresh.
+ echo "cache install failed, building fresh" >> "$logf"
+ fi
+ fi
# 1. copy SlackBuild dir into the overlay
local workroot="/sbo-work"
mkdir -p "$c$workroot"
cp -a "$dir" "$c$workroot/$prog"
- # %README% reminder carries through to summary
- [[ "${HAS_README[$dir]:-}" == "1" ]] && ST_README["$key"]=1
-
# 2-5. download, md5, build, install all run INSIDE the chroot non-interactively.
# The heredoc script writes a status token to a known file we read back out.
# overlayfs note: if a build fails ONLY here and works on bare 15.0, suspect
@@ -647,7 +670,18 @@ CHROOT_EOF
local end; end=$(date +%s)
ST_TIME["$key"]=$(( end - start ))
ST_STATUS["$key"]="$status"
- [[ "$status" == "SUCCESS" ]] && return 0
+ if [[ "$status" == "SUCCESS" ]]; then
+ # Copy the produced package out of the overlay into the persistent cache
+ # before teardown, so it can be reused as a dep in this or a later run. The
+ # build wrote to the forced OUTPUT=/sbo-work/output (see the heredoc).
+ local built newest=""
+ for built in "$c"/sbo-work/output/${prog}-*.t?z; do
+ [[ -e "$built" ]] || continue
+ [[ -z "$newest" || "$built" -nt "$newest" ]] && newest="$built"
+ done
+ [[ -n "$newest" ]] && cache_store "$cat" "$prog" "$newest"
+ return 0
+ fi
ST_REASON["$key"]="see $(basename "$logf")"
return 1
}
@@ -741,8 +775,9 @@ run_target() {
continue
fi
+ local it=0; [[ "$d" == "$target_dir" ]] && it=1
echo " building $key ..."
- if build_one "$tmpdir" "$d"; then
+ if build_one "$tmpdir" "$d" "$it"; then
echo " $key: ${ST_STATUS[$key]} (${ST_TIME[$key]}s)"
else
echo " $key: ${ST_STATUS[$key]} (${ST_TIME[$key]}s)"