Files
mcpctl/installlocal.sh
Michal Rydlikowski e4bff0ef89
Some checks are pending
CI/CD / lint (push) Successful in 50s
CI/CD / test (push) Successful in 1m4s
CI/CD / typecheck (push) Successful in 3m0s
CI/CD / build (amd64) (push) Successful in 2m22s
CI/CD / build (arm64) (push) Successful in 1m45s
CI/CD / publish-rpm (amd64) (push) Successful in 46s
CI/CD / publish-rpm (arm64) (push) Successful in 48s
CI/CD / publish-deb (amd64) (push) Successful in 58s
CI/CD / publish-deb (arm64) (push) Successful in 58s
CI/CD / smoke (push) Has started running
fix: correct arch naming and build order for ARM64 packages
- nfpm.yaml: use ${NFPM_ARCH} (Go's ExpandEnv doesn't support :-default)
- arch-helper.sh: export RPM_ARCH (x86_64/aarch64) alongside NFPM_ARCH
- build-rpm/deb.sh: build TypeScript before running tests (tests need
  built @mcpctl/shared), generate Prisma client on fresh checkout
- Fix RPM filename matching to use aarch64 not arm64

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-13 23:16:48 +00:00

73 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# 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"
# Resolve target architecture
source scripts/arch-helper.sh
resolve_arch "${MCPCTL_TARGET_ARCH:-}"
# 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 "Error: Neither rpm/dnf nor dpkg/apt found. Unsupported system."
exit 1
fi
echo "==> Detected package format: $PKG_FORMAT (arch: $NFPM_ARCH)"
# Find package matching the target architecture
# RPM uses x86_64/aarch64, DEB uses amd64/arm64
find_pkg() {
local pattern="$1"
ls $pattern 2>/dev/null | grep -E "[._](${NFPM_ARCH}|${RPM_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
echo "==> Done!"
echo " Enable mcplocal: systemctl --user enable --now mcplocal"