From 168208cf3d3433bb976f5ac8357528c51131f3e8 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Fri, 16 Jan 2026 11:55:47 +0000 Subject: [PATCH] fix install script again --- install.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 2e3eb25..e346fa6 100755 --- a/install.sh +++ b/install.sh @@ -17,19 +17,41 @@ need_cmd() { command -v "$1" >/dev/null 2>&1; } install_neovim_linux() { # Install latest stable Neovim from GitHub releases (official tarball) - local tmp + local arch tmp url + arch="$(uname -m)" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' RETURN - local url="https://github.com/neovim/neovim/releases/download/v0.11.5/nvim-linux-x86_64.tar.gz" + case "$arch" in + x86_64|amd64) url="https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz" ;; + aarch64|arm64) url="https://github.com/neovim/neovim/releases/latest/download/nvim-linuxarm64.tar.gz" ;; + *) + echo "Unsupported architecture: $arch" >&2 + return 1 + ;; + esac + + # -f: fail on HTTP errors, -L: follow redirects, -S: show errors curl -fL --retry 3 --retry-delay 1 -o "$tmp/nvim.tar.gz" "$url" + # quick sanity check (avoids "not in gzip format") + if ! tar -tzf "$tmp/nvim.tar.gz" >/dev/null 2>&1; then + echo "Downloaded file is not a valid gzip tarball: $url" >&2 + echo "First bytes:" >&2 + head -c 200 "$tmp/nvim.tar.gz" | sed -e 's/[^[:print:]\t]/./g' >&2 + return 1 + fi + sudo rm -rf /opt/nvim sudo mkdir -p /opt sudo tar -C /opt -xzf "$tmp/nvim.tar.gz" - sudo mv /opt/nvim-linux64 /opt/nvim - # Ensure /usr/local/bin exists and symlink nvim + # tarball extracts to /opt/nvim-linux64 or /opt/nvim-linuxarm64 + local extracted + extracted="$(tar -tzf "$tmp/nvim.tar.gz" | head -n1 | cut -d/ -f1)" + sudo mv "/opt/$extracted" /opt/nvim + + sudo mkdir -p /usr/local/bin sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim }