feat: add ARM64 (aarch64) architecture support for builds and packages
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>
This commit is contained in:
Michal Rydlikowski
2026-03-13 23:01:51 +00:00
parent 588b2a9e65
commit 8ad7fe2748
11 changed files with 326 additions and 64 deletions

View File

@@ -1,23 +1,69 @@
#!/bin/bash
# Build (if needed) and install mcpctl RPM locally
# Build (if needed) and install mcpctl locally.
# Auto-detects package format: RPM for Fedora/RHEL, DEB for Debian/Ubuntu.
#
# Usage:
# ./installlocal.sh # Build and install for native arch
# MCPCTL_TARGET_ARCH=amd64 ./installlocal.sh # Cross-compile for amd64
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1)
# Resolve target architecture
source scripts/arch-helper.sh
resolve_arch "${MCPCTL_TARGET_ARCH:-}"
# Build if no RPM exists or if source is newer than the RPM
if [[ -z "$RPM_FILE" ]] || [[ $(find src/ -name '*.ts' -newer "$RPM_FILE" 2>/dev/null | head -1) ]]; then
echo "==> Building RPM..."
bash scripts/build-rpm.sh
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1)
# Detect package format
if command -v rpm &>/dev/null && command -v dnf &>/dev/null; then
PKG_FORMAT="rpm"
elif command -v dpkg &>/dev/null && command -v apt &>/dev/null; then
PKG_FORMAT="deb"
elif command -v rpm &>/dev/null; then
PKG_FORMAT="rpm"
else
echo "==> RPM is up to date: $RPM_FILE"
echo "Error: Neither rpm/dnf nor dpkg/apt found. Unsupported system."
exit 1
fi
echo "==> Installing $RPM_FILE..."
sudo rpm -Uvh --force "$RPM_FILE"
echo "==> Detected package format: $PKG_FORMAT (arch: $NFPM_ARCH)"
# Find package matching the target architecture
find_pkg() {
local pattern="$1"
# Filter by architecture name in filename
ls $pattern 2>/dev/null | grep -E "[._]${NFPM_ARCH}[._]" | head -1
}
if [ "$PKG_FORMAT" = "rpm" ]; then
PKG_FILE=$(find_pkg "dist/mcpctl-*.rpm")
# Build if no package exists or if source is newer
if [[ -z "$PKG_FILE" ]] || [[ $(find src/ -name '*.ts' -newer "$PKG_FILE" 2>/dev/null | head -1) ]]; then
echo "==> Building RPM..."
bash scripts/build-rpm.sh
PKG_FILE=$(find_pkg "dist/mcpctl-*.rpm")
else
echo "==> RPM is up to date: $PKG_FILE"
fi
echo "==> Installing $PKG_FILE..."
sudo rpm -Uvh --force "$PKG_FILE"
else
PKG_FILE=$(find_pkg "dist/mcpctl*.deb")
# Build if no package exists or if source is newer
if [[ -z "$PKG_FILE" ]] || [[ $(find src/ -name '*.ts' -newer "$PKG_FILE" 2>/dev/null | head -1) ]]; then
echo "==> Building DEB..."
bash scripts/build-deb.sh
PKG_FILE=$(find_pkg "dist/mcpctl*.deb")
else
echo "==> DEB is up to date: $PKG_FILE"
fi
echo "==> Installing $PKG_FILE..."
sudo dpkg -i "$PKG_FILE" || sudo apt-get install -f -y
fi
echo "==> Reloading systemd user units..."
systemctl --user daemon-reload