diff options
Diffstat (limited to 'sbo-batch-test')
| -rwxr-xr-x | sbo-batch-test | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sbo-batch-test b/sbo-batch-test index a9e3d14..1e0020c 100755 --- a/sbo-batch-test +++ b/sbo-batch-test @@ -307,6 +307,42 @@ update_base() { } # ============================================================================= +# Package cache. Persistent, on-disk store of built packages so unchanged deps +# are installed from cache instead of rebuilt. Layout mirrors the SBo tree: +# $PKG_CACHE/<cat>/<prog>/<prog>-<ver>-<arch>-<build>_<tag>.txz +# One .txz per prog dir (the latest tested build). Key is prog+version; build +# number, arch, and tag do not affect a hit. Empty PKG_CACHE disables caching. +# ============================================================================= + +# Echo the version field of a cached package filename. <file> is a basename like +# prog-1.2-x86_64-1_danix.txz; prog may itself contain dashes, so strip the known +# prog prefix first, then take the field up to the next dash. +_cache_ver_of() { + local prog="$1" base="$2" + base="${base#"$prog"-}" # drop "prog-" + echo "${base%%-*}" # version is up to the next dash +} + +# cache_decision <cat> <prog> <version> -> echoes: cached | bump:OLD:NEW | new +cache_decision() { + local cat="$1" prog="$2" version="$3" + [[ -z "$PKG_CACHE" ]] && { echo new; 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" ]] && { echo new; return; } + local have; have="$(_cache_ver_of "$prog" "$(basename "$newest")")" + if [[ "$have" == "$version" ]]; then + echo cached + else + echo "bump:$have:$version" + fi +} + +# ============================================================================= # SBo tree lookup. Find the SlackBuild dir for a prog name across roots. # Echoes the dir path, returns 0 if found, 1 otherwise. # ============================================================================= |
