aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-13 10:51:48 +0200
committerDanilo M. <danix@danix.xyz>2026-07-13 10:51:48 +0200
commit4a3d6a6698bd2d8415d117a2ea4b1bd88ea3102f (patch)
treed33c33a5fc429b9271a2b6c5243d319d87633c98
parent44f03382065d2742d474fa45b13d07189bae9767 (diff)
downloadsbo-slackbuilds-4a3d6a6698bd2d8415d117a2ea4b1bd88ea3102f.tar.gz
sbo-slackbuilds-4a3d6a6698bd2d8415d117a2ea4b1bd88ea3102f.zip
test-build: run_target orchestration + summary + confirm
-rwxr-xr-x.extras/test-build147
1 files changed, 147 insertions, 0 deletions
diff --git a/.extras/test-build b/.extras/test-build
index 325f5c4..fe864bb 100755
--- a/.extras/test-build
+++ b/.extras/test-build
@@ -44,6 +44,8 @@ TARGET_ARG=""
ACTIVE_TREE="" # selected SBo tree (by version)
ACTIVE_IMAGE="" # selected image tag (by version)
RUN_DIR="" # timestamped log dir for this run
+DEPS_DIR="" # per-run host dir of built dep .txz, mounted into the container
+BUILD_OUT="" # per-run host dir where built packages are copied out
# Status tracking. Keyed by "category/prog". Parallel assoc arrays.
declare -A ST_STATUS=()
@@ -560,6 +562,151 @@ CONTAINER_EOF
return 1
}
+# confirm_order: print the resolved order (overrides marked) and ask to proceed.
+# --yes skips the prompt but the order is still printed. --dry-run never reaches
+# here. Returns 0 to proceed, 1 to abort.
+confirm_order() {
+ local target_dir="$1"
+ echo " build order (${VERSION_ID}):"
+ local d
+ for d in "${RESOLVED_ORDER[@]}"; do
+ local it=0; [[ "$d" == "$target_dir" ]] && it=1
+ local rdm=""; [[ "${HAS_README[$d]:-}" == 1 ]] && rdm=" [%README%]"
+ printf " %-30s %s%s\n" "$(pkg_key "$d")" "$(cache_label "$d" "$it")" "$rdm"
+ echo "$(pkg_key "$d")" >> "$RUN_DIR/build-order.txt"
+ done
+ # note fetch deps (built via sbopkg in-container, not in the order list)
+ local fp
+ for fp in "${!FETCH_DEPS[@]}"; do
+ printf " %-30s %s\n" "$fp" "fetch (sbopkg in container)"
+ done
+ [[ $ASSUME_YES -eq 1 ]] && return 0
+ local reply
+ read -rp " Proceed? [Y/n] " reply
+ [[ -z "$reply" || "$reply" =~ ^[Yy]$ ]]
+}
+
+# run_target <target-slackbuild-dir>
+run_target() {
+ local target_dir="$1"
+ local tkey; tkey="$(pkg_key "$target_dir")"
+
+ echo
+ echo "=== Target: $tkey (${VERSION_ID}) ==="
+ resolve_target "$target_dir"
+ apply_overrides_to_order
+
+ # Hard resolution failures: report and stop, do not build.
+ if [[ ${#CYCLES[@]} -gt 0 || ${#UNMET[@]} -gt 0 ]]; then
+ local why=""
+ if [[ ${#UNMET[@]} -gt 0 ]]; then
+ local u
+ for u in "${!UNMET[@]}"; do why+="unmet:$u(${UNMET[$u]}) "; done
+ fi
+ [[ ${#CYCLES[@]} -gt 0 ]] && why+="${CYCLES[*]}"
+ ST_STATUS["$tkey"]="UNMET-DEP"
+ ST_REASON["$tkey"]="$why"
+ echo " resolution failed: $why"
+ echo " add an override rule ($TB_OVERRIDES) and rerun, or fix the tree." >&2
+ return
+ fi
+
+ if [[ $DRY_RUN -eq 1 ]]; then
+ echo " build order (dry-run):"
+ local d
+ for d in "${RESOLVED_ORDER[@]}"; do
+ local it=0; [[ "$d" == "$target_dir" ]] && it=1
+ local rdm=""; [[ "${HAS_README[$d]:-}" == 1 ]] && rdm=" [%README%]"
+ printf " %-30s %s%s\n" "$(pkg_key "$d")" "$(cache_label "$d" "$it")" "$rdm"
+ echo "$(pkg_key "$d")" >> "$RUN_DIR/build-order.txt"
+ done
+ local fp
+ for fp in "${!FETCH_DEPS[@]}"; do
+ printf " %-30s %s\n" "$fp" "fetch (sbopkg in container)"
+ done
+ return
+ fi
+
+ if ! confirm_order "$target_dir"; then
+ echo " aborted."
+ ST_STATUS["$tkey"]="ABORTED"
+ return
+ fi
+
+ # Per-run docker workdirs (host side, discarded after the run).
+ DEPS_DIR="$RUN_DIR/deps"; BUILD_OUT="$RUN_DIR/out"
+ mkdir -p "$DEPS_DIR" "$BUILD_OUT"
+
+ local d failed_progs=()
+ for d in "${RESOLVED_ORDER[@]}"; do
+ local key; key="$(pkg_key "$d")"
+ local prog; prog="$(basename "$d")"
+
+ if depends_on_failed "$d" failed_progs; then
+ ST_STATUS["$key"]="BLOCKED-BY-DEP"
+ ST_REASON["$key"]="blocked by failed dep"
+ [[ "${HAS_README[$d]:-}" == "1" ]] && ST_README["$key"]=1
+ echo " $key: BLOCKED-BY-DEP"
+ failed_progs+=("$prog")
+ continue
+ fi
+
+ local it=0; [[ "$d" == "$target_dir" ]] && it=1
+ echo " building $key ..."
+ if build_one "$d" "$it"; then
+ echo " $key: ${ST_STATUS[$key]} (${ST_TIME[$key]}s)"
+ else
+ echo " $key: ${ST_STATUS[$key]} (${ST_TIME[$key]}s)"
+ failed_progs+=("$prog")
+ fi
+ done
+}
+
+# =============================================================================
+# SUMMARY (ported)
+# =============================================================================
+print_summary() {
+ local total=$SECONDS
+ local succ=0 fail=0 blocked=0 cached=0
+ local summary="$RUN_DIR/summary.log"
+
+ {
+ echo "test-build run summary"
+ echo "target: $TARGET_ARG version: $VERSION_ID"
+ echo
+ } > "$summary"
+
+ echo
+ echo "================ SUMMARY ================"
+ local key
+ for key in "${!ST_STATUS[@]}"; do
+ local st="${ST_STATUS[$key]}" rsn="${ST_REASON[$key]:-}" t="${ST_TIME[$key]:-0}"
+ local rd=""; [[ "${ST_README[$key]:-}" == "1" ]] && rd=" [%README%]"
+ local col="$C_YEL"
+ case "$st" in
+ SUCCESS) col="$C_GRN"; ((succ++)) ;;
+ CACHED) col="$C_GRN"; ((cached++)) ;;
+ BLOCKED-BY-DEP|UNMET-DEP|ABORTED) col="$C_YEL"; ((blocked++)) ;;
+ *) col="$C_RED"; ((fail++)) ;;
+ esac
+ printf "%s%-30s %-16s%s %s%s (%ss)\n" "$col" "$key" "$st" "$C_RST" "$rsn" "$rd" "$t"
+ printf "%-30s %-16s %s%s (%ss)\n" "$key" "$st" "$rsn" "$rd" "$t" >> "$summary"
+ done
+ echo "----------------------------------------"
+ printf "%s%d succeeded%s, %s%d failed%s, %s%d blocked%s, %s%d cached%s, total %ss\n" \
+ "$C_GRN" "$succ" "$C_RST" "$C_RED" "$fail" "$C_RST" "$C_YEL" "$blocked" "$C_RST" \
+ "$C_GRN" "$cached" "$C_RST" "$total"
+ echo "logs: $RUN_DIR"
+ if [[ $fail -eq 0 && $blocked -eq 0 ]]; then
+ echo "${C_GRN}All green.${C_RST} Safe to build the SBo submission tarball on the host."
+ fi
+ {
+ echo
+ echo "$succ succeeded, $fail failed, $blocked blocked, $cached cached, total ${total}s"
+ echo "logs: $RUN_DIR"
+ } >> "$summary"
+}
+
main() {
parse_args "$@"
init_color