fix: fail safely when AUR synchronization fails
All checks were successful
Update AUR Packages / update (nethlink-appimage) (push) Successful in 13s
Update AUR Packages / update (open-video-downloader-appimage) (push) Successful in 13s
Update AUR Packages / update (open-video-downloader-bin) (push) Successful in 14s
Update AUR Packages / update (pman-helper) (push) Successful in 13s
Update AUR Packages / update (reflex-appimage) (push) Successful in 13s
Update AUR Packages / update (tsparams) (push) Successful in 12s

This commit is contained in:
2026-07-27 00:17:01 +02:00
parent 4defd478dc
commit 2565c193e6
5 changed files with 174 additions and 19 deletions

View File

@@ -50,6 +50,16 @@ if git fetch --quiet aur-ro master 2>/dev/null; then
log "AUR already in sync (${pkgname})"
exit 0
fi
# Established BEFORE pushing, rather than inferred from a failure afterwards.
# The AUR only ever accepts fast-forwards, so this is the whole decision --
# there is no force to fall back on.
if ! git merge-base --is-ancestor FETCH_HEAD HEAD; then
die "the AUR has commits origin does not, for ${pkgname}.
The AUR accepts fast-forwards only and refuses force pushes from anyone who
is not an AUR administrator, so this cannot be overwritten. Rebase or replay
the local changes onto the AUR's HEAD, then re-run."
fi
log "AUR differs from origin; pushing (${pkgname})"
else
log "no AUR repo for ${pkgname} yet; the first push will create it"
@@ -60,20 +70,28 @@ if [ -n "${NO_GIT_PUSH:-}" ]; then
exit 0
fi
if git push aur HEAD:master; then
if push_output="$(git push aur HEAD:master 2>&1)"; then
printf '%s\n' "$push_output"
log "pushed ${pkgname} to the AUR"
exit 0
fi
# A rejected push here usually means the AUR has commits origin does not,
# i.e. someone pushed directly. Overwriting that silently would destroy it.
if [ -n "${AUR_FORCE:-}" ]; then
warn "AUR_FORCE set: force-pushing over the AUR history for ${pkgname}"
git push --force aur HEAD:master
exit 0
fi
# Report what git actually said, then name a remedy that can work. The previous
# version blamed every failure on a diverged history and recommended a force
# push -- wrong on both counts for what turned out to be an unregistered SSH key.
printf '%s\n' "$push_output" >&2
die "push to the AUR was rejected for ${pkgname}.
The AUR history has probably diverged from origin (someone pushed there
directly). Inspect it, then re-run with AUR_FORCE=1 to overwrite.
This run leaves origin untouched and will be retried on the next pass."
case "$push_output" in
*"Permission denied"*|*"publickey"*|*"Could not read from remote repository"*)
die "the AUR rejected the SSH key for ${pkgname}.
Check that AUR_SSH_KEY holds a valid private key and that its public half is
saved on your AUR account (My Account -> SSH Public Key; the form needs your
account password before it will save)." ;;
*"non-fast-forward"*|*"fetch first"*)
die "the AUR moved between the pre-check and the push for ${pkgname}.
Nothing to do: the next run re-reads the AUR and reconciles." ;;
*"Host key verification failed"*|*"Could not resolve hostname"*)
die "could not reach aur.archlinux.org for ${pkgname}; see the error above." ;;
*)
die "push to the AUR failed for ${pkgname}; see the git error above." ;;
esac