diff options
| author | Danilo M. <danix@danix.xyz> | 2026-07-14 15:29:45 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-07-14 15:29:45 +0200 |
| commit | e129f089e9e014366591808fc48ad5ccce37858c (patch) | |
| tree | 4e17baa3b35ffe13404757b319a47b463f58e01b /.extras/test-build | |
| parent | e4edbf22caf1558217ea9aff43a81dd4b5263516 (diff) | |
| download | sbo-slackbuilds-e129f089e9e014366591808fc48ad5ccce37858c.tar.gz sbo-slackbuilds-e129f089e9e014366591808fc48ad5ccce37858c.zip | |
test-build: target the local SlackBuild (CWD/path), deps from the tree
The tool resolved the target package from the SBo tree, so it tested the
already-published version, not the local edit under test. Useless for the
maintenance workflow, where the point is to verify an edited SlackBuild while
its deps come from the tree.
resolve_target_dir now takes the target from where you are:
- a path (absolute, ./x, or containing /): that dir
- a bare name: ./<name>/ under CWD, else CWD itself if it IS <name>/
Repo-agnostic; deps still resolve from the configured SBo tree via
find_slackbuild_dir. Add four target-resolution self-checks.
Also source /etc/profile.d/*.sh in the build container before running the
SlackBuild: the heredoc is a non-login shell, so a bare `go build` picked the
system gccgo 1.18 instead of the installed google-go-lang; sourcing profile.d
activates dep-provided env (GOROOT/PATH, cargo, ...) as a real login build would.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to '.extras/test-build')
| -rwxr-xr-x | .extras/test-build | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/.extras/test-build b/.extras/test-build index 681ddf7..26bf2a4 100755 --- a/.extras/test-build +++ b/.extras/test-build @@ -158,6 +158,32 @@ find_slackbuild_dir() { category_of() { basename "$(dirname "$1")"; } pkg_key() { echo "$(category_of "$1")/$(basename "$1")"; } +# Resolve the TARGET to test from CWD or a path (repo-agnostic). The target is +# the SlackBuild you are editing, wherever it lives; its deps come from the +# configured SBo tree (see find_slackbuild_dir), NOT the other way around. +# - a path (absolute, or containing '/', or '.'/'./x'): use that dir directly +# - a bare name: ./<name>/ under CWD, else CWD itself if it IS <name>/ +# Prints the resolved absolute dir on success; returns 1 (with a message) if the +# dir has no matching <name>.info. +resolve_target_dir() { + local arg="$1" dir prog + if [[ "$arg" == /* || "$arg" == .* || "$arg" == */* ]]; then + dir="${arg%/}"; prog="$(basename "$dir")" + elif [[ -f "./$arg/$arg.info" ]]; then + dir="./$arg"; prog="$arg" + elif [[ "$(basename "$PWD")" == "$arg" && -f "./$arg.info" ]]; then + dir="."; prog="$arg" + else + echo "Target '$arg' not found: no ./$arg/$arg.info, and CWD is not $arg/." >&2 + return 1 + fi + if [[ ! -f "$dir/$prog.info" ]]; then + echo "Target dir '$dir' has no $prog.info (expected a SlackBuild package dir)." >&2 + return 1 + fi + ( cd "$dir" && pwd ) # emit absolute path +} + read_requires() { local info="$1" # shellcheck disable=SC1090 @@ -534,6 +560,16 @@ for u in $DL; do fi done +# Source /etc/profile.d so dep-provided env is live (google-go-lang sets GOROOT +# + PATH to its go here, rust-opt sets cargo, etc.). This heredoc runs in a +# non-login shell, which does NOT read profile.d, so a bare `go build` would +# otherwise pick the system gccgo instead of the installed google-go-lang. +set +u # profile.d scripts routinely reference unset vars +for pf in /etc/profile.d/*.sh; do + [ -r "$pf" ] && . "$pf" +done +set -u + chmod +x ./"$prog".SlackBuild if ! ./"$prog".SlackBuild; then echo BUILD-FAILED > "$statf"; exit 1 @@ -784,10 +820,10 @@ main() { mkdir -p "$RUN_DIR" : > "$RUN_DIR/build-order.txt" - # Single-package mode: resolve the name in the active tree. + # The target is the local SlackBuild under test (CWD or a path); its deps are + # resolved from the configured SBo tree during _resolve_visit. local tdir - if ! tdir="$(find_slackbuild_dir "$TARGET_ARG")"; then - echo "Program not found in the SBo tree ($ACTIVE_TREE): $TARGET_ARG" >&2 + if ! tdir="$(resolve_target_dir "$TARGET_ARG")"; then exit 1 fi |
