gralculator/scripts/gralculator-install.sh
Grok 27a4a0fc4d
Some checks failed
CI / Test (push) Successful in 37s
CI / Lint (push) Failing after 28s
CI / Build (push) Has been skipped
fix: update install scripts to use correct gralculator repo name in GITEA_BASE URLs
All references now consistently use 'gralculator' for the project:
- local folder: apps/gralculator
- binary: gralculator
- remote repo: gmgauthier/gralculator (renamed via tea)
- scripts and workflows updated
2026-06-06 15:35:04 +01:00

79 lines
2.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
VERSION=${VERSION:-${1:?Provide VERSION env or arg, e.g. VERSION=0.1.0 bash gralculator-install.sh}}
# Strip leading 'v' if present
VERSION=${VERSION#v}
GITEA_BASE=https://repos.gmgauthier.com/gmgauthier/gralculator
# Platform detection
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
linux) OS=linux ;;
darwin) OS=darwin ;;
esac
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH=amd64 ;;
arm64|aarch64) ARCH=arm64 ;;
esac
ASSET="gralculator-${OS}-${ARCH}-v${VERSION}.tar.gz"
echo "Installing gralculator ${VERSION} for ${OS}/${ARCH}..."
TEMP_DIR=$(mktemp -d)
trap 'rm -rf "${TEMP_DIR}"' EXIT
cd "${TEMP_DIR}"
# Download asset + checksums
echo "Downloading ${ASSET}..."
curl -fL "${GITEA_BASE}/releases/download/v${VERSION}/${ASSET}" -o asset.tar.gz
echo "Downloading checksums.txt..."
curl -fL "${GITEA_BASE}/releases/download/v${VERSION}/checksums.txt" -o checksums.txt
# Robust checksum verification
echo "Verifying checksum..."
CHECKSUM_CMD=""
if command -v sha256sum >/dev/null 2>&1; then
CHECKSUM_CMD="sha256sum"
elif command -v shasum >/dev/null 2>&1; then
CHECKSUM_CMD="shasum -a 256"
fi
if [ -n "$CHECKSUM_CMD" ] && [ -f checksums.txt ]; then
HASH=$(grep -oE '[0-9a-f]{64}\s+build/[^ ]*' checksums.txt | grep "${ASSET}" | cut -d' ' -f1 || true)
if [ -z "$HASH" ]; then
echo "⚠️ No checksum entry found for ${ASSET} continuing without verification"
else
echo "${HASH} asset.tar.gz" | $CHECKSUM_CMD --check - || {
echo "❌ Checksum mismatch for ${ASSET}!"
exit 1
}
echo "✅ Checksum verified successfully"
fi
else
echo "⚠️ Checksum tool not found (sha256sum/shasum) skipping verification"
fi
# Extract
echo "Extracting asset..."
tar xzf asset.tar.gz
BINARY="gralculator-${OS}-${ARCH}"
if [ "$OS" = "windows" ]; then BINARY="${BINARY}.exe"; fi
# Install
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
mv "${BINARY}" "${INSTALL_DIR}/gralculator" 2>/dev/null || mv "${BINARY}" "${INSTALL_DIR}/gralculator.exe" 2>/dev/null || true
chmod +x "${INSTALL_DIR}/gralculator" 2>/dev/null || true
echo "✅ gralculator ${VERSION} installed to ${INSTALL_DIR}/gralculator"
echo "Add to PATH if needed: export PATH=\"${INSTALL_DIR}:\$PATH\""
gralculator -v || true