aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-07-13 10:13:05 +0200
committerDanilo M. <danix@danix.xyz>2026-07-13 10:13:05 +0200
commit1a39e22ddfd989591620995284187fbfbbf93f91 (patch)
tree26bedb8bc8526dcc6f61d79878069ad1736ce8f0
parenteb749440407dafe821d390e093f2341478f93640 (diff)
downloadsbo-slackbuilds-1a39e22ddfd989591620995284187fbfbbf93f91.tar.gz
sbo-slackbuilds-1a39e22ddfd989591620995284187fbfbbf93f91.zip
test-build: config, arg parsing, version selection
-rwxr-xr-x.extras/test-build103
-rw-r--r--.extras/test-build-config.example18
-rw-r--r--.extras/test-logic.sh14
3 files changed, 134 insertions, 1 deletions
diff --git a/.extras/test-build b/.extras/test-build
index 51faadc..4d3f158 100755
--- a/.extras/test-build
+++ b/.extras/test-build
@@ -33,8 +33,109 @@ TB_OVERRIDES="${TB_OVERRIDES:-$HOME/.config/sbo-testbuild/overrides}"
set -uo pipefail
# Not -e: a package build failing is a handled outcome, not a script crash.
+# ---- flags / globals --------------------------------------------------------
+USE_COLOR=1 # --no-color or non-TTY disables
+DRY_RUN=0 # --dry-run: resolve + print order, do not build
+ASSUME_YES=0 # --yes: skip the confirm prompt (still prints the order)
+USE_CACHE=1 # --no-cache disables the dep cache for one run
+VERSION_ID="current" # "current" | "15.0"; set by --stable
+TARGET_ARG=""
+
+ACTIVE_TREE="" # selected SBo tree (by version)
+ACTIVE_IMAGE="" # selected image tag (by version)
+RUN_DIR="" # timestamped log dir for this run
+
+# Status tracking. Keyed by "category/prog". Parallel assoc arrays.
+declare -A ST_STATUS=()
+declare -A ST_REASON=()
+declare -A ST_TIME=()
+declare -A ST_README=()
+
+usage() {
+ cat <<'EOF'
+test-build - verify an SBo package builds on a target Slackware in docker
+
+USAGE:
+ test-build [OPTIONS] <program-name>
+
+OPTIONS:
+ -h, --help This text.
+ --stable Target Slackware 15.0 (image + tree). Default is -current.
+ --dry-run Resolve, apply overrides, print the build order, do not build.
+ --yes Skip the confirm prompt (the order is still printed first).
+ --no-cache Rebuild all deps this run, ignore/refresh the cache.
+ --no-color Disable ANSI color (auto-disabled when stdout is not a TTY).
+EOF
+}
+
+parse_args() {
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -h|--help) usage; exit 0 ;;
+ --stable|15.0) VERSION_ID="15.0"; shift ;;
+ --dry-run) DRY_RUN=1; shift ;;
+ --yes) ASSUME_YES=1; shift ;;
+ --no-cache) USE_CACHE=0; shift ;;
+ --no-color) USE_COLOR=0; shift ;;
+ -*) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;;
+ *)
+ if [[ -n "$TARGET_ARG" ]]; then
+ echo "Only one target accepted (got '$TARGET_ARG' and '$1')." >&2
+ exit 2
+ fi
+ TARGET_ARG="$1"; shift ;;
+ esac
+ done
+ if [[ -z "$TARGET_ARG" ]]; then
+ echo "No target given." >&2; usage >&2; exit 2
+ fi
+}
+
+init_color() {
+ if [[ $USE_COLOR -eq 1 && -t 1 ]]; then
+ C_RED=$'\e[31m'; C_GRN=$'\e[32m'; C_YEL=$'\e[33m'; C_RST=$'\e[0m'
+ else
+ C_RED=""; C_GRN=""; C_YEL=""; C_RST=""
+ fi
+}
+
+# Map VERSION_ID to the active tree + image. No I/O, unit-testable.
+select_version_paths() {
+ if [[ "$VERSION_ID" == "15.0" ]]; then
+ ACTIVE_TREE="$SBO_TREE_STABLE"; ACTIVE_IMAGE="$IMAGE_STABLE"
+ else
+ ACTIVE_TREE="$SBO_TREE_CURRENT"; ACTIVE_IMAGE="$IMAGE_CURRENT"
+ fi
+}
+
+# require_config: the external config must exist and set the version's paths.
+require_config() {
+ if [[ ! -f "$TB_CONFIG" ]]; then
+ cat >&2 <<EOF
+No config file: $TB_CONFIG
+Copy the example and edit it:
+
+ mkdir -p "\$(dirname "$TB_CONFIG")"
+ cp .extras/test-build-config.example "$TB_CONFIG"
+ \${EDITOR:-vi} "$TB_CONFIG"
+EOF
+ exit 1
+ fi
+ select_version_paths
+ if [[ -z "$ACTIVE_TREE" || -z "$ACTIVE_IMAGE" ]]; then
+ echo "Config $TB_CONFIG is missing the tree/image for version '$VERSION_ID'." >&2
+ exit 1
+ fi
+ if [[ ! -d "$ACTIVE_TREE" ]]; then
+ echo "SBo tree for '$VERSION_ID' does not exist: $ACTIVE_TREE" >&2
+ exit 1
+ fi
+}
+
main() {
- :
+ parse_args "$@"
+ init_color
+ require_config
}
main "$@"
diff --git a/.extras/test-build-config.example b/.extras/test-build-config.example
new file mode 100644
index 0000000..a07b2c1
--- /dev/null
+++ b/.extras/test-build-config.example
@@ -0,0 +1,18 @@
+# test-build config. Copy to ~/.config/sbo-testbuild/config and edit.
+# Override the path with the TB_CONFIG environment variable.
+
+# Local SBo trees, one per target Slackware version.
+SBO_TREE_CURRENT="/home/danix/SBo/current"
+SBO_TREE_STABLE="/home/danix/SBo/15.0"
+
+# Ready image tags (built by a separate job, consumed here by tag).
+IMAGE_CURRENT="sbo-testbuild:current"
+IMAGE_STABLE="sbo-testbuild:15.0"
+
+# Where per-run logs land.
+LOG_ROOT="/home/danix/.cache/sbo-test-build"
+
+# Dependency package cache (host dir). Empty disables caching.
+# Namespaced internally by image digest, so it self-invalidates on image update
+# and keeps current vs 15.0 separate.
+PKG_CACHE="/home/danix/.cache/sbo-test-build/pkgcache"
diff --git a/.extras/test-logic.sh b/.extras/test-logic.sh
index 20041a9..81a0841 100644
--- a/.extras/test-logic.sh
+++ b/.extras/test-logic.sh
@@ -30,6 +30,20 @@ bad() { echo " FAIL: $1"; ((fail++)); return 0; }
# Placeholder assertion so this file runs before any logic exists.
ok "script sources without executing main"
+# --- version selection ------------------------------------------------------
+SBO_TREE_CURRENT="/trees/current"
+SBO_TREE_STABLE="/trees/stable"
+IMAGE_CURRENT="sbo-testbuild:current"
+IMAGE_STABLE="sbo-testbuild:15.0"
+
+VERSION_ID="current"; select_version_paths
+[[ "$ACTIVE_TREE" == "/trees/current" ]] && ok "current -> current tree" || bad "current tree wrong: [$ACTIVE_TREE]"
+[[ "$ACTIVE_IMAGE" == "sbo-testbuild:current" ]] && ok "current -> current image" || bad "current image wrong: [$ACTIVE_IMAGE]"
+
+VERSION_ID="15.0"; select_version_paths
+[[ "$ACTIVE_TREE" == "/trees/stable" ]] && ok "15.0 -> stable tree" || bad "stable tree wrong: [$ACTIVE_TREE]"
+[[ "$ACTIVE_IMAGE" == "sbo-testbuild:15.0" ]] && ok "15.0 -> stable image" || bad "stable image wrong: [$ACTIVE_IMAGE]"
+
echo
echo "$pass passed, $fail failed"
[[ $fail -eq 0 ]] || exit 1