From 5b3ab9154f1ac44aed42d67de8a0f67150eebdfe Mon Sep 17 00:00:00 2001 From: MDietermann Date: Tue, 14 Apr 2026 21:18:30 +0200 Subject: [PATCH] feat: add bootstrap.sh curl-piped installer --- bootstrap.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..d15166a --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +set -euo pipefail + +REPO="MDietermann/Archduino" +BASE_URL="${ARCHDUINO_RELEASE_BASE:-https://gitlab.hive-brain.de}" +API_URL="${BASE_URL}/api/v1" + +err() { echo "bootstrap: error: $*" >&2; exit 1; } +msg() { echo "==> $*"; } + +# Arch gate +[ -f /etc/arch-release ] || err "Archduino v1 supports Arch Linux only." + +# Arch detect +case "$(uname -m)" in + x86_64) ARCH="amd64" ;; + aarch64) ARCH="arm64" ;; + *) err "unsupported architecture: $(uname -m)" ;; +esac + +# Prereqs +msg "Installing prerequisites (sudo, git, curl, ca-certificates)" +sudo pacman -Sy --needed --noconfirm sudo git curl ca-certificates + +# Discover latest release +msg "Querying latest release from Gitea" +API_ENDPOINT="${API_URL}/repos/${REPO}/releases/latest" +RELEASE_JSON=$(curl -fsSL "$API_ENDPOINT") || err "failed to fetch ${API_ENDPOINT}" + +# Extract tag_name without requiring jq +TAG=$(printf '%s' "$RELEASE_JSON" | grep -o '"tag_name":[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/') +[ -n "$TAG" ] || err "could not parse tag_name from release metadata" +VERSION="${TAG#v}" +msg "Latest release: ${TAG}" + +# Download +TMP=$(mktemp -d) +trap 'rm -rf "$TMP"' EXIT +TARBALL="archduino_${VERSION}_linux_${ARCH}.tar.gz" +CHECKSUMS="checksums.txt" +DL_BASE="${BASE_URL}/${REPO}/releases/download/${TAG}" + +msg "Downloading ${TARBALL}" +curl -fsSL -o "${TMP}/${TARBALL}" "${DL_BASE}/${TARBALL}" || err "tarball download failed" +curl -fsSL -o "${TMP}/${CHECKSUMS}" "${DL_BASE}/${CHECKSUMS}" || err "checksums download failed" + +# Verify +msg "Verifying checksum" +(cd "$TMP" && sha256sum --check --ignore-missing "$CHECKSUMS") || err "checksum verification failed" + +# Extract +msg "Extracting" +tar -xzf "${TMP}/${TARBALL}" -C "$TMP" + +# Install +msg "Installing to /usr/local/bin (sudo)" +sudo install -m 0755 "${TMP}/archduino" /usr/local/bin/archduino + +msg "Installing shell completions" +sudo install -Dm 0644 "${TMP}/completions/archduino.bash" /usr/share/bash-completion/completions/archduino +sudo install -Dm 0644 "${TMP}/completions/_archduino" /usr/share/zsh/site-functions/_archduino +sudo install -Dm 0644 "${TMP}/completions/archduino.fish" /usr/share/fish/vendor_completions.d/archduino.fish + +msg "Launching: archduino install $*" +exec /usr/local/bin/archduino install "$@"