#!/usr/bin/env sh # gfix installer — https://gitfix.pro/install # Downloads the right binary for your OS+arch, verifies SHA256, installs to # /usr/local/bin/gfix. Proprietary EULA: https://github.com/ameyypawar/gfix set -eu VERSION="${GFIX_VERSION:-latest}" PREFIX="${PREFIX:-/usr/local}" REPO="ameyypawar/gfix" usage() { cat <&2; exit 1 ;; esac # Detect arch arch="$(uname -m)" case "$arch" in x86_64|amd64) arch_tag="x86_64" ;; arm64|aarch64) arch_tag="aarch64" ;; *) echo "gfix: unsupported arch: $arch" >&2; exit 1 ;; esac target="${arch_tag}-${os_tag}" # Resolve version if [ "$VERSION" = "latest" ]; then VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ | grep '"tag_name":' | head -1 | cut -d'"' -f4)" [ -n "$VERSION" ] || { echo "gfix: could not resolve latest version" >&2; exit 1; } fi tarball="gfix-${VERSION}-${target}.tar.gz" url="https://github.com/${REPO}/releases/download/${VERSION}/${tarball}" sums_url="https://github.com/${REPO}/releases/download/${VERSION}/SHA256SUMS.txt" echo "gfix: installing ${VERSION} for ${target} → ${PREFIX}/bin/gfix" tmpdir="$(mktemp -d)" trap 'rm -rf "$tmpdir"' EXIT curl -fsSL "$url" -o "${tmpdir}/${tarball}" \ || { echo "gfix: download failed from ${url}" >&2; exit 1; } curl -fsSL "$sums_url" -o "${tmpdir}/SHA256SUMS.txt" \ || { echo "gfix: could not fetch SHA256SUMS.txt" >&2; exit 1; } # Verify SHA256 expected="$(grep " ${tarball}\$" "${tmpdir}/SHA256SUMS.txt" | cut -d' ' -f1)" [ -n "$expected" ] || { echo "gfix: ${tarball} not listed in SHA256SUMS.txt" >&2; exit 1; } if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "${tmpdir}/${tarball}" | cut -d' ' -f1)" elif command -v shasum >/dev/null 2>&1; then actual="$(shasum -a 256 "${tmpdir}/${tarball}" | cut -d' ' -f1)" else echo "gfix: need sha256sum or shasum; neither found" >&2; exit 1 fi [ "$expected" = "$actual" ] \ || { echo "gfix: SHA256 mismatch! expected=${expected} actual=${actual}" >&2; exit 1; } tar -xzf "${tmpdir}/${tarball}" -C "$tmpdir" # Install (try without sudo, then with) install_dir="${PREFIX}/bin" if [ -w "$install_dir" ]; then mv "${tmpdir}/gfix" "${install_dir}/gfix" elif command -v sudo >/dev/null 2>&1; then echo "gfix: ${install_dir} not writable; using sudo" sudo mv "${tmpdir}/gfix" "${install_dir}/gfix" else echo "gfix: ${install_dir} not writable and no sudo available" >&2; exit 1 fi chmod +x "${install_dir}/gfix" echo "" echo "gfix installed: ${install_dir}/gfix" echo "" # macOS unsigned-binary callout if [ "$os" = "Darwin" ]; then echo "macOS note: the alpha binary is unsigned. If Gatekeeper complains," echo " on first run, clear the quarantine attribute:" echo "" echo " xattr -d com.apple.quarantine ${install_dir}/gfix" echo "" fi echo "Verify: gfix --version" echo "Wire MCP: claude mcp add --scope user gfix ${install_dir}/gfix mcp" echo "Setup: https://github.com/ameyypawar/gitfix-docs"