Compare commits

..

1 Commits

Author SHA1 Message Date
MickLesk
947d032f96 fix(tools): replace raw GitHub API curl calls with get_latest_github_release 2026-05-23 23:12:31 +02:00
2 changed files with 20 additions and 94 deletions

View File

@@ -4269,12 +4269,10 @@ function setup_gs() {
ensure_dependencies jq ensure_dependencies jq
local RELEASE_JSON local LATEST_VERSION
RELEASE_JSON=$(curl -fsSL --max-time 15 https://api.github.com/repos/ArtifexSoftware/ghostpdl-downloads/releases/latest 2>/dev/null || echo "") # Tags are "gs10.05.1" format — fetch without stripping "v", then strip "gs"
LATEST_VERSION=$(get_latest_github_release "ArtifexSoftware/ghostpdl-downloads" "false") || {
if [[ -z "$RELEASE_JSON" ]]; then
msg_warn "Cannot fetch latest Ghostscript version from GitHub API" msg_warn "Cannot fetch latest Ghostscript version from GitHub API"
# Try to get from current version
if command -v gs &>/dev/null; then if command -v gs &>/dev/null; then
gs --version | head -n1 gs --version | head -n1
cache_installed_version "ghostscript" "$CURRENT_VERSION" cache_installed_version "ghostscript" "$CURRENT_VERSION"
@@ -4282,11 +4280,9 @@ function setup_gs() {
fi fi
msg_error "Cannot determine Ghostscript version and no existing installation found" msg_error "Cannot determine Ghostscript version and no existing installation found"
return 250 return 250
fi }
local LATEST_VERSION LATEST_VERSION="${LATEST_VERSION#gs}"
LATEST_VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name' | sed 's/^gs//') local LATEST_VERSION_DOTTED="$LATEST_VERSION"
local LATEST_VERSION_DOTTED
LATEST_VERSION_DOTTED=$(echo "$RELEASE_JSON" | jq -r '.name' | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
if [[ -z "$LATEST_VERSION" || -z "$LATEST_VERSION_DOTTED" ]]; then if [[ -z "$LATEST_VERSION" || -z "$LATEST_VERSION_DOTTED" ]]; then
msg_warn "Could not determine latest Ghostscript version from GitHub - checking system" msg_warn "Could not determine latest Ghostscript version from GitHub - checking system"
@@ -7336,22 +7332,11 @@ function setup_ruby() {
# Download and build rbenv if needed # Download and build rbenv if needed
if [[ ! -x "$RBENV_BIN" ]]; then if [[ ! -x "$RBENV_BIN" ]]; then
local RBENV_RELEASE local RBENV_RELEASE
local rbenv_json RBENV_RELEASE=$(get_latest_github_release "rbenv/rbenv") || {
rbenv_json=$(curl -fsSL --max-time 15 https://api.github.com/repos/rbenv/rbenv/releases/latest 2>/dev/null || echo "")
if [[ -z "$rbenv_json" ]]; then
msg_error "Failed to fetch latest rbenv version from GitHub" msg_error "Failed to fetch latest rbenv version from GitHub"
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
return 7 return 7
fi }
RBENV_RELEASE=$(echo "$rbenv_json" | jq -r '.tag_name' 2>/dev/null | sed 's/^v//' || echo "")
if [[ -z "$RBENV_RELEASE" ]]; then
msg_error "Could not parse rbenv version from GitHub response"
rm -rf "$TMP_DIR"
return 250
fi
if ! curl_with_retry "https://github.com/rbenv/rbenv/archive/refs/tags/v${RBENV_RELEASE}.tar.gz" "$TMP_DIR/rbenv.tar.gz"; then if ! curl_with_retry "https://github.com/rbenv/rbenv/archive/refs/tags/v${RBENV_RELEASE}.tar.gz" "$TMP_DIR/rbenv.tar.gz"; then
msg_error "Failed to download rbenv" msg_error "Failed to download rbenv"
@@ -7383,22 +7368,11 @@ function setup_ruby() {
# Install ruby-build plugin # Install ruby-build plugin
if [[ ! -d "$RBENV_DIR/plugins/ruby-build" ]]; then if [[ ! -d "$RBENV_DIR/plugins/ruby-build" ]]; then
local RUBY_BUILD_RELEASE local RUBY_BUILD_RELEASE
local ruby_build_json RUBY_BUILD_RELEASE=$(get_latest_github_release "rbenv/ruby-build") || {
ruby_build_json=$(curl -fsSL --max-time 15 https://api.github.com/repos/rbenv/ruby-build/releases/latest 2>/dev/null || echo "")
if [[ -z "$ruby_build_json" ]]; then
msg_error "Failed to fetch latest ruby-build version from GitHub" msg_error "Failed to fetch latest ruby-build version from GitHub"
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
return 7 return 7
fi }
RUBY_BUILD_RELEASE=$(echo "$ruby_build_json" | jq -r '.tag_name' 2>/dev/null | sed 's/^v//' || echo "")
if [[ -z "$RUBY_BUILD_RELEASE" ]]; then
msg_error "Could not parse ruby-build version from GitHub response"
rm -rf "$TMP_DIR"
return 250
fi
if ! curl_with_retry "https://github.com/rbenv/ruby-build/archive/refs/tags/v${RUBY_BUILD_RELEASE}.tar.gz" "$TMP_DIR/ruby-build.tar.gz"; then if ! curl_with_retry "https://github.com/rbenv/ruby-build/archive/refs/tags/v${RUBY_BUILD_RELEASE}.tar.gz" "$TMP_DIR/ruby-build.tar.gz"; then
msg_error "Failed to download ruby-build" msg_error "Failed to download ruby-build"
@@ -7781,8 +7755,7 @@ function setup_clickhouse() {
# Fallback to GitHub API if package server failed # Fallback to GitHub API if package server failed
if [[ -z "$CLICKHOUSE_VERSION" ]]; then if [[ -z "$CLICKHOUSE_VERSION" ]]; then
CLICKHOUSE_VERSION=$(curl -fsSL --max-time 15 https://api.github.com/repos/ClickHouse/ClickHouse/releases/latest 2>/dev/null | CLICKHOUSE_VERSION=$(get_latest_github_release "ClickHouse/ClickHouse") || true
grep -oP '"tag_name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n1 || echo "")
fi fi
[[ -z "$CLICKHOUSE_VERSION" ]] && { [[ -z "$CLICKHOUSE_VERSION" ]] && {
@@ -8071,22 +8044,11 @@ function setup_uv() {
ensure_dependencies jq ensure_dependencies jq
# Fetch latest version # Fetch latest version
local releases_json local LATEST_VERSION
releases_json=$(curl -fsSL --max-time 15 \ LATEST_VERSION=$(get_latest_github_release "astral-sh/uv") || {
"https://api.github.com/repos/astral-sh/uv/releases/latest" 2>/dev/null || echo "")
if [[ -z "$releases_json" ]]; then
msg_error "Could not fetch latest uv version from GitHub API" msg_error "Could not fetch latest uv version from GitHub API"
return 7 return 7
fi }
local LATEST_VERSION
LATEST_VERSION=$(echo "$releases_json" | jq -r '.tag_name' 2>/dev/null | sed 's/^v//')
if [[ -z "$LATEST_VERSION" ]]; then
msg_error "Could not parse uv version from GitHub API response"
return 250
fi
# Get currently installed version # Get currently installed version
local INSTALLED_VERSION="" local INSTALLED_VERSION=""
@@ -8213,22 +8175,11 @@ function setup_yq() {
fi fi
local LATEST_VERSION local LATEST_VERSION
local releases_json LATEST_VERSION=$(get_latest_github_release "${GITHUB_REPO}") || {
releases_json=$(curl -fsSL --max-time 15 "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" 2>/dev/null || echo "")
if [[ -z "$releases_json" ]]; then
msg_error "Could not fetch latest yq version from GitHub API" msg_error "Could not fetch latest yq version from GitHub API"
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
return 250 return 250
fi }
LATEST_VERSION=$(echo "$releases_json" | jq -r '.tag_name' 2>/dev/null | sed 's/^v//' || echo "")
if [[ -z "$LATEST_VERSION" ]]; then
msg_error "Could not parse yq version from GitHub API response"
rm -rf "$TMP_DIR"
return 250
fi
# Get currently installed version # Get currently installed version
local INSTALLED_VERSION="" local INSTALLED_VERSION=""

View File

@@ -28,14 +28,7 @@ declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "kernel-clean"
# Detect current kernel # Detect current kernel
current_kernel=$(uname -r) current_kernel=$(uname -r)
# Only list fully-installed (ii) versioned kernel packages; the pattern available_kernels=$(dpkg --list | grep 'kernel-.*-pve' | awk '{print $2}' | grep -v "$current_kernel" | sort -V)
# proxmox-kernel-X.Y.Z matches versioned kernels while excluding the
# two-segment meta-packages (proxmox-kernel-X.Y) and proxmox-kernel-helper.
available_kernels=$(dpkg --list |
awk '/^ii/ {print $2}' |
grep -E '^proxmox-kernel-[0-9]+\.[0-9]+\.[0-9]' |
grep -v "$current_kernel" |
sort -V)
header_info header_info
@@ -89,28 +82,10 @@ fi
# Remove kernels # Remove kernels
for kernel in "${kernels_to_remove[@]}"; do for kernel in "${kernels_to_remove[@]}"; do
echo -e "${YW}Removing $kernel...${CL}" echo -e "${YW}Removing $kernel...${CL}"
# Derive the major.minor meta-package name (e.g. proxmox-kernel-6.14) if apt-get purge -y "$kernel" >/dev/null 2>&1; then
# from a versioned name like proxmox-kernel-6.14.11-9-pve-signed. echo -e "${GN}Successfully removed: $kernel${CL}"
minor_version=$(echo "$kernel" | sed -E 's/^proxmox-kernel-([0-9]+\.[0-9]+)\..*/\1/')
meta="proxmox-kernel-${minor_version}"
pkgs_to_remove=("$kernel")
# Include the meta-package in the purge when it is installed and when
# no other versioned kernel of the same minor version will remain
# (the running kernel keeps it alive if it shares the same minor).
if dpkg -l "$meta" 2>/dev/null | grep -q '^ii'; then
remaining=$(dpkg --list |
awk '/^ii/ {print $2}' |
grep -E "^proxmox-kernel-${minor_version}\." |
grep -v "^${kernel}$" |
wc -l)
if [ "$remaining" -eq 0 ]; then
pkgs_to_remove+=("$meta")
fi
fi
if apt-get purge -y "${pkgs_to_remove[@]}" >/dev/null 2>&1; then
echo -e "${GN}Successfully removed: ${pkgs_to_remove[*]}${CL}"
else else
echo -e "${RD}Failed to remove: ${pkgs_to_remove[*]}. Check dependencies.${CL}" echo -e "${RD}Failed to remove: $kernel. Check dependencies.${CL}"
fi fi
done done