mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-29 04:56:58 -06:00
Honor CARGO_BUILD_TARGET in FreeBSD packaging for aarch64 release builds
package.sh took the arch from uname -m and read binaries from target/release, so a cross-built aarch64 target would be packaged as the host arch from the wrong directory. Pass --target, read target/<triple>/release, and name the archive from the target triple when CARGO_BUILD_TARGET is set. Skip the --version smoke run for cross builds, since the binary cannot run on the host.
This commit is contained in:
@@ -14,17 +14,29 @@ set -euo pipefail
|
||||
LINUX="$ROOT/packaging/linux"
|
||||
APP_ID=ai.storyteller.deckcraft
|
||||
|
||||
if [[ "${1:-}" != "--skip-build" ]]; then
|
||||
(cd "$ROOT" && cargo build --release --locked -p deckcraft -p deckcraft-cli)
|
||||
TARGET_ARGS=()
|
||||
BIN="$CARGO_TARGET_DIR/release"
|
||||
# Cross builds (CARGO_BUILD_TARGET from the release workflow) land under target/<triple>/release.
|
||||
if [[ -n "${CARGO_BUILD_TARGET:-}" ]]; then
|
||||
TARGET_ARGS=(--target "$CARGO_BUILD_TARGET")
|
||||
BIN="$CARGO_TARGET_DIR/$CARGO_BUILD_TARGET/release"
|
||||
fi
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
case "$ARCH" in
|
||||
amd64) ARCH=x86_64 ;;
|
||||
arm64) ARCH=aarch64 ;;
|
||||
*) ;;
|
||||
esac
|
||||
BIN="$CARGO_TARGET_DIR/release"
|
||||
if [[ "${1:-}" != "--skip-build" ]]; then
|
||||
(cd "$ROOT" && cargo build --release --locked "${TARGET_ARGS[@]}" -p deckcraft -p deckcraft-cli)
|
||||
fi
|
||||
|
||||
if [[ -n "${CARGO_BUILD_TARGET:-}" ]]; then
|
||||
# The target triple, not the build host's uname, names the arch of a cross build.
|
||||
if [[ "$CARGO_BUILD_TARGET" == aarch64-unknown-freebsd ]]; then ARCH=aarch64; else ARCH=x86_64; fi
|
||||
else
|
||||
ARCH="$(uname -m)"
|
||||
case "$ARCH" in
|
||||
amd64) ARCH=x86_64 ;;
|
||||
arm64) ARCH=aarch64 ;;
|
||||
*) ;;
|
||||
esac
|
||||
fi
|
||||
NAME="deckcraft-$VERSION-freebsd-$ARCH"
|
||||
WORK="$CARGO_TARGET_DIR/freebsd-package"
|
||||
STAGE="$WORK/$NAME"
|
||||
@@ -41,6 +53,6 @@ cp -R "$ROOT/assets/app-icon/hicolor" "$STAGE/share/icons/"
|
||||
copy_docs "$STAGE/share/doc/deckcraft"
|
||||
|
||||
tar -C "$WORK" -czf "$DIST/$NAME.tar.gz" "$NAME"
|
||||
"$STAGE/bin/deckcraft-cli" --version
|
||||
if [[ -z "${CARGO_BUILD_TARGET:-}" ]]; then "$STAGE/bin/deckcraft-cli" --version; fi # a cross-built binary cannot run on the build host
|
||||
echo "wrote $DIST/$NAME.tar.gz"
|
||||
ls -lh "$DIST/$NAME.tar.gz"
|
||||
|
||||
Reference in New Issue
Block a user