From 79adead5bf94f7d96c283f63bb146e216648e7fc Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 14:14:07 -0500 Subject: [PATCH 1/5] FreeBSD package.sh: package the aarch64 cross build The release workflow now cross-compiles FreeBSD aarch64 inside the x86_64 VM (storytold/craft-common-actions#50) and sets CARGO_BUILD_TARGET=aarch64-unknown-freebsd. package.sh now reads the binaries from target//release when CARGO_BUILD_TARGET is set, names the archive after the target instead of uname -m, and skips the --version run when the binary is for another architecture than the machine. x86_64 packages are unchanged. Part of storytold/craft-common-actions#39. --- packaging/freebsd/package.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.sh index 71af80c3..e232919c 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -29,11 +29,18 @@ while [ $# -gt 0 ]; do done # FreeBSD calls x86_64 "amd64"; release names use the Rust/Linux spelling. -case "$(uname -m)" in - amd64 | x86_64) ARCH=x86_64 ;; - arm64 | aarch64) ARCH=aarch64 ;; - *) echo "unsupported architecture $(uname -m)" >&2; exit 2 ;; -esac +release_arch() { + case "$1" in + amd64 | x86_64) echo x86_64 ;; + arm64 | aarch64) echo aarch64 ;; + *) echo "unsupported architecture $1" >&2; return 2 ;; + esac +} +HOST_ARCH="$(release_arch "$(uname -m)")" +# The release workflow cross-compiles aarch64 in an x86_64 VM with CARGO_BUILD_TARGET set to +# aarch64-unknown-freebsd (craft-common-actions#39): name the archive after the target. +ARCH="$HOST_ARCH" +if [ -n "${CARGO_BUILD_TARGET:-}" ]; then ARCH="$(release_arch "${CARGO_BUILD_TARGET%%-*}")"; fi BASENAME="soundcraft-$VERSION-freebsd-$ARCH" echo "==> SoundCraft $VERSION for FreeBSD $ARCH" @@ -41,7 +48,8 @@ echo "==> SoundCraft $VERSION for FreeBSD $ARCH" if [ "$SKIP_BUILD" = 0 ]; then (cd "$ROOT" && cargo build --release --locked -p soundcraft -p soundcraft-cli) fi -BIN="$CARGO_TARGET_DIR/release" +# Cargo puts a cross build under target//release. +BIN="$CARGO_TARGET_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}release" WORK="$CARGO_TARGET_DIR/freebsd-package" STAGE="$WORK/$BASENAME" rm -rf "$WORK" @@ -63,6 +71,10 @@ copy_docs "$STAGE/share/doc/soundcraft" tar -C "$WORK" -czf "$DIST/$BASENAME.tar.gz" "$BASENAME" echo "wrote $DIST/$BASENAME.tar.gz" -"$STAGE/bin/soundcraft-cli" --version +if [ "$ARCH" = "$HOST_ARCH" ]; then + "$STAGE/bin/soundcraft-cli" --version +else + echo "skipping --version: an $ARCH binary does not run on this $HOST_ARCH machine" +fi echo "==> done" ls -lh "$DIST" From ce42466dd6e336adf2ff9be180cbdb37b14c95cd Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 14:32:12 -0500 Subject: [PATCH 2/5] FreeBSD package.sh: accept only FreeBSD targets, check cross-built binaries Review follow-up. CARGO_BUILD_TARGET must now be a *-unknown-freebsd triple, so a Linux or macOS target can no longer be packaged under a FreeBSD name, and it is read before uname -m, so an unsupported host does not block a valid cross build. When the binaries are for another architecture and cannot run --version, file(1) must report each as a FreeBSD ELF executable for the target architecture. Part of storytold/craft-common-actions#39. --- packaging/freebsd/package.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.sh index e232919c..a1ec8271 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -36,11 +36,15 @@ release_arch() { *) echo "unsupported architecture $1" >&2; return 2 ;; esac } -HOST_ARCH="$(release_arch "$(uname -m)")" # The release workflow cross-compiles aarch64 in an x86_64 VM with CARGO_BUILD_TARGET set to # aarch64-unknown-freebsd (craft-common-actions#39): name the archive after the target. -ARCH="$HOST_ARCH" -if [ -n "${CARGO_BUILD_TARGET:-}" ]; then ARCH="$(release_arch "${CARGO_BUILD_TARGET%%-*}")"; fi +case "${CARGO_BUILD_TARGET:-}" in + "") ARCH="$(release_arch "$(uname -m)")" ;; + *-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). +HOST_ARCH="$(release_arch "$(uname -m)" 2>/dev/null)" || HOST_ARCH="$(uname -m)" BASENAME="soundcraft-$VERSION-freebsd-$ARCH" echo "==> SoundCraft $VERSION for FreeBSD $ARCH" @@ -74,6 +78,14 @@ echo "wrote $DIST/$BASENAME.tar.gz" if [ "$ARCH" = "$HOST_ARCH" ]; then "$STAGE/bin/soundcraft-cli" --version else + # They cannot run here, so check what they are instead. + want="$ARCH"; [ "$ARCH" != x86_64 ] || want=x86-64 + for b in "$STAGE"/bin/*; do + case "$(file -b "$b")" in + ELF*"$want"*FreeBSD*) ;; + *) echo "error: $b is not a FreeBSD $ARCH executable: $(file -b "$b")" >&2; exit 1 ;; + esac + done echo "skipping --version: an $ARCH binary does not run on this $HOST_ARCH machine" fi echo "==> done" From 8063aa71731b88a24e78b076dc8b13db59fcca96 Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 14:49:35 -0500 Subject: [PATCH 3/5] FreeBSD package.sh: accept only executables in the cross-build check Review follow-up. The file(1) check for binaries that cannot run here now needs an executable (file says "executable" or "pie executable") or an ELF with an interpreter, which is how an older file(1) still shows a PIE it calls a shared object. FreeBSD libraries, object files and core files for the target architecture are refused. Part of storytold/craft-common-actions#39. --- packaging/freebsd/package.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.sh index a1ec8271..e50853b8 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -78,11 +78,12 @@ echo "wrote $DIST/$BASENAME.tar.gz" if [ "$ARCH" = "$HOST_ARCH" ]; then "$STAGE/bin/soundcraft-cli" --version else - # They cannot run here, so check what they are instead. + # They cannot run here, so check what they are instead: executables, not libraries or objects. + # An older file(1) calls a PIE a shared object; its interpreter still marks it as a program. want="$ARCH"; [ "$ARCH" != x86_64 ] || want=x86-64 for b in "$STAGE"/bin/*; do case "$(file -b "$b")" in - ELF*"$want"*FreeBSD*) ;; + ELF*" executable, "*"$want"*FreeBSD* | ELF*"$want"*FreeBSD*interpreter*) ;; *) echo "error: $b is not a FreeBSD $ARCH executable: $(file -b "$b")" >&2; exit 1 ;; esac done From 38d62661ce28c4b1fc7e4e95c95a9997aca412ef Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 15:31:37 -0500 Subject: [PATCH 4/5] 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 e50853b8..52a122ab 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -43,8 +43,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 BASENAME="soundcraft-$VERSION-freebsd-$ARCH" echo "==> SoundCraft $VERSION for FreeBSD $ARCH" From d9f2b070cbb0b39a0d6fddf7c43c2b14aeb5abdd Mon Sep 17 00:00:00 2001 From: zuujiscom Date: Thu, 22 Oct 2026 16:06:19 -0500 Subject: [PATCH 5/5] FreeBSD package.sh: accept only the two supported FreeBSD targets Review follow-up. CARGO_BUILD_TARGET must be aarch64-unknown-freebsd or x86_64-unknown-freebsd, the two the release builds; anything else, including made-up triples such as aarch64-foo-unknown-freebsd, stops with exit 2. Part of storytold/craft-common-actions#39. --- packaging/freebsd/package.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/freebsd/package.sh b/packaging/freebsd/package.sh index 52a122ab..285c17a5 100755 --- a/packaging/freebsd/package.sh +++ b/packaging/freebsd/package.sh @@ -40,8 +40,8 @@ release_arch() { # aarch64-unknown-freebsd (craft-common-actions#39): name the archive after the target. case "${CARGO_BUILD_TARGET:-}" in "") ARCH="$(release_arch "$(uname -m)")" ;; - *-unknown-freebsd) ARCH="$(release_arch "${CARGO_BUILD_TARGET%%-*}")" ;; - *) echo "CARGO_BUILD_TARGET=$CARGO_BUILD_TARGET is not a FreeBSD target" >&2; exit 2 ;; + aarch64-unknown-freebsd | x86_64-unknown-freebsd) ARCH="$(release_arch "${CARGO_BUILD_TARGET%%-*}")" ;; + *) echo "CARGO_BUILD_TARGET=$CARGO_BUILD_TARGET is not a supported FreeBSD target" >&2; exit 2 ;; esac # Only binaries for this machine run here (the --version check at the end); a FreeBSD target built # on another OS never does.