diff --git a/kbuildx/scripts/netbsd-build.sh b/kbuildx/scripts/netbsd-build.sh index 4b78047..0ffd563 100755 --- a/kbuildx/scripts/netbsd-build.sh +++ b/kbuildx/scripts/netbsd-build.sh @@ -3,6 +3,7 @@ set -eu version=$1; repo=$2; ref=$3; label=$4; requested_config=$5; bundle=$6 export PATH=/usr/pkg/gcc15/bin:/usr/pkg/bin:/sbin:/usr/sbin:/bin:/usr/bin +export LD_LIBRARY_PATH=/usr/pkg/gcc15/lib:/usr/pkg/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} mkdir -p /tmp/netbsd-bin for tool in as ld ar ranlib nm strip; do target=$(command -v "x86_64--netbsd-$tool" 2>/dev/null || true) @@ -10,13 +11,18 @@ for tool in as ld ar ranlib nm strip; do target="/usr/pkg/bin/$tool" fi if [ -z "$target" ]; then - target=$(find /usr/pkg -type f -name "*$tool" -perm -111 2>/dev/null | head -n 1 || true) + # Exact or cross-prefixed names only: "*$tool" is too loose — git's + # "scalar" matches "*ar" and once ended up as HOST_AR. + target=$(find /usr/pkg -type f \( -name "$tool" -o -name "*-$tool" \) -perm -111 2>/dev/null | head -n 1 || true) + fi + # Only install tools that can actually run; a binary with a missing + # shared library (or a false find match) would poison the whole build. + if [ -n "$target" ] && "$target" --version >/dev/null 2>&1; then + ln -sf "$target" "/tmp/netbsd-bin/$tool" fi - if [ -n "$target" ]; then ln -sf "$target" "/tmp/netbsd-bin/$tool"; fi done export PATH=/tmp/netbsd-bin:$PATH -export LD_LIBRARY_PATH=/usr/pkg/gcc15/lib:/usr/pkg/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} # Repair /usr/lib/libgnuctf.so.2 only if a real library file exists somewhere; # a dangling symlink would leave /usr/bin/ld unrunnable while looking "fixed". @@ -84,8 +90,8 @@ fi rm -rf "$obj" "$tools" jobs=$(sysctl -n hw.ncpu) cd "$src" -./build.sh -U -u -j"$jobs" -O "$obj" -T "$tools" tools || cat /tmp/nbbu*-config.log -./build.sh -U -u -j"$jobs" -O "$obj" -T "$tools" kernel="$config" || cat /tmp/nbbu*-config.log +./build.sh -U -u -j"$jobs" -O "$obj" -T "$tools" tools +./build.sh -U -u -j"$jobs" -O "$obj" -T "$tools" kernel="$config" kernel=$(find "$obj" -type f -path "*/compile/$config/netbsd" | head -n 1) test -n "$kernel" -a -f "$kernel" base="netbsd-${label}.${artifact_arch}"