mint-linux: prebuilt x86_64 glibc binary + one-click installer
This commit is contained in:
+117
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# mint — one-click Linux (x86_64, glibc) installer
|
||||
#
|
||||
# Steps:
|
||||
# 1. Sanity-checks the host (arch, glibc, required GUI runtime libs).
|
||||
# 2. Downloads the prebuilt tarball + sha256 from the public Gitea release.
|
||||
# 3. Verifies the checksum, extracts, installs `mint` onto $PATH.
|
||||
# 4. Runs a headless smoke test.
|
||||
#
|
||||
# Quick start:
|
||||
# curl -fsSL https://gitea.mygoband.com/carrydela/mint-linux/raw/branch/main/install.sh | bash
|
||||
#
|
||||
# Overridable env:
|
||||
# MINT_GITEA gitea base url (default: https://gitea.mygoband.com)
|
||||
# MINT_REPO owner/repo (default: carrydela/mint-linux)
|
||||
# MINT_TAG release tag (default: latest)
|
||||
# MINT_INSTALL_DIR where to install (default: /usr/local/bin, else ~/.local/bin)
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
GITEA="${MINT_GITEA:-https://gitea.mygoband.com}"
|
||||
REPO="${MINT_REPO:-carrydela/mint-linux}"
|
||||
TAG="${MINT_TAG:-latest}"
|
||||
NAME="mint-linux-x86_64" # asset stem; real file is ${NAME}.tar.gz
|
||||
BIN="mint"
|
||||
LOGO=$'\033[1;36mmint\033[0m'
|
||||
|
||||
log() { printf '%s %b\n' "$LOGO" "$*"; }
|
||||
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
# --- 1. host checks ---------------------------------------------------------
|
||||
[ "$(uname -s)" = "Linux" ] || die "this installer is for Linux (host is $(uname -s))"
|
||||
ARCH="$(uname -m)"
|
||||
[ "$ARCH" = "x86_64" ] || die "only x86_64 is currently shipped (host is $ARCH)"
|
||||
|
||||
need() { command -v "$1" >/dev/null 2>&1 || die "missing required tool: $1 (install it first)"; }
|
||||
need curl; need tar; need sha256sum
|
||||
|
||||
if ! ldd --version >/dev/null 2>&1; then
|
||||
echo "warning: ldd/glibc not detected — this build is glibc-linked and will not run" >&2
|
||||
echo " on musl/Alpine. Use a musl-static build for those hosts." >&2
|
||||
fi
|
||||
|
||||
# GUI runtime libs (loaded at runtime by egui/winit). Warn if absent.
|
||||
missing=()
|
||||
for probe in libxcb.so.1 libxkbcommon.so.0 libGL.so.1 libwayland-client.so.0 libx11.so.6; do
|
||||
ldconfig -p 2>/dev/null | grep -q "$probe" || missing+=("$probe")
|
||||
done
|
||||
if [ "${#missing[@]}" -gt 0 ]; then
|
||||
echo "warning: these GUI runtime libs are missing (the GUI will not launch until they are installed):" >&2
|
||||
printf ' %s\n' "${missing[@]}" >&2
|
||||
echo " Debian/Ubuntu: apt install libxcb1 libxkbcommon0 libgl1 libwayland-client0 libx11-6" >&2
|
||||
echo " Fedora/RHEL: dnf install libxcb libxkbcommon mesa-libGL wayland-client libX11" >&2
|
||||
fi
|
||||
|
||||
# --- 2. resolve tag ---------------------------------------------------------
|
||||
if [ "$TAG" = "latest" ]; then
|
||||
TAG="$(curl -fsSL "${GITEA}/api/v1/repos/${REPO}/releases/latest" \
|
||||
| sed -nE 's/.*"tag_name"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p' | head -1)"
|
||||
[ -n "$TAG" ] || die "could not resolve the latest release tag from ${GITEA}/${REPO}"
|
||||
fi
|
||||
log "release tag: $TAG"
|
||||
|
||||
URL="${GITEA}/${REPO}/releases/download/${TAG}/${NAME}.tar.gz"
|
||||
SHA_URL="${URL}.sha256"
|
||||
|
||||
# --- 3. download + verify ---------------------------------------------------
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
log "downloading: ${URL}"
|
||||
curl -fL --progress-bar -o "$TMP/${NAME}.tar.gz" "$URL"
|
||||
|
||||
if curl -fsSL -o "$TMP/${NAME}.sha256" "$SHA_URL" 2>/dev/null; then
|
||||
log "verifying sha256..."
|
||||
expected="$(awk '{print $1; exit}' "$TMP/${NAME}.sha256")"
|
||||
actual="$(sha256sum "$TMP/${NAME}.tar.gz" | awk '{print $1}')"
|
||||
[ "$expected" = "$actual" ] || die "checksum mismatch (expected $expected, got $actual)"
|
||||
log "checksum ok"
|
||||
else
|
||||
echo "warning: no published ${NAME}.tar.gz.sha256; skipping checksum verification." >&2
|
||||
fi
|
||||
|
||||
log "extracting..."
|
||||
tar -xzf "$TMP/${NAME}.tar.gz" -C "$TMP"
|
||||
[ -f "$TMP/$BIN" ] || die "extracted archive does not contain '$BIN'"
|
||||
|
||||
# --- 4. install -------------------------------------------------------------
|
||||
if [ -n "${MINT_INSTALL_DIR:-}" ]; then
|
||||
DEST="$MINT_INSTALL_DIR"
|
||||
elif [ "$(id -u)" = 0 ] && [ -d /usr/local/bin ]; then
|
||||
DEST="/usr/local/bin"
|
||||
elif [ -d /usr/local/bin ] && [ -w /usr/local/bin ]; then
|
||||
DEST="/usr/local/bin"
|
||||
else
|
||||
DEST="$HOME/.local/bin"
|
||||
fi
|
||||
mkdir -p "$DEST"
|
||||
|
||||
TARGET="$DEST/$BIN"
|
||||
install -m 0755 "$TMP/$BIN" "$TARGET"
|
||||
log "installed: $TARGET"
|
||||
|
||||
case ":$PATH:" in
|
||||
*":$DEST:"*) : ;;
|
||||
*) echo "note: $DEST is not on your PATH — add it, or call the binary by full path." >&2 ;;
|
||||
esac
|
||||
|
||||
# --- 5. smoke test (headless) ----------------------------------------------
|
||||
if "$TARGET" --version >/dev/null 2>&1; then
|
||||
log "smoke test ok -> $($TARGET --version 2>/dev/null)"
|
||||
else
|
||||
echo "warning: '$TARGET --version' failed; the GUI runtime libs above may be required." >&2
|
||||
fi
|
||||
|
||||
log "done. launch it with: mint"
|
||||
Reference in New Issue
Block a user