diff --git a/misc/build.func b/misc/build.func index d150d909f..6426eddaa 100644 --- a/misc/build.func +++ b/misc/build.func @@ -4927,7 +4927,8 @@ create_lxc_container() { case "${_ans,,}" in y | yes) msg_info "Upgrading Proxmox LXC stack (pve-container, lxc-pve)" - if $STD apt-get update && $STD apt-get install -y --only-upgrade pve-container lxc-pve; then + apt_update_safe + if $STD apt-get install -y --only-upgrade pve-container lxc-pve; then msg_ok "LXC stack upgraded." if [[ "$do_retry" == "yes" ]]; then msg_info "Retrying container creation after upgrade" diff --git a/misc/core.func b/misc/core.func index 044810f35..2175a26bb 100644 --- a/misc/core.func +++ b/misc/core.func @@ -552,6 +552,53 @@ silent() { fi } +# ------------------------------------------------------------------------------ +# apt_update_safe() +# +# - Runs apt-get update with graceful error handling +# - On failure: shows warning with common causes instead of aborting +# - Logs full output to active log file +# - Returns 0 even on failure so the caller can continue +# - Typical cause: enterprise repos returning 401 Unauthorized +# +# Usage: +# apt_update_safe # Warn on failure, continue without aborting +# ------------------------------------------------------------------------------ +apt_update_safe() { + local logfile + logfile="$(get_active_logfile)" + + local _restore_errexit=false + [[ "$-" == *e* ]] && _restore_errexit=true + + set +Eeuo pipefail + trap - ERR + + apt-get update >>"$logfile" 2>&1 + local rc=$? + + if $_restore_errexit; then + set -Eeuo pipefail + trap 'error_handler' ERR + fi + + if [[ $rc -ne 0 ]]; then + msg_warn "apt-get update exited with code ${rc} — some repositories may have failed." + + # Check log for common 401/403 enterprise repo issues + if grep -qiE '401\s*Unauthorized|403\s*Forbidden|enterprise\.proxmox\.com' "$logfile" 2>/dev/null; then + echo -e "${TAB}${INFO} ${YWB}Hint: Proxmox enterprise repository returned an auth error.${CL}" + echo -e "${TAB} If you don't have a subscription, you can disable the enterprise" + echo -e "${TAB} repo and use the no-subscription repo instead." + fi + + echo -e "${TAB}${INFO} ${YWB}Continuing despite partial update failure — packages may still be installable.${CL}" + echo "" + fi + + return 0 +} + # ------------------------------------------------------------------------------ # spinner() # diff --git a/misc/install.func b/misc/install.func index 807a11426..069eba5ba 100644 --- a/misc/install.func +++ b/misc/install.func @@ -233,7 +233,7 @@ fi EOF chmod +x /usr/local/bin/apt-proxy-detect.sh fi - $STD apt-get update + apt_update_safe $STD apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED msg_ok "Updated Container OS"