diff options
-rwxr-xr-x | sbopkglint | 5 | ||||
-rw-r--r-- | sbopkglint.d/10-docs.t.sh | 21 |
2 files changed, 26 insertions, 0 deletions
@@ -210,6 +210,11 @@ named INSTALL, INSTALL.*, or install.txt are flagged (it's impossible to make this test 100% perfect). This check can be disabled with the B<-i> option. +=item B<-> + +Any *.pdf files found in the doc dir are checked with B<pdfinfo> to +make sure they really are PDF files, and not corrupt/damaged. + =back =head2 noarch diff --git a/sbopkglint.d/10-docs.t.sh b/sbopkglint.d/10-docs.t.sh index 1e9e02a..c6710b7 100644 --- a/sbopkglint.d/10-docs.t.sh +++ b/sbopkglint.d/10-docs.t.sh @@ -18,6 +18,10 @@ # 444), and check that any +x file looks like some kind of script # (perl/shell/python/etc). +# also, any PDF files found in the doc dir are checked with pdfinfo, +# to make sure they're really PDFs and don't contain errors that +# prevent them being displayed. + DOCDIR=usr/doc/$PRGNAM-$VERSION # existence of the doc dir was already checked by a previous test, @@ -50,6 +54,23 @@ if [ -d "$DOCDIR" ]; then fi done fi + + # PDF filenames often have spaces/punctuation, don't use find. + # This is not ideal (only goes 3 levels deep), but it's easy. + for i in $DOCDIR/*.pdf $DOCDIR/*/*.pdf $DOCDIR/*/*/*.pdf \ + $DOCDIR/*.PDF $DOCDIR/*/*.PDF $DOCDIR/*/*/*.PDF + do + if [ -e "$i" ]; then + # pdfinfo non-fatal errors don't result in non-zero exit status, + # but generally they do mean un-renderable PDFs, so check its stderr + # in addition to its exit status. + pdfinfo "$i" &> .tmp.pdfinfo + if [ "$?" != "0" ] || grep -q '^Syntax Error' .tmp.pdfinfo; then + warn "broken PDF file: $i" + fi + rm -f .tmp.pdfinfo + fi + done fi # allow /usr/doc/HTML to exist, though we don't check its contents here. |