#!/bin/bash #Copyright 2002 William Stearns #Released under the GPL. #grep '^[A-Z]' to separate the uc/lc's. unset CDPATH #CDPATH screws up the directory listings - thanks Stephen! POMListVer='0.2.2' echo pomlist \(Patch-o-matic\) file lister, version $POMListVer. >>/dev/stderr fail () { echo "$* Exiting." >>/dev/stderr exit 1 } usage () { #FIXME - how how to set base filename once that is possible. echo 'pomlist, the patch-o-matic file html formatter, version '$POMListVer' .' >>/dev/stderr echo 'Usage: ' >>/dev/stderr echo ' pomlist [/path/to/p-o-m/directory] [fullpage] [http://baseurl/for/browsing]' >>/dev/stderr echo >>/dev/stderr echo 'The p-o-m directory is the directory containing "runme"' >>/dev/stderr echo 'If missing, it defaults to the current directory ' >>/dev/stderr echo '"fullpage" tells pomlist to construct the entire html page, ' >>/dev/stderr echo 'as opposed to the default html body text.' >>/dev/stderr echo 'The optional URL base is one that will be used in the hypertext ' >>/dev/stderr echo 'links to the actual files if specified. Otherwise, links to the ' >>/dev/stderr echo 'local files will be used.' >>/dev/stderr echo >>/dev/stderr echo 'Examples: ' >>/dev/stderr echo ' pomlist /usr/src/iptables-1.2.6a/patch-o-matic fullpage' >>/dev/stderr echo ' pomlist /usr/src/iptables-1.2.6a/patch-o-matic fullpage http://cvs.samba.org/cgi-bin/cvsweb/~checkout~/netfilter/userspace/patch-o-matic/' >>/dev/stderr echo ' pomlist /usr/src/iptables-1.2.6a/patch-o-matic fullpage file:/usr/src/iptables-1.2.6a/patch-o-matic/' >>/dev/stderr exit 0 } DoHeader () { if [ "$Fullpage" = "yes" ]; then cat < Patch-o-matic $1 patch listing EOHEADER fi echo '' echo '' echo '' echo '' } DoBody () { #Parameters: #$1: Name of the Suite being worked on, or 'combined' or "summary' for the top level if [ "$1" = "summary" ] || [ "$1" = "combined" ]; then Wildcard='*' for OneDir in * ; do if [ -d $OneDir ] && [ "$OneDir" != "CVS" ]; then DirList="$DirList $OneDir" fi done else Wildcard="$1" DirList="$1" fi #echo '

'$1 'patch listing

' #Netfilter web site generates its own - thanks Stephen! echo ' ' echo '

Individual Suite pages:

' echo '[summary] ' echo '[combined] ' for DirLink in * ; do if [ -d $DirLink ] && [ "$DirLink" != "CVS" ]; then echo '['$DirLink'] ' fi done echo #It isn't quite the case that all uppercase modules are targets, all #lower are matches. We'll just do a raw list. #Besides, bash on my system isn't letting me list or case upper vs. lower correctly. *sigh* if [ "$1" != "summary" ]; then echo '

ipv4 patches

' if [ -n "`ls -A1 $Wildcard/*.patch.help 2>/dev/null | sed -e 's@.*/@@' | sort`" ]; then for OnePatch in `ls -A1 $Wildcard/*.patch.help 2>/dev/null | sed -e 's@.*/@@' | sort` ; do PatchName=`echo $OnePatch | sed -e 's/.patch.help//'` PatchPage='' echo -n '['$PatchName'] ' done else echo 'None' fi echo echo '

ipv6 patches

' if [ -n "`ls -A1 $Wildcard/*.patch.ipv6.help 2>/dev/null | sed -e 's@.*/@@' | sort`" ]; then for OnePatch in `ls -A1 $Wildcard/*.patch.ipv6.help 2>/dev/null | sed -e 's@.*/@@' | sort` ; do PatchName=`echo $OnePatch | sed -e 's/.patch.ipv6.help//'` PatchPage='' echo -n '['$PatchName'] ' done else echo 'None' fi echo fi echo '
' for OneDir in $DirList ; do echo '

'$OneDir'

' if [ "$1" = "combined" ]; then echo -n '[Top] ' for DirLink in $DirList ; do if [ "$DirLink" != "$OneDir" ]; then echo '['$DirLink'] ' else echo '['$DirLink'] ' fi done fi cd $OneDir if [ -e "SUITE" ]; then Suite=`cat SUITE | sed -e "s/$OneDir//" | grep -v '^\W*$'` if [ -n "$Suite" ]; then echo '

'$OneDir' depends on: '$Suite'

' fi fi if [ -f DESCRIPTION ]; then echo -n '

' cat DESCRIPTION echo '

' fi if [ "$1" = "summary" ]; then echo '

'$OneDir 'ipv4 patches

' if [ -n "`ls -A1 *.patch.help 2>/dev/null | sed -e 's@.*/@@' | sort`" ]; then for OnePatch in `ls -A1 *.patch.help 2>/dev/null | sed -e 's@.*/@@' | sort` ; do PatchName=`echo $OnePatch | sed -e 's/.patch.help//'` PatchPage=${OutputBase##*/}-$OneDir.html echo -n '['$PatchName'] ' done else echo 'None' fi echo echo '

'$OneDir 'ipv6 patches

' if [ -n "`ls -A1 *.patch.ipv6.help 2>/dev/null | sed -e 's@.*/@@' | sort`" ]; then for OnePatch in `ls -A1 *.patch.ipv6.help 2>/dev/null | sed -e 's@.*/@@' | sort` ; do PatchName=`echo $OnePatch | sed -e 's/.patch.ipv6.help//'` PatchPage=${OutputBase##*/}-$OneDir.html echo -n '['$PatchName'] ' done else echo 'None' fi echo echo '
' else echo '
' echo '
' for OnePatch in `ls *.patch.help *.patch.ipv6.help 2>/dev/null` ; do PatchName=`basename $OnePatch | sed -e 's/.patch.help//' -e 's/.patch.ipv6.help//'` echo -n '
'$PatchName' ' for OneExt in patch patch.config.in \ patch.configure.help patch.help patch.ipv6 \ patch.ipv6.config.in patch.ipv6.configure.help \ patch.ipv6.help patch.ipv6.makefile patch.makefile ; do if [ -f $PatchName.$OneExt ]; then #FIXME urlbase echo -n '['$PatchName.$OneExt'] ' fi done echo echo '
' echo '
'
				cat $OnePatch | sed \
				 -e 's@\(Author.*\)<\([^\>]*\)>@\1\<\2\>@' \
				 -e 's@\(http:[^ ]*\)@\1@' \
				 -e 's@\(ftp:[^ ]*\)@\1@'
				echo '
' echo '
' done echo '
' fi cd .. done } DoFooter () { echo '
' echo '

Generated '`date`' by pomlist version '$POMListVer'.

' echo '
' if [ "$Fullpage" = "yes" ]; then cat < EOFOOTER fi } FullParams="$0 $*" POMDir='./' #Default if not specified Extension='body' while [ -n "$1" ]; do case "$1" in [Hh][Ee][Ll][Pp]) usage ;; [Ff][Uu][Ll][Ll][Pp][Aa][Gg][Ee]) Fullpage="yes" Extension='html' ;; [Hh][Tt][Tt][Pp]*|[Ff][Tt][Pp]*|[Ff][Ii][Ll][Ee]*) BaseURL="$1" ;; #FIXME - a way of specifying OutputBase # /*) # OutputBase="$1" # ;; *) POMDir="$1/" ;; esac shift done #BaseURL="file:`pwd`/" [ -n "$BaseURL" ] || BaseURL="http://cvs.samba.org/cgi-bin/cvsweb/~checkout~/netfilter/userspace/patch-o-matic/" #OutputBase="/path/to/output" [ -n "$OutputBase" ] || OutputBase="`pwd`/pom" [ -e "$POMDir/runme" ] || fail 'Not in the patch-o-matic directory, please specify the directory that contains "runme" on the command line.' cd $POMDir || fail 'Could not change to patch-o-matic directory' rm -f $OutputBase-combined.$Extension ( DoHeader 'combined' ; DoBody 'combined' ; DoFooter ) >$OutputBase-combined.$Extension rm -f $OutputBase-summary.$Extension ( DoHeader 'summary' ; DoBody 'summary' ; DoFooter ) >$OutputBase-summary.$Extension for SuiteDir in * ; do if [ -d $SuiteDir ] && [ "$SuiteDir" != "CVS" ]; then rm -f $OutputBase-$SuiteDir.$Extension ( DoHeader "$SuiteDir" ; DoBody "$SuiteDir" ; DoFooter ) >$OutputBase-$SuiteDir.$Extension fi done