From 268eb07bb348d28daa2878ef8620261a098d3066 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:17:08 +0200 Subject: [PATCH] Make spinner robust and improve Gentoo bootstrap Reset shell command hash in spinner and make sleep resilient to shells without redirected sleep, preventing stale PATH lookups and failures in background subshells. Improve Gentoo bootstrap by syncing portage (emerge-webrsync or emerge --sync), preferring binary packages (--getbinpkg --usepkg) before falling back to source emerge, and add a fallback fetcher: prefer curl but use wget if curl is unavailable; fail with a clear error if neither is present. Replace direct curl sourcing with a configurable _fetch command to support the wget fallback. --- misc/core.func | 6 +++++- misc/install.func | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/misc/core.func b/misc/core.func index 5d46742d..af668c42 100644 --- a/misc/core.func +++ b/misc/core.func @@ -551,13 +551,17 @@ silent() { # - Uses color_spinner() colors for output # ------------------------------------------------------------------------------ spinner() { + # Reset bash's command hash table — package upgrades (dnf/pacman) may have + # moved /usr/bin <-> /usr/sbin during /usr-merge, leaving the parent shell + # with stale cached paths that get inherited by this background subshell. + hash -r 2>/dev/null || true local chars=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏) local msg="${SPINNER_MSG:-Processing...}" local i=0 while true; do local index=$((i++ % ${#chars[@]})) printf "\r\033[2K%s %b" "${CS_YWB}${chars[$index]}${CS_CL}" "${CS_YWB}${msg}${CS_CL}" - sleep 0.1 + sleep 0.1 2>/dev/null || command sleep 0.1 2>/dev/null || break done } diff --git a/misc/install.func b/misc/install.func index 954fa2fa..d087af57 100644 --- a/misc/install.func +++ b/misc/install.func @@ -175,16 +175,32 @@ _bootstrap() { elif command -v pacman &>/dev/null; then pacman -Sy --noconfirm curl &>/dev/null elif command -v emerge &>/dev/null; then - emerge --quiet net-misc/curl &>/dev/null + # Gentoo stage3 has no curl and no portage tree on first boot. + # Sync portage (webrsync = fast snapshot) then prefer binary package. + emerge-webrsync --quiet &>/dev/null || emerge --sync --quiet &>/dev/null + emerge --quiet --getbinpkg --usepkg net-misc/curl &>/dev/null \ + || emerge --quiet net-misc/curl &>/dev/null fi fi + # Last resort: if curl still missing but wget is available (Gentoo stage3), + # use wget for the bootstrap source fetch so we don't fail immediately. + local _fetch + if command -v curl &>/dev/null; then + _fetch="curl -fsSL" + elif command -v wget &>/dev/null; then + _fetch="wget -qO-" + else + echo "ERROR: neither curl nor wget available — cannot bootstrap" >&2 + exit 1 + fi + # Configurable base URL for development — override with COMMUNITY_SCRIPTS_URL COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}" # Source core functions - source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/core.func") - source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/error_handler.func") + source <($_fetch "$COMMUNITY_SCRIPTS_URL/misc/core.func") + source <($_fetch "$COMMUNITY_SCRIPTS_URL/misc/error_handler.func") load_functions catch_errors