From 30149d765d193103c3b8ddd960ac1f41c689df14 Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 15:31:37 -0500 Subject: [PATCH] FreeBSD package.sh: never run a FreeBSD target's binary on another OS Review follow-up. With CARGO_BUILD_TARGET set on a host that is not FreeBSD (say an x86_64 Mac building x86_64-unknown-freebsd), the architectures match but the binary still cannot run, so the --version run is skipped there and the file(1) check is used instead. Part of storytold/craft-common-actions#39. --- packaging/freebsd/package.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.sh index 87e5e29f..7a3ae533 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -45,8 +45,12 @@ case "${CARGO_BUILD_TARGET:-}" in *-unknown-freebsd) ARCH="$(release_arch "${CARGO_BUILD_TARGET%%-*}")" ;; *) echo "CARGO_BUILD_TARGET=$CARGO_BUILD_TARGET is not a FreeBSD target" >&2; exit 2 ;; esac -# Only binaries for this machine run here (the --version check at the end). +# Only binaries for this machine run here (the --version check at the end); a FreeBSD target built +# on another OS never does. HOST_ARCH="$(release_arch "$(uname -m)" 2>/dev/null)" || HOST_ARCH="$(uname -m)" +if [ -n "${CARGO_BUILD_TARGET:-}" ] && [ "$(uname -s)" != FreeBSD ]; then + HOST_ARCH="$(uname -s) $HOST_ARCH" +fi if [ "$DRY_RUN" = 0 ] && [ "$(uname -s)" != FreeBSD ]; then echo "error: build on FreeBSD (or pass --dry-run to check the tree layout)" >&2 exit 2