Greetings,
in the analysis of https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234126, I found that the whole doc/ build will
- not properly detect if the .ps.eps suffix-transformation rule's commands fail with blank page!! and leave a useless .eps file behind
- also on the same conversion run, the eps to png rules will break on that .eps file, but emit pnmtopng: bad magic number 0x2d67 - not a PPM, PGM, PBM, or PAM file and leave a zero-sized .png file behind.
So running make ; make will succeed for book/handbook, but leave a 0-sized share/images/books/handbook/advanced-networking/net-routing.png file.
The attached patch, in an attempt to fail early and consistently,
- adds extra checks to see that ${PS2EPS} in particular from the .ps.eps rule isn't emitting output on the "wrong channel" which I assume is an error message such as "blank page!" when the paper size is mismatched. The thing is that ps2epsi.ps script itself will complain, but gs runs it to completion, so the exit status doesn't give us a clue about the failure.
- sets .DELETE_ON_ERROR for the easy cases (in share/mk/doc.images.mk and share/pgpkeys/Makefile) that make a lot of use of >${.TARGET} redirections that are prone to leaving broken files behind
Further discussion and failed attempts at fixing:
- Chaining the commands with && doesn't help prevent the "false success" of a failed rule, I've tried that, we really need to watch for unexpected output.
- I am aware that the latter sensitizes the .ps.eps rule to future ps2epsi.ps or the gs changes, in that the assumption "output outside the intended channel means error" could create a false negative, but that's then easier to spot