From 4d57e0a8dab2139a631a21aab862487481548702 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:32:59 +0200 Subject: Adding upstream version 2.23.7. Signed-off-by: Daniel Baumann --- scripts/manpage-alert.sh | 147 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100755 scripts/manpage-alert.sh (limited to 'scripts/manpage-alert.sh') diff --git a/scripts/manpage-alert.sh b/scripts/manpage-alert.sh new file mode 100755 index 0000000..626b377 --- /dev/null +++ b/scripts/manpage-alert.sh @@ -0,0 +1,147 @@ +#!/bin/sh -e +# +# Copyright 2005 Branden Robinson +# Changes copyright 2007 by their respective authors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +usage() { + cat < /dev/null || true )" + Q1=""; R1=""; Q2=""; R2="" + if [ -n "$P1" ]; then + Q1="$(echo "$P1" | grep -v "^diversion by" || true)" + R1="$(echo "$P1" | sed -ne 's/^diversion by \(.*\) to:.*$/\1/p'): $F1" + fi + # symlink may be created by postinst script for alternatives etc., + if [ -z "$Q1" ] && [ -L "$F1" ]; then + F2=$(readlink -f "$F1") + P2="$(LANG=C dpkg-query -S "$F2" 2> /dev/null || true )" + if [ -n "$P2" ]; then + Q2="$(echo "$P2" | grep -v "^diversion by" || true)" + R2="$(echo "$P2" | sed -ne 's/^diversion by \(.*\) to:.*$/\1/p'): $F2" + fi + fi + if [ -n "$Q1" ]; then + echo "$Q1" + elif [ -n "$R1" ]; then + echo "$R1 (diversion)" + elif [ -n "$Q2" ]; then + echo "unknown_package: $F1 -> $Q2" + elif [ -n "$R2" ]; then + echo "unknown_package: $F1 -> $R2 (diversion)" + else + echo "unknown_package: $F1" + fi +} + +SHOWPACKAGE=DEFAULT +SHOWSTAT=TRUE + +while [ -n "$1" ]; do + case "$1" in + -h|--help) usage; exit 0;; + -V|--version) version; exit 0;; + -p|--package) SHOWPACKAGE=PACKAGE + shift + ;; + -f|--file) SHOWPACKAGE=FILE + shift + ;; + -n|--no-stat) SHOWSTAT=FALSE + shift + ;; + *) break + ;; + esac +done + +if [ $# -lt 1 ]; then + # check if we're running on a usrmerge system + if [ -L /bin -a -L /sbin ]; then + set -- /usr/bin /usr/sbin /usr/games + else + set -- /bin /sbin /usr/bin /usr/sbin /usr/games + fi +fi + +NUM_EXECUTABLES=0 +NUM_MANPAGES_FOUND=0 +NUM_MANPAGES_MISSING=0 + +for DIR in "$@"; do + for F in "$DIR"/*; do + # Skip as it's a symlink to /usr/bin + if [ "$F" = "/usr/bin/X11" ]; then continue; fi + NUM_EXECUTABLES=$(( NUM_EXECUTABLES + 1 )) + + if OUT=$(man -w -S 1:8:6 "${F##*/}" 2>&1 > /dev/null); then + NUM_MANPAGES_FOUND=$(( NUM_MANPAGES_FOUND + 1 )) + else + if [ $SHOWPACKAGE = "PACKAGE" ]; then + # echo ": " + showpackage "$F" + elif [ $SHOWPACKAGE = "FILE" ]; then + # echo "" + echo "$F" + else + # echo "No manual entry for " + echo "$OUT" | perl -ne "next if /^.*'man 7 undocumented'.*$/;" \ + -e "s,(\W)\Q${F##*/}\E(?:\b|$),\1$F,; s,//,/,; print;" + fi + NUM_MANPAGES_MISSING=$(( NUM_MANPAGES_MISSING + 1 )) + fi + done +done + +if [ $SHOWSTAT = "TRUE" ]; then +echo +printf "Of %d commands, found manpages for %d (%d missing).\n" \ + $NUM_EXECUTABLES \ + $NUM_MANPAGES_FOUND \ + $NUM_MANPAGES_MISSING +fi + +# vim:set ai et sw=4 ts=4 tw=80: -- cgit v1.2.3