r10322 - /man-cgi/extractor/list-manpages-dist.sh
Author: jfs
Date: Tue Nov 5 22:57:20 2013
New Revision: 10322
URL: http://svn.debian.org/wsvn/?sc=1&rev=10322
Log:
Add script to list the manpages that exist in a given distribution. To compare the extracted manpages with the indexed files in Contents.gz
Added:
man-cgi/extractor/list-manpages-dist.sh (with props)
Added: man-cgi/extractor/list-manpages-dist.sh
URL: http://svn.debian.org/wsvn/man-cgi/extractor/list-manpages-dist.sh?rev=10322&op=file
==============================================================================
--- man-cgi/extractor/list-manpages-dist.sh (added)
+++ man-cgi/extractor/list-manpages-dist.sh Tue Nov 5 22:57:20 2013
@@ -0,0 +1,98 @@
+#!/bin/sh -e
+#
+# List the manual pages available for a given distribution
+
+
+# Source the configuration file
+ME=$0
+MYDIR="`dirname $ME`"
+
+. ${MYDIR}/config
+
+usage () {
+ echo "Usage: $0 distribution"
+}
+
+# Setup directory for scripts
+[ -z "$EXTRACTORDIR" ] && EXTRACTORDIR=$MYDIR
+
+if [ ! -d "$EXTRACTORDIR" ] ; then
+ echo "Cannot find the directory $EXTRACTORDIR with the scripts!" >&2
+ exit 1
+fi
+if [ ! -d "$MIRRORDIR" ] || [ ! -d "$MIRRORDIR/pool" ] ; then
+ echo "Cannot find a Debian mirror archive at $MIRRORDIR!" >&2
+ exit 1
+fi
+
+# We store our results here
+DATADIR="$EXTRACTORDIR/data"
+if [ ! -d "$DATADIR" ] ; then
+ mkdir "$DATADIR" || { echo "ERROR: Cannot create ${DATADIR} " >&2; exit 1; }
+fi
+
+dist=$1
+if [ -z "$dist" ] ; then
+ echo "ERROR: Distribution is not defined" >&1
+ usage
+ exit 1
+fi
+
+[ -n "$2" ] && ARCH=$2
+[ -n "$ARCH" ] && ARCH="i386"
+[ -n "$REPOS" ] && REPOS="main"
+
+
+[ ! -e "${MIRRORDIR}/dists/${dist}" ] && { echo "ERROR: Cannot find distribution ${dist} in ${MIRRORDIR}/dists " >&2; exit 1; }
+
+contents="${MIRRORDIR}/dists/${dist}/Contents-${ARCH}.gz"
+[ ! -e "$contents" ] && { echo "ERROR: Cannot find contents file $contents " >&2; exit 1; }
+
+echo "Obtaining the list of manpages for release $dist (architecture $ARCH)"
+
+# Parse the content files and extract a list of files, per package using regular expressions
+tempfile=`mktemp` || { echo "ERROR: Cannot create temporary file" >&2 ; exit 1; }
+trap "rm -f $tempfile 2>/dev/null || true" EXIT HUP INT QUIT TERM
+
+
+# Generate the manpages for each distribution
+# Only update if the file does not exist or if the contents file is newer
+if [ ! -e "${DATADIR}/dir_manpages_packages.${dist}.${ARCH}" ] ||
+ [ "$contents" -nt "${DATADIR}/dir_manpages_packages.${dist}.${ARCH}" ] ; then
+ # Try to only uncompress once
+ [ ! -s "$tempfile" ] && zcat $contents >$tempfile
+ egrep -i '^usr/(share|X11R6)/man/' $tempfile >${DATADIR}/dir_manpages_packages.${dist}.${ARCH}
+fi
+manpages_in_share_man=`cat ${DATADIR}/dir_manpages_packages.${dist}.${ARCH} | wc -l`
+if [ ! -e "${DATADIR}/files_manpages_packages.${dist}.${ARCH}" ] ||
+ [ "$contents" -nt "${DATADIR}/files_manpages_packages.${dist}.${ARCH}" ] ; then
+ # Try to only uncompress once
+ [ ! -s "$tempfile" ] && zcat $contents >$tempfile
+ egrep -i '\.[1-9]\w*\.gz\s+' $tempfile |grep -v ^usr/share/doc >${DATADIR}/files_manpages_packages.${dist}.${ARCH}
+fi
+manpages_possible_files=`cat ${DATADIR}/files_manpages_packages.${dist}.${ARCH} | wc -l`
+manpages_not_share_man=`grep -v ^usr/share/man/ ${DATADIR}/files_manpages_packages.${dist}.${ARCH} | wc -l`
+
+# list of manual pages (omitting package)
+cat ${DATADIR}/files_manpages_packages.${dist}.${ARCH} ${DATADIR}/dir_manpages_packages.${dist}.${ARCH} |
+ awk '{print $1}' | sort -u > ${DATADIR}/manpages.${dist}.${ARCH}
+total_manpages=`cat ${DATADIR}/manpages.${dist}.${ARCH} | wc -l`
+
+# list of packages with manual pages
+cat ${DATADIR}/files_manpages_packages.${dist}.${ARCH} ${DATADIR}/dir_manpages_packages.${dist}.${ARCH} |
+ awk '{print $2}' | sort -u > ${DATADIR}/packages_with_manpages.${dist}.${ARCH}
+total_packages=`cat ${DATADIR}/packages_with_manpages.${dist}.${ARCH} | wc -l`
+
+
+echo "---------------------------------------------"
+echo "Summary for release $dist, architecture $ARCH"
+echo "---------------------------------------------"
+echo "Total Manpages: $total_manpages"
+echo " - Possible manpage files: $manpages_possible_files"
+echo " - In /usr/(share|X11R6)/man/: $manpages_in_share_man"
+echo " - Not in /usr/(share|X11R6)/man/: $manpages_not_share_man"
+echo "Total packages with manpages: $total_packages"
+echo
+echo "The extracted information is available at ${DATADIR}"
+
+exit 0
Propchange: man-cgi/extractor/list-manpages-dist.sh
------------------------------------------------------------------------------
svn:executable = *
Reply to: