diff --git a/.gitea/workflows/tests.yaml b/.gitea/workflows/tests.yaml index 550510f..dc7c118 100644 --- a/.gitea/workflows/tests.yaml +++ b/.gitea/workflows/tests.yaml @@ -309,34 +309,63 @@ jobs: echo " Checking for conflicting packages in packages.x86_64" echo "═══════════════════════════════════════════════════════════════" - # Sync databases first so pacman knows what exists - sudo pacman -Sy --noconfirm + # Resolve against the repos mkarchiso sees, including [local-aur] + # (localrepo/), so conflicts between pre-built AUR packages and + # anything else are caught here instead of in the ISO build. + # A fresh dbpath = empty local db, like pacstrap's target root: + # packages installed on the runner can neither mask a conflict + # nor cause a false one. + CONF=$(mktemp) + DB=$(mktemp -d) + ROOT=$(mktemp -d) + cp /etc/pacman.conf "$CONF" + printf '\n[local-aur]\nSigLevel = Optional TrustAll\nServer = file://%s/localrepo\n' \ + "$PWD" >> "$CONF" + mkdir -p "$DB/sync" + cp -p /var/lib/pacman/sync/*.db "$DB/sync/" + pac() { pacman --config "$CONF" --dbpath "$DB" "$@"; } + pac -Sy --noconfirm + # From here on never download (set after -Sy, which needs to fetch + # the file:// local-aur db): the check only needs a prepared + # transaction + sed -i '/^\[options\]/a XferCommand = /usr/bin/false %u' "$CONF" - # Collect only packages that exist in the official repositories + # Packages built at ISO build time (build-end4-deps.sh) can't be + # resolved yet; everything else must be + mapfile -t AVAIL < <(pac -Slq | sort -u) PKGS=() while IFS= read -r pkg; do [[ -z "$pkg" || "$pkg" =~ ^# ]] && continue - - # Check if the package exists in official repos - if pacman -Si "$pkg" >/dev/null 2>&1; then + if printf '%s\n' "${AVAIL[@]}" | grep -qxF -- "$pkg"; then PKGS+=("$pkg") else - echo "⚠️ Skipping AUR/missing package: $pkg" + echo "⚠️ Skipping unresolvable package: $pkg" fi done < packages.x86_64 - # Run conflict check only if we have official packages to test + # `pacman -Sp` skips conflict checks entirely, so run a real -S + # into an empty root. Conflicts and broken deps fail in "prepare", + # before any download; a clean list gets as far as the download, + # which the XferCommand above makes fail on purpose. if [ ${#PKGS[@]} -eq 0 ]; then - echo "✅ No official packages to check." - elif CONFLICTS=$(pacman -Sp --needed "${PKGS[@]}" 2>&1); then - echo "✅ No package conflicts detected among official packages" + echo "✅ No resolvable packages to check." else - echo "------- Pacman Output -------" - echo "$CONFLICTS" - echo "-----------------------------" - echo "" - echo "═══════════════════════════════════════════════════════════════" - echo " ❌ Conflicting packages found — fix packages.x86_64" - echo "═══════════════════════════════════════════════════════════════" - exit 1 + OUT=$(pac -S --noconfirm --root "$ROOT" --cachedir "$ROOT" "${PKGS[@]}" 2>&1) + if grep -q 'failed to prepare transaction' <<< "$OUT"; then + echo "------- Pacman Output -------" + grep -vE '^(http|file|ftp)' <<< "$OUT" | tail -40 + echo "-----------------------------" + echo "" + echo "═══════════════════════════════════════════════════════════════" + echo " ❌ Conflicting/unresolvable packages — fix packages.x86_64" + echo "═══════════════════════════════════════════════════════════════" + exit 1 + elif ! grep -q 'Proceed with installation' <<< "$OUT"; then + echo "------- Pacman Output -------" + tail -40 <<< "$OUT" + echo "-----------------------------" + echo "❌ pacman stopped before the conflict check completed" + exit 1 + fi + echo "✅ No package conflicts detected (repos + local-aur)" fi