aboutsummaryrefslogtreecommitdiff
path: root/sbopkglint.d/10-docs.t.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sbopkglint.d/10-docs.t.sh')
-rw-r--r--sbopkglint.d/10-docs.t.sh21
1 files changed, 21 insertions, 0 deletions
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.