mirror of
https://github.com/storytold/soundcraft.git
synced 2026-10-29 13:06:49 -06:00
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user