From 0c48381bdc0bfd199166b721493ae8eb43556335 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 3 Feb 2023 21:15:02 -0500 Subject: sbopkglint: check PDF files in doc dir --- sbopkglint.d/10-docs.t.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sbopkglint.d') 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. -- cgit v1.2.3