From 526a330e02f16898dfbccc9655116e8abbb1a502 Mon Sep 17 00:00:00 2001 From: nocode Date: Fri, 18 Sep 2026 10:09:24 +0200 Subject: [PATCH] fix(build): fall back to local-repo when the AUR cannot be reached A run died cloning libxmlrpc, a package that was already built and sitting in local-repo, along with the seven others. Ten minutes of keyring refresh, system upgrade and 600 MB of build tools, thrown away on the first package, for a clone whose only purpose was to read a version number. That is why the clone happens at all: build_or_skip compares the PKGBUILD's version against local-repo to decide between building and skipping, and the PKGBUILD only exists once cloned. With no network there was no path left, even though the answer was already on disk. Three changes. Each clone now gets a second attempt after five seconds. A network that stumbles for a second should not cost a whole preparation phase. When both attempts fail, the package already built in local-repo is reused and the warning names the file that was picked. Offline there is no way to know whether a newer version exists upstream, so the one on hand is taken. The script only gives up when the package is genuinely absent, and it then says which host to check. A flag stops the bleeding after the first total failure: the remaining packages go straight to the fallback rather than waiting through two TCP timeouts each, which on eight packages is minutes of waiting for an answer already known. Two name-matching traps are covered by the new helpers. A version-agnostic lookup on "$pkg"-* would match "$pkg"-debug-* and install the debug package instead, so the glob requires a digit after the dash, which every pacman version starts with and no name suffix does. The same glob keeps a name from catching a longer one that has it as a prefix. Neither helper has a test yet. On the incident itself, only what the log shows: the mirrors gave up after 10 s and the AUR after 21 s, so the run met connection timeouts rather than refusals, and DNS had resolved. The container runs with --network=host, so podman's bridge was not in the path. Why the packets went nowhere was not measured. Transient, and now survivable. Signed-off-by: nocode --- setup-aur.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 5 deletions(-) diff --git a/setup-aur.sh b/setup-aur.sh index 25da01b..0cb653e 100755 --- a/setup-aur.sh +++ b/setup-aur.sh @@ -262,6 +262,44 @@ repo_has() { # façon → on ne supprime QUE les fichiers sans propriétaire (pacman -Qo vide), # puis on réessaie. Un fichier possédé par un AUTRE paquet reste un vrai conflit # (on ne le touche pas et le pacman -U finit par échouer proprement). +# Le paquet est-il dans local-repo, PEU IMPORTE la version ? Pendant du +# « repo_has », qui exige une version précise (celle du PKGBUILD, donc un clone +# réussi). Sert au repli hors ligne : mieux vaut construire l'ISO avec le paquet +# de la dernière fois que ne rien construire du tout. +# +# Le motif « -[0-9]* » n'est pas cosmétique : « $pkg-* » attraperait aussi +# « $pkg-debug-… », et on installerait le paquet de débogage à la place. Une +# version pacman commence toujours par un chiffre (ou « epoch: »), un suffixe +# de nom jamais. +repo_has_any() { + local f + for f in "$LOCAL_REPO/$1"-[0-9]*.pkg.tar.*; do [ -e "$f" ] && return 0; done + return 1 +} + +# Le plus RÉCEMMENT publié, s'il y en a plusieurs. Trier des versions en shell +# est un nid à bugs ; la date de copie dans local-repo dit la même chose ici, +# puisque publish_to_repo y copie au fil des builds. +repo_newest() { + ls -t "$LOCAL_REPO/$1"-[0-9]*.pkg.tar.* 2>/dev/null | head -1 +} + +# Clone l'AUR avec une SECONDE CHANCE. Un réseau qui bronche une seconde ne +# doit pas jeter dix minutes de préparation pacman : le run mourait sur le +# premier paquet, et sur le premier paquet SEULEMENT parce qu'il fallait lire +# son PKGBUILD — il était déjà construit dans local-repo. +clone_aur() { + local pkg="$1" try + for try in 1 2; do + [ "$try" = 2 ] && { warn "clonage $pkg : seconde tentative dans 5 s…"; sleep 5; } + rm -rf "$BUILD_DIR/$pkg" + su - "$BUILD_USER" \ + -c "git clone --depth=1 https://aur.archlinux.org/${pkg}.git $BUILD_DIR/$pkg" \ + && return 0 + done + return 1 +} + pacman_ur() { local i out rc conflicts=() f removed for i in 1 2 3 4 5 6 7 8; do @@ -366,12 +404,30 @@ build_or_skip() { step "3/4 — Build des paquets (saut si déjà à jour dans local-repo)" # ============================================================ # --- Paquets AUR (ordre : deps avant dépendants ; clone shallow puis build/saut) --- +# AUR_UP : passe à 0 dès qu'un clonage épuise ses deux tentatives. Les paquets +# suivants sautent alors directement au repli, au lieu d'attendre deux délais +# d'expiration TCP chacun — sur huit paquets, plusieurs minutes pour rien. +AUR_UP=1 for pkg in "${AUR_PACKAGES[@]}"; do - info "Clonage $pkg (AUR)…" - rm -rf "$BUILD_DIR/$pkg" - su - "$BUILD_USER" -c "git clone --depth=1 https://aur.archlinux.org/${pkg}.git $BUILD_DIR/$pkg" \ - || error "Clonage $pkg échoué" - build_or_skip "$pkg" + if [ "$AUR_UP" = 1 ]; then + info "Clonage $pkg (AUR)…" + if clone_aur "$pkg"; then + build_or_skip "$pkg" + continue + fi + AUR_UP=0 + warn "AUR injoignable — on se rabat sur local-repo pour la suite." + fi + + # Hors ligne : on ne peut pas lire le PKGBUILD, donc pas savoir si une + # version plus récente existe. On prend celle qu'on a. + if repo_has_any "$pkg"; then + _f="$(repo_newest "$pkg")" + warn "$pkg : clonage impossible → paquet déjà construit réutilisé ($(basename "$_f"))" + is_noinstall "$pkg" || pacman_ur "$_f" + else + error "Clonage $pkg échoué et aucun paquet dans local-repo. Vérifie l'accès à aur.archlinux.org (voir ci-dessus), puis relance." + fi done # --- PKGBUILD locaux FWS (ordre explicite, feuilles d'abord, anaconda dernier) ---