aboutsummaryrefslogtreecommitdiff
path: root/sbopkglint.d
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2023-02-03 21:15:02 -0500
committerB. Watson <urchlay@slackware.uk>2023-02-03 21:15:02 -0500
commit0c48381bdc0bfd199166b721493ae8eb43556335 (patch)
treed41330fcc03933dec3d19a68e6e2601569ea47fe /sbopkglint.d
parentd0a889c066c90e5df14fc56881ff2aa4f0367719 (diff)
downloadsbo-maintainer-tools-0c48381bdc0bfd199166b721493ae8eb43556335.tar.gz
sbopkglint: check PDF files in doc dir
Diffstat (limited to 'sbopkglint.d')
-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.