summaryrefslogtreecommitdiffstats
path: root/man/check-man
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:19:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:19:27 +0000
commite0023883c6d2e6745a19e4b48e186ed156c1fca8 (patch)
tree1a48b8056ec984385d0d862b683535d04d6ed215 /man/check-man
parentInitial commit. (diff)
downloadman-db-e0023883c6d2e6745a19e4b48e186ed156c1fca8.tar.xz
man-db-e0023883c6d2e6745a19e4b48e186ed156c1fca8.zip
Adding upstream version 2.11.2.upstream/2.11.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'man/check-man')
-rwxr-xr-xman/check-man46
1 files changed, 46 insertions, 0 deletions
diff --git a/man/check-man b/man/check-man
new file mode 100755
index 0000000..a58b7f9
--- /dev/null
+++ b/man/check-man
@@ -0,0 +1,46 @@
+#! /bin/sh
+set -e
+
+# Check that a manual page formats without errors. Lintian does something
+# similar for Debian packages. Relies on top_builddir, LINGUA, and EGREP
+# variables exported from 'make check', or you can set them manually.
+
+if [ -z "$top_builddir" ]; then
+ echo "top_builddir unset; try 'make check' instead?"
+ exit 77
+elif [ -z "$LINGUA" ]; then
+ echo "LINGUA unset; try 'make check' instead?"
+ exit 77
+elif [ -z "$EGREP" ]; then
+ echo "EGREP unset; try 'make check' instead?"
+ exit 77
+fi
+
+[ -x "$top_builddir/src/man" ] || exit 77
+
+code=0
+errors="$(LC_ALL=C MANWIDTH=80 MAN_KEEP_FORMATTING=1 "$top_builddir/libtool" \
+ --mode=execute \
+ -dlopen "$top_builddir/lib/.libs/libman.la" \
+ -dlopen "$top_builddir/libdb/.libs/libmandb.la" \
+ "$top_builddir/src/man" --warnings -E UTF-8 -l "$1" \
+ 2>&1 >/dev/null)" || code=$?
+
+# Ignore wrapping failures for CJK manual pages; this should go away once
+# groff supports these natively.
+# Indeed, even for other languages we're going to get "cannot adjust line"
+# if %manpath_config_file% expands to something long. Hmm. We'll just ignore
+# this across the board for now.
+errors="$(echo "$errors" | $EGREP -v "(cannot adjust line|can't break line)")" || true
+
+if [ "$code" != 0 ]; then
+ echo "man -E UTF-8 -l $1 failed with exit status $code and error output:"
+ echo "$errors"
+ exit $code
+elif [ "$errors" ]; then
+ echo "man -E UTF-8 -l $1 produced error output:"
+ echo "$errors"
+ exit 1
+else
+ exit 0
+fi