Some checks failed
CI/CD / lint (push) Successful in 46s
CI/CD / test (push) Successful in 1m3s
CI/CD / typecheck (push) Has started running
CI/CD / smoke (push) Has been cancelled
CI/CD / build (amd64) (push) Has been cancelled
CI/CD / build (arm64) (push) Has been cancelled
CI/CD / publish-rpm (amd64) (push) Has been cancelled
CI/CD / publish-rpm (arm64) (push) Has been cancelled
CI/CD / publish-deb (amd64) (push) Has been cancelled
CI/CD / publish-deb (arm64) (push) Has been cancelled
Add cross-architecture build support so the project can be developed on ARM64 (Fedora aarch64 laptop) while still producing amd64 packages for production. All build, package, publish, and install scripts are now architecture-aware via shared arch-helper.sh detection. - Add scripts/arch-helper.sh for shared architecture detection - CI builds both amd64 and arm64 in matrix strategy - nfpm.yaml uses NFPM_ARCH env var instead of hardcoded amd64 - Build scripts support MCPCTL_TARGET_ARCH for cross-compilation - installlocal.sh auto-detects RPM/DEB and filters by architecture - release.sh gains --both-arches flag for dual-arch releases - Package cleanup is arch-scoped (won't clobber other arch's packages) - build-mcpd.sh supports --platform and --multi-arch flags - Add pnpm scripts: rpm:build:amd64, deb:build:arm64, release:both - Conditional rpm/dpkg-deb checks for cross-distro compatibility Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63 lines
1.5 KiB
Bash
63 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# Shared architecture detection for build scripts.
|
|
# Source this file, then call: resolve_arch [target_arch]
|
|
#
|
|
# Outputs (exported):
|
|
# NFPM_ARCH — nfpm/deb/rpm arch name: "amd64" or "arm64"
|
|
# BUN_TARGET — bun cross-compile target (empty if native build)
|
|
# ARCH_SUFFIX — filename suffix for cross-compiled binaries (empty if native)
|
|
|
|
_detect_native_arch() {
|
|
case "$(uname -m)" in
|
|
x86_64) echo "amd64" ;;
|
|
aarch64) echo "arm64" ;;
|
|
arm64) echo "arm64" ;; # macOS reports arm64
|
|
*) echo "amd64" ;; # fallback
|
|
esac
|
|
}
|
|
|
|
_bun_target_for() {
|
|
local arch="$1"
|
|
case "$arch" in
|
|
amd64) echo "bun-linux-x64" ;;
|
|
arm64) echo "bun-linux-arm64" ;;
|
|
esac
|
|
}
|
|
|
|
_nfpm_download_arch() {
|
|
local arch="$1"
|
|
case "$arch" in
|
|
amd64) echo "x86_64" ;;
|
|
arm64) echo "arm64" ;;
|
|
esac
|
|
}
|
|
|
|
# resolve_arch [override]
|
|
# override: "amd64" or "arm64" (optional, auto-detects if empty)
|
|
resolve_arch() {
|
|
local requested="${1:-}"
|
|
local native
|
|
native="$(_detect_native_arch)"
|
|
|
|
if [ -z "$requested" ]; then
|
|
# Native build
|
|
NFPM_ARCH="$native"
|
|
BUN_TARGET=""
|
|
ARCH_SUFFIX=""
|
|
else
|
|
NFPM_ARCH="$requested"
|
|
if [ "$requested" = "$native" ]; then
|
|
# Requesting our own arch — native build
|
|
BUN_TARGET=""
|
|
ARCH_SUFFIX=""
|
|
else
|
|
# Cross-compilation
|
|
BUN_TARGET="$(_bun_target_for "$requested")"
|
|
ARCH_SUFFIX="-${requested}"
|
|
fi
|
|
fi
|
|
|
|
export NFPM_ARCH BUN_TARGET ARCH_SUFFIX
|
|
echo " Architecture: ${NFPM_ARCH} (native: ${native}${BUN_TARGET:+, cross-compiling via $BUN_TARGET})"
|
|
}
|