From 798b86faca84eaeba4f3f5ba1658b453603527de Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 14:47:01 -0500 Subject: fix(archsetup): give git_install the same retry logic as pacman/aur pacman_install and aur_install retry up to MAX_INSTALL_RETRIES. git_install only retried the clone once and never the build. I folded it into the same retry loop: it cleans the build dir between attempts and runs clone && make-install as one command list, so the captured exit code is the real failure rather than the if-statement's status (the trap retry_install documents). One behavior change: a build that fails every attempt now warns and continues instead of being fatal on the re-clone path. That matches how pacman and aur failures are handled, so one source build that won't compile no longer aborts the whole install. It surfaces in the error summary instead. --- archsetup | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/archsetup b/archsetup index 5bbf177..8bff777 100755 --- a/archsetup +++ b/archsetup @@ -586,19 +586,38 @@ git_install() { local prog_name prog_name="$(basename "$1" .git)" local build_dir="$source_dir/$prog_name" + local attempt=1 + local last_exit_code=0 display "task" "building & installing $prog_name from source" - if ! (sudo -u "$username" git clone --depth 1 "$1" "$build_dir" >> "$logfile" 2>&1); then - error_warn "cloning $prog_name - directory may exist, removing and retrying" "$?" - safe_rm_rf "$build_dir" "$source_dir" >> "$logfile" 2>&1 || \ - error_warn "removing existing directory for $prog_name" "$?" - sudo -u "$username" git clone --depth 1 "$1" "$build_dir" >> "$logfile" 2>&1 || \ - error_fatal "re-cloning $prog_name after cleanup" "$?" - fi + while [ $attempt -le $MAX_INSTALL_RETRIES ]; do + # Start each attempt from a clean slate. A leftover dir from a prior + # attempt (or a failed earlier install) makes git clone refuse to write. + if [ -e "$build_dir" ]; then + safe_rm_rf "$build_dir" "$source_dir" >> "$logfile" 2>&1 || \ + error_warn "removing existing directory for $prog_name" "$?" + fi + + # clone && build as one command list, not an `if`-compound — capturing + # $? after `if ...; then ...; fi` reads the if's status (0 when the + # condition is false), masking the real failure. Same trap retry_install + # documents. The list's exit code is the clone's code on a clone failure, + # make's code on a build failure, 0 only when both succeed. + sudo -u "$username" git clone --depth 1 "$1" "$build_dir" >> "$logfile" 2>&1 \ + && (cd "$build_dir" && make install >> "$logfile" 2>&1) + last_exit_code=$? + if [ $last_exit_code -eq 0 ]; then + return 0 + fi + + attempt=$((attempt + 1)) + if [ $attempt -le $MAX_INSTALL_RETRIES ]; then + display "task" "retrying $prog_name (attempt $attempt/$MAX_INSTALL_RETRIES)" + fi + done - (cd "$build_dir" && make install >> "$logfile" 2>&1) || \ - error_warn "building $prog_name from source" "$?" + error_warn "building $prog_name from source" "$last_exit_code" } # PIP Install (using pipx for isolated environments) -- cgit v1.2.3