File find_manpage_gaps.sh of Package man-pages-supplement
#!/bin/bash
#
# Script to find binaries without associated man-page
# Copyright (C) 2008 SUSE Linux Products GmbH
# Author: Matthias G. Eckermann <mge@novell.com>
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
# USA.
#
BASEPATH=/mnt
TMPPATH=/var/tmp/man
#
RPM="rpm --nosignature "
RPMPATH=$BASEPATH/suse
ARCHIVES=$BASEPATH/ARCHIVES.gz
MANARCH=$TMPPATH/MANARCHIVES
MANPAGES="$RPMPATH/noarch/man-pages*.rpm"
function create_man_page_pod() {
BinaryName=$1
PackageName=$2
PackageSummary=$( $RPM -qp --queryformat="%{Summary}" $RR )
PackageLicense=$( $RPM -qp --queryformat="%{LICENSE}" $RR )
PackageDescription=$( $RPM -qp --queryformat="%{DESCRIPTION}" $RR )
PackageURL=$( $RPM -qp --queryformat="%{URL}" $RR )
if [ "$PackageURL"=="(none)" ]; then
echo $PackageName | grep -i kde > /dev/null
if [ $? == 0 ]; then
PackageURL="http://www.kde.org/"
else
echo $PackageName | grep -i gnome > /dev/null
if [ $? == 0 ]; then
PackageURL="http://www.gnome.org/"
else
PackageURL=""
fi
fi
fi
cat > $TMPPATH/pod/$BinaryName.1.pod <<EOF
=head1 NAME
$BinaryName
=head1 SYNOPSIS
This executable is part of the package '$PackageName': $PackageSummary
Documentation for SUSE Linux Enterprise is available online at: L<http://www.novell.com/documentation/> and also installed on the system at F</usr/share/doc/manual/>
Additional documentation for a specific package may be available at F</usr/share/doc/packages/$PackageName/> L<$PackageURL/>
=head1 DESCRIPTION
$PackageDescription
=head1 LICENSE
$PackageLicense
=cut
EOF
}
function convert_pod2man() {
BinaryName=$1
PackageName=$2
PackagePath=$3
sed -i -e "s/Authors:/=head1 AUTHORS\\n/g" $TMPPATH/pod/$BinaryName.1.pod
sed -i -e "s/--------//g" $TMPPATH/pod/$BinaryName.1.pod
if [ "$PackagePath" == "/sbin/" ]; then
PackageGroup=8
pod2man --section=$PackageGroup --name=$BinaryName --center=$PackageName $TMPPATH/pod/$BinaryName.1.pod $TMPPATH/usr/share/man/man8/$BinaryName.$PackageGroup
else
PackageGroup=1
pod2man --section=$PackageGroup --name=$BinaryName --center=$PackageName $TMPPATH/pod/$BinaryName.1.pod $TMPPATH/usr/share/man/man1/$BinaryName.$PackageGroup
fi
}
mkdir -p $TMPPATH/pod
mkdir -p $TMPPATH/usr/share/man/man1
mkdir -p $TMPPATH/usr/share/man/man8
zgrep /usr/share/man/ $ARCHIVES > $MANARCH
ALLPACKS=0
FOUND=0
NOTFOUND=0
for RR in $( find $RPMPATH -iname "*.rpm" ); do
RESVAL=0
FOUNDIN=0
RRR=$( basename $RR | cut -d- -f1 )
PACKNAME=$( $RPM -qp --queryformat="%{NAME}" $RR )
for SUBPATH in /bin/ /sbin/; do
for BB in $( $RPM -qlp $RR | grep $SUBPATH ); do
a=$(( ALLPACKS++ ))
FOUNDIN="package"
BBB=$( basename $BB )
RESSTR=$( $RPM -qlp $RR | grep /usr/share/man/ | grep "/$BBB\." )
RESVAL=$?
if [ $RESVAL -eq 1 ]; then
FOUNDIN="docpack"
RRDOC=$( find $RPMPATH -iname "$RRR*-doc*.rpm" )
if [ ".$RRDOC"=="." ] ; then
RESVAL=1
else
RESSTR=$( $RPM -qlp $RRDOC | grep /usr/share/man/ | grep "/$BBB\." )
RESVAL=$?
fi
if [ $RESVAL -eq 1 ]; then
FOUNDIN="archive"
RESSTR=$( grep /usr/share/man/ $MANARCH | grep "/$BBB\." )
RESVAL=$?
fi
fi
if [ $RESVAL -eq 1 ] ; then
a=$(( NOTFOUND++ ))
echo "- Binary=$BBB Package=$PACKNAME"
create_man_page_pod $BBB $PACKNAME
convert_pod2man $BBB $PACKNAME $SUBPATH
else
a=$(( FOUND++ ))
echo "+ $FOUNDIN Binary=$BBB Package=$PACKNAME"
fi
done
done
done
rm -f $MANARCH
echo -e "\nResult:\nAll=$ALLPACKS Found=$FOUND Notfound=$NOTFOUND\n"