diff options
Diffstat (limited to 'sbo-batch-test')
| -rwxr-xr-x | sbo-batch-test | 47 |
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)" |
