diff options
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 |
