Created attachment 219173 [details]
[patch] fix undetected cat_file failure
If a patch file does not exist, do-patch.sh does not trigger a build failure. It appears this was broken in r533459 (2020-04-30).
See also bug 250530 comment 10.
The attached patch checks the return value of cat_file first, then the pipeline to do_patch(). This isn't great efficiency-wise, because of the extra cat, but it catches more potential failures than just [ ! -r "$file" || ! ! -f "$file" ] or similar tests - for instance, if the patch is compressed and the decompression fails for some reason.
(In reply to John Hein from comment #0)
Correction: I think this was broken in do-patch.sh from day 1. r533459 just shuffled things around as far as the particular piece that is addressed in this bug.
In which case is this supposed to happen?
If you have a use case, would a simple "set pipefail" at the top of the script not be enough?
I have opened review D27007 and bug #250723 with a more global pipefail patch.
(In reply to Mathieu Arnold from comment #3)
See bug 250530 comment 10 for a real failure case (devel/llvm10 before ports r553456).
pipefail seems like it is a good alternative fix, yes.
I have not tested your wider pipefail patch from bug 250723 to see if anything breaks that shouldn't, but conceptually it seems like it is reasonable.
It's not written in porter's handbook, but we can use make -D PATCH_DEBUG patch to debug the patch.
Why don't you just run it before you ask them to commit? :)
Closing this bug in favor of the fix in bug 250723.