From 9fb5b8b84b7822eb8a5aff2b0aaa176a15ff7a4f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 24 Jun 2026 16:38:45 +0200 Subject: Add cache_path + cache_store + tests Co-Authored-By: Claude Opus 4.8 --- sbo-batch-test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'sbo-batch-test') diff --git a/sbo-batch-test b/sbo-batch-test index 1e0020c..c5e6cf1 100755 --- a/sbo-batch-test +++ b/sbo-batch-test @@ -342,6 +342,31 @@ cache_decision() { fi } +# cache_path -> echoes the cached .txz path for that +# version, or nothing. Used to installpkg a cached dep. +cache_path() { + local cat="$1" prog="$2" version="$3" + [[ -z "$PKG_CACHE" ]] && return + local dir="$PKG_CACHE/$cat/$prog" + local f newest="" + for f in "$dir/$prog"-*.t?z; do + [[ -e "$f" ]] || continue + [[ -z "$newest" || "$f" -nt "$newest" ]] && newest="$f" + done + [[ -z "$newest" ]] && return + [[ "$(_cache_ver_of "$prog" "$(basename "$newest")")" == "$version" ]] && echo "$newest" +} + +# cache_store -> clear the prog dir, copy src in. +cache_store() { + local cat="$1" prog="$2" src="$3" + [[ -z "$PKG_CACHE" ]] && return + local dir="$PKG_CACHE/$cat/$prog" + mkdir -p "$dir" + rm -f "$dir"/*.t?z + cp -a "$src" "$dir/" +} + # ============================================================================= # SBo tree lookup. Find the SlackBuild dir for a prog name across roots. # Echoes the dir path, returns 0 if found, 1 otherwise. -- cgit v1.2.3