Scope update-neovim.sh to debian: arch gets neovim from pacman; guard no-ops elsewhere
This commit is contained in:
parent
f692fbf01e
commit
a223473fc2
3 changed files with 121 additions and 2 deletions
|
|
@ -31,3 +31,8 @@ repos = [
|
||||||
"~/Documents/Git/*"
|
"~/Documents/Git/*"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[commands]
|
||||||
|
# Debian-only (script no-ops elsewhere): apt neovim is stale, so debian
|
||||||
|
# machines install from the pinned binary tarball. Arch uses pacman.
|
||||||
|
"~/.local/bin/update-neovim.sh" = "neovim"
|
||||||
|
|
||||||
|
|
|
||||||
68
dot_local/bin/update-neovim.sh
Normal file
68
dot_local/bin/update-neovim.sh
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# =============================================================================
|
||||||
|
# update-neovim.sh — chezmoi-managed, deployed to ~/.local/bin/update-neovim.sh
|
||||||
|
#
|
||||||
|
# Installs or upgrades neovim from the official binary tarball.
|
||||||
|
# Bump NVIM_TARGET_VERSION to upgrade. Topgrade calls this via
|
||||||
|
# ~/.config/topgrade/topgrade.toml.
|
||||||
|
#
|
||||||
|
# Debian-only: arch gets neovim from pacman (see PACMAN_PKGS in
|
||||||
|
# run_once_20-install-user-packages.sh.tmpl), so this is a no-op
|
||||||
|
# on non-debian machines.
|
||||||
|
#
|
||||||
|
# Idempotent: no-op if installed version matches target.
|
||||||
|
# =============================================================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
OS_ID="$(. /etc/os-release 2>/dev/null && echo "$ID" || true)"
|
||||||
|
if [[ "$OS_ID" != "debian" ]]; then
|
||||||
|
echo "neovim: not debian ($OS_ID) — no action"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
NVIM_TARGET_VERSION="v0.11.4"
|
||||||
|
|
||||||
|
ARCH="$(uname -m)"
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64)
|
||||||
|
NVIM_TARBALL="nvim-linux64.tar.gz"
|
||||||
|
NVIM_EXTRACT_DIR="nvim-linux64"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
NVIM_TARBALL="nvim-linux-arm64.tar.gz"
|
||||||
|
NVIM_EXTRACT_DIR="nvim-linux-arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unsupported arch: $ARCH" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if command -v nvim >/dev/null 2>&1; then
|
||||||
|
INSTALLED_VER="$(nvim --version 2>/dev/null | head -1 | awk '{print $2}')"
|
||||||
|
if [[ "$INSTALLED_VER" == "$NVIM_TARGET_VERSION" ]]; then
|
||||||
|
echo "neovim $INSTALLED_VER matches target — no action"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "neovim $INSTALLED_VER -> $NVIM_TARGET_VERSION"
|
||||||
|
else
|
||||||
|
echo "installing neovim $NVIM_TARGET_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
TMP_TARBALL="$(mktemp /tmp/nvim-update.XXXXXX.tar.gz)"
|
||||||
|
trap 'rm -f "$TMP_TARBALL"' EXIT
|
||||||
|
|
||||||
|
if ! curl -fL --retry 3 \
|
||||||
|
"https://github.com/neovim/neovim/releases/download/${NVIM_TARGET_VERSION}/${NVIM_TARBALL}" \
|
||||||
|
-o "$TMP_TARBALL"; then
|
||||||
|
echo "failed to download $NVIM_TARBALL" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo rm -rf /opt/nvim-linux* /usr/local/bin/nvim
|
||||||
|
sudo tar -xzf "$TMP_TARBALL" -C /opt/
|
||||||
|
sudo ln -sf "/opt/${NVIM_EXTRACT_DIR}/bin/nvim" /usr/local/bin/nvim
|
||||||
|
|
||||||
|
echo "neovim $NVIM_TARGET_VERSION installed"
|
||||||
|
nvim --version | head -1
|
||||||
|
|
@ -200,8 +200,54 @@ if command -v bun >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Neovim comes from the system package (pacman list above); topgrade keeps
|
# Neovim — debian apt ships a stale version, so install the official
|
||||||
# it current. No manual tarball install.
|
# binary tarball, pinned to a known-good version. Bump
|
||||||
|
# NVIM_TARGET_VERSION here and in ~/.local/bin/update-neovim.sh to
|
||||||
|
# upgrade (topgrade runs the script on debian machines).
|
||||||
|
NVIM_TARGET_VERSION="v0.11.4"
|
||||||
|
ARCH="$(uname -m)"
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64)
|
||||||
|
NVIM_TARBALL="nvim-linux64.tar.gz"
|
||||||
|
NVIM_EXTRACT_DIR="nvim-linux64"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
NVIM_TARBALL="nvim-linux-arm64.tar.gz"
|
||||||
|
NVIM_EXTRACT_DIR="nvim-linux-arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "unsupported arch for neovim tarball: $ARCH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if command -v nvim >/dev/null 2>&1; then
|
||||||
|
INSTALLED_VER="$(nvim --version 2>/dev/null | head -1 | awk '{print $2}')"
|
||||||
|
if [[ "$INSTALLED_VER" == "$NVIM_TARGET_VERSION" ]]; then
|
||||||
|
log "neovim $INSTALLED_VER matches target — skipping"
|
||||||
|
NVIM_TARBALL=""
|
||||||
|
else
|
||||||
|
log "neovim $INSTALLED_VER != target $NVIM_TARGET_VERSION — upgrading"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$NVIM_TARBALL" ]]; then
|
||||||
|
log "downloading neovim $NVIM_TARGET_VERSION ($NVIM_TARBALL)"
|
||||||
|
cd /tmp
|
||||||
|
if ! curl -fL --retry 3 \
|
||||||
|
"https://github.com/neovim/neovim/releases/download/${NVIM_TARGET_VERSION}/${NVIM_TARBALL}" \
|
||||||
|
-o nvim.tar.gz; then
|
||||||
|
die "failed to download neovim tarball"
|
||||||
|
fi
|
||||||
|
sudo rm -rf /opt/nvim-linux* /usr/local/bin/nvim
|
||||||
|
sudo tar -xzf nvim.tar.gz -C /opt/
|
||||||
|
sudo ln -sf "/opt/${NVIM_EXTRACT_DIR}/bin/nvim" /usr/local/bin/nvim
|
||||||
|
rm -f nvim.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify neovim is reachable (PATH may need /usr/local/bin explicitly for this run)
|
||||||
|
if ! command -v nvim >/dev/null 2>&1 && [[ -x /usr/local/bin/nvim ]]; then
|
||||||
|
export PATH="/usr/local/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
{{ else -}}
|
{{ else -}}
|
||||||
die "unsupported os_family: {{ .os_family }}"
|
die "unsupported os_family: {{ .os_family }}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue