[devscripts] 02/02: manpage-alert: show package names etc.

Osamu Aoki osamu at moszumanska.debian.org
Wed Mar 9 13:56:30 UTC 2016


This is an automated email from the git hooks/post-receive script.

osamu pushed a commit to branch master
in repository devscripts.

commit d807d4aa9a7aa8091869552fdf6a18ff14f1c9fc
Author: Osamu Aoki <osamu at pluto.local>
Date:   Wed Mar 9 15:01:40 2016 +0000

    manpage-alert: show package names etc.
    
    This update is inspired by a patch submitted by François
    Wendling <frwendling at free.fr> for #497320.
    
    This patch adds the following new features :
     * Show to which package executables belongs to, using dpkg-query.
     * It's now possible to remove the statistics line, and leading text
       allowing the output to be directly piped to another program.
     * Allow multi-character options
     * diversion and missing handled properly
---
 debian/changelog         |  2 ++
 scripts/manpage-alert.1  | 21 ++++++++++-----
 scripts/manpage-alert.sh | 69 +++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 82310a2..f9334e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ devscripts (2.16.2) UNRELEASED; urgency=medium
     + Fix non-{Debian,Ubuntu} cases.  Closes: #816645
   * debsnap:
     + Add --list option.  Closes: #610048, #679763, #816910
+  * manpage-alert:
+    + Show package name etc.  Closes: #497320
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/scripts/manpage-alert.1 b/scripts/manpage-alert.1
index 97cac66..5ba1445 100644
--- a/scripts/manpage-alert.1
+++ b/scripts/manpage-alert.1
@@ -2,21 +2,29 @@
 .SH NAME
 manpage-alert \- check for binaries without corresponding manpages
 .SH SYNOPSIS
-\fBmanpage-alert\fR [\fIpath list\fR]
-.br
-\fBmanpage-alert \-\-help\fR|\fB\-\-version\fR
+\fBmanpage-alert\fR [\fIoptions\fR] [\fIpaths\fR]
 .SH DESCRIPTION
 \fBmanpage-alert\fR searches the given list of paths for binaries without
 corresponding manpages.
 .P
-If no paths are specified on the command line, the path list
+If no \fIpaths\fR are specified on the command line, the path list
 \fI/bin /sbin /usr/bin /usr/sbin /usr/games\fR will be assumed.
 .SH OPTIONS
-.BR \-\-help ", " \-h
+.TP
+.BR \-h\fR, \fB\-\-help
 Show a summary of options.
 .TP
-.BR \-\-version ", " \-v
+.BR \-v\fR, \fB\-\-version
 Show version and copyright information.
+.TP
+.BR \-f\fR, \fB\-\-file
+Show filenames of missing manpages without any leading text.
+.TP
+.BR \-p\fR, \fB\-\-package
+Show filenames of missing manpages with their package name.
+.TP
+.BR \-n\fR, \fB\-\-no\-stat
+Do not show statistics at the end.
 .SH AUTHOR
 \fBmanpage-alert\fR was written by Branden Robinson and modified by
 Julian Gilbey <jdg at debian.org> and Adam D. Barratt
@@ -25,4 +33,3 @@ devscripts package.
 .P
 This manpage and the associated program are licensed under the terms of
 the GPL, version 2 or later.
-
diff --git a/scripts/manpage-alert.sh b/scripts/manpage-alert.sh
index 0e2acac..dd0ee3a 100755
--- a/scripts/manpage-alert.sh
+++ b/scripts/manpage-alert.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh -e
 #
 # Copyright 2005 Branden Robinson
 # Changes copyright 2007 by their respective authors
@@ -19,13 +19,18 @@
 
 usage() {
     cat <<EOF
-Usage: manpage-alert [options | paths]
+Usage: manpage-alert [options] [paths]
   Options:
     -h, --help          This usage screen.
-    -V, --version       Display the version and copyright information
+    -v, --version       Display the version and copyright information.
+    -f, --file          Show filenames of missing manpages
+                        without any leading text.
+    -p, --package       Show filenames of missing manpages
+                        with their package name.
+    -n, --no-stat       Do not show statistics at the end.
 
-  This script will locate executables in the given paths for which no
-  manpage is available.
+  This script will locate executables in the given paths with manpage
+  outputs for which no manpage is available and its statictics.
 
   If no paths are specified on the command line, "/bin /sbin /usr/bin
   /usr/sbin /usr/games" will be used by default.
@@ -34,7 +39,7 @@ EOF
 
 version() {
     cat <<EOF
-This is manpage-alert, from the Debian devscripts package, version ###VERSION###
+This is manpage-alert, from the Debian devscripts package, version ###VERSION###.
 This code is (C) 2005 by Branden Robinson, all rights reserved.
 This program comes with ABSOLUTELY NO WARRANTY.
 You are free to redistribute this code under the terms of the
@@ -42,10 +47,33 @@ GNU General Public License, version 2 or later.
 EOF
 }
 
-case "$1" in
-    --help|-h) usage; exit 0;;
-    --version|-V) version; exit 0;;
-esac
+showpackage() {
+    PKGNAME="$(LANG=C dpkg-query -S "$1" 2> /dev/null || true )"
+    if [ -n "$PKGNAME" ]; then
+        echo "$PKGNAME" | sed -e 's/diversion by \(.+\) to:/\1/'
+    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
     set -- /bin /sbin /usr/bin /usr/sbin /usr/games
@@ -59,24 +87,33 @@ 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 ))
 
-        OUT=$(man -w -S 1:8:6 "${F##*/}" 2>&1 >/dev/null)
-        RET=$?
-        if [ $RET = "0" ]; then
+        if OUT=$(man -w -S 1:8:6 "${F##*/}" 2>&1 >/dev/null); then
             NUM_MANPAGES_FOUND=$(( $NUM_MANPAGES_FOUND + 1 ))
         else
-            echo "$OUT" | perl -ne "next if /^.*'man 7 undocumented'.*$/;" \
-              -e "s,(\W)\Q${F##*/}\E(?:\b|$),\1$F,; s,//,/,; print;"
+            if [ $SHOWPACKAGE = "PACKAGE" ]; then 
+                # echo "<packagename>: <filename>"
+                showpackage "$F"
+            elif [ $SHOWPACKAGE = "FILE" ]; then
+                # echo "<filename>"
+                echo "$F"
+            else
+                # echo "No manual entry for <filename>"
+                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:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list