fix(setup-aur.sh)!: use explicit package list instead of glob for install and publish

Change publish_to_repo() to accept explicit file list via variadic arguments
instead of a directory glob. This prevents re-publishing stale .pkg files
from previous builds that may still exist in BUILD_DIR.

Update build_or_skip() to get the actual list of packages produced by the
current makepkg invocation using --packagelist, filter for .pkg.tar.* files,
verify they exist on disk, and pass only those to pacman -U and publish_to_repo().

This fixes issues where:
- After pkgrel bumps, old .pkg files would cause pacman to receive duplicate
  package names ("repeated target" error)
- Stale packages would be republished over the purge in local-repo
- Optional debug packages would cause errors when not produced

BREAKING CHANGE: publish_to_repo() function signature changed from publish_to_repo(name, directory) to publish_to_repo(name, file1, file2, ...) - callers must pass explicit file paths instead of a directory path
This commit is contained in:
2026-07-03 23:59:32 +02:00
parent 4249282052
commit 7fe54d0791
+22 -4
View File
@@ -232,11 +232,14 @@ repo_has() {
# Publie les .pkg d'un build vers local-repo en purgeant d'abord les anciennes
# versions de CE paquet (+ son sous-paquet -debug). Le « -[0-9] » empêche
# « anaconda » d'attraper « anaconda-widgets » / « anaconda-debug ».
# Prend la LISTE EXPLICITE des fichiers à publier (pas un glob sur le dossier :
# un .pkg d'un build précédent peut traîner dans $BUILD_DIR/<name> et serait
# republié par-dessus la purge).
publish_to_repo() {
local name="$1" d="$2"
local name="$1"; shift
rm -f "$LOCAL_REPO/$name"-[0-9]*.pkg.tar.* \
"$LOCAL_REPO/$name"-debug-[0-9]*.pkg.tar.* 2>/dev/null || true
cp -f "$d"/*.pkg.tar.* "$LOCAL_REPO/" || error "Copie de $name vers local-repo échouée"
cp -f "$@" "$LOCAL_REPO/" || error "Copie de $name vers local-repo échouée"
}
# Construit OU saute <name> (source déjà déposée dans $BUILD_DIR/<name>).
@@ -259,8 +262,23 @@ build_or_skip() {
chown -R "$BUILD_USER:$BUILD_USER" "$d"
su - "$BUILD_USER" -c "cd '$d' && makepkg -sf --noconfirm" \
|| error "Build $name échoué"
pacman -U --noconfirm "$d/"*.pkg.tar.* || error "Install de $name échouée"
publish_to_repo "$name" "$d"
# N'installer/publier QUE les paquets produits par CE PKGBUILD dans SA
# version courante (makepkg --packagelist), jamais un glob "$d/"* : après
# un bump de pkgrel, l'ancien .pkg traîne encore dans $d (BUILD_DIR n'est
# pas nettoyé entre les runs) → pacman -U recevait 2× le même nom de
# paquet (« erreur : cible répétée ») et la vieille version repartait
# dans local-repo. Le grep filtre tout bruit éventuel de su - (PAM…).
# NB : --packagelist liste aussi un -debug qui n'est PAS toujours produit
# (paquet pur python : rien à stripper) → ne garder que les fichiers
# réellement présents sur disque.
local -a pkgfiles=() existing=()
local f
mapfile -t pkgfiles < <(su - "$BUILD_USER" -c "cd '$d' && makepkg --packagelist" \
| grep -E '\.pkg\.tar\.')
for f in "${pkgfiles[@]}"; do [ -e "$f" ] && existing+=("$f"); done
[ "${#existing[@]}" -gt 0 ] || error "Aucun paquet produit trouvé pour $name"
pacman -U --noconfirm "${existing[@]}" || error "Install de $name échouée"
publish_to_repo "$name" "${existing[@]}"
success "$name build + install OK"
}