Patch Recovery Workflow
When a patch fails to apply (.rej files appear or patch exits non-zero):
Identify the failing patch from the error output. Patches are listed in the
sourcearray of thePKGBUILD.Clone upstream at the target version:
git clone <upstream-repo-url> /tmp/upstream-recovery cd /tmp/upstream-recovery git checkout <target-tag-or-commit>Attempt manual application:
patch -p1 < /path/to/failing.patchResolve any
.rej(reject) files by editing the affected source files. The.rejfile shows the failed hunk in context. After resolving, delete all.rejfiles.Generate a fresh patch:
git diff > <package-dir>/<patch-name>.patchUpdate the
PKGBUILDsource array to reference the regenerated patch if the filename changed.Refresh checksums:
updpkgsumsRun the full verification sequence:
namcap PKGBUILD makepkg --printsrcinfo > .SRCINFO pkgctl build
Gotchas
- If the upstream source has been substantially refactored, the patch may be obsolete. Verify whether the patch's purpose (bug fix, feature) has been addressed upstream before spending time on regeneration.
- For packages using
update.shfor transformations rather than.patchfiles (e.g.,ranger-doas), this workflow does not apply. Consult the package's localAGENTS.mdinstead. - If
updpkgsumsfails, the upstream tarball may have been re-rolled. Verify the file content manually before committing new hashes.
When to Escalate
If a patch cannot be reconciled with upstream changes after 2-3 regeneration attempts, or if the patch addresses a security vulnerability, escalate to the user before proceeding.