[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

r10418 - /man-cgi/extractor/list-manpages-packages.sh



Author: jfs
Date: Sun May 25 13:33:49 2014
New Revision: 10418

URL: http://svn.debian.org/wsvn/?sc=1&rev=10418
Log:

For a given distribution, using the information extracted from Contents.gz, list the location
in the pool for all the packages that contain the manpages.

This output can then be feeded to the manpage-extractor in order to extract the manpages from those packages directly.


Added:
    man-cgi/extractor/list-manpages-packages.sh   (with props)

Added: man-cgi/extractor/list-manpages-packages.sh
URL: http://svn.debian.org/wsvn/man-cgi/extractor/list-manpages-packages.sh?rev=10418&op=file
==============================================================================
--- man-cgi/extractor/list-manpages-packages.sh	(added)
+++ man-cgi/extractor/list-manpages-packages.sh	Sun May 25 13:33:49 2014
@@ -0,0 +1,65 @@
+#!/bin/sh -e
+#
+# List the manpages files for a given distribution and provide
+# the pool filenames
+
+# 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 "ERROR: Cannot find the directory $EXTRACTORDIR with the scripts!" >&2
+        exit 1
+fi
+
+# Parameter parsing
+dist=$1
+if [ -z "$dist" ] ; then
+	echo "WARN: No distribution given, using 'sid'">&2
+	dist=sid
+fi
+[ -n "$2" ] && ARCH=$2
+[ -n "$ARCH" ] && ARCH="i386"
+[ -n "$REPOS" ] && REPOS="main"
+
+# Last sanity checks
+INPUTFILE="$DATADIR/packages_with_manpages.${dist}.${ARCH}"
+if [ ! -e "$INPUTFILE" ] ; then
+        echo "ERROR: $INPUTFILE does not exist, please run the count-manpages-archive.sh script first" >&2
+	exit 1
+fi
+PACKAGEFILE="$MIRRORDIR/dists/$dist/main/binary-${ARCH}/Packages.gz"
+if [ ! -e "$PACKAGEFILE" ] ; then
+        echo "ERROR: $PACKAGEFILE does not exist. Is $MIRRORDIR a mirror?" >&2
+	exit 1
+fi
+
+cat $INPUTFILE |
+while read package; do
+# TODO: sometimes package is actually more than *one* package (if it contains a ',') look
+# for that and manage it
+	packagename=`echo $package | awk -F '/' '{print $2}'`
+	for repo in main contrib non-free; do
+		PACKAGEFILE="$MIRRORDIR/dists/$dist/$repo/binary-${ARCH}/Packages.gz"
+		echo "DEBUG: Looking for $packagename (from $package) in $PACKAGEFILE" >&2
+		if [ -r $PACKAGEFILE ]; then
+			filename=`zcat $PACKAGEFILE |grep-dctrl -F Package -X $packagename | grep Filename: | awk '{print $2}'`
+			[ -n "$filename" ] && echo $filename
+			if [ ! -e "${MIRRORDIR}/$filename" ] ; then
+			echo "WARN: File not found under $MIRRORDIR. Is mirror updated?" >&2
+			fi
+		fi
+	done
+done
+
+
+exit 0

Propchange: man-cgi/extractor/list-manpages-packages.sh
------------------------------------------------------------------------------
    svn:executable = *


Reply to: