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/<triple>/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.
This commit is contained in:
zuujiscom
2026-10-22 14:14:07 -05:00
parent 06db0bd373
commit 79adead5bf
+19 -7
View File
@@ -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/<triple>/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"