Subject: Re: bin/5231: makewhatis does not deal with multiple MANDIR's
To: None <netbsd-bugs@NetBSD.ORG>
From: Geoff Wing <mason@primenet.com.au>
List: netbsd-bugs
Date: 03/31/1998 14:48:09
Tim Rightnour <root@garbled.net> typed:
:Well, once again I've had quite a learning experience from my little attempt to
:fix something here.. I do appreciate the suggestions though, I'd much rather do
:it correctly, then have something broken comitted.
And if one wanted to be really annoying, one would post a jazzed up version.
However, the whole exercise is dependant upon whether people want this sort of
thing, rather than having multiple ``makewhatis dirname'' scripts.
(code note: after find, there's no benefit in sorting it given the method
of avoiding duplicate hard linked files)
#! /bin/sh
#
# $NetBSD: makewhatis.sh,v 1.13 1998/03/21 23:46:00 tron Exp $
#
# Recent changes by Tim Rightnour 03/29/1998 to make it work on multiple
# man dirs. Slight cleanup as well.
#
# written by matthew green <mrg@eterna.com.au>, based on the
# original by J.T. Conklin <jtc@netbsd.org> and Thorsten
# Frueauf <frueauf@ira.uka.de>.
#
# Public domain.
#
# The variables below make it slightly easier to put in local hacks to
# getname and the sed routines.
GETNAME=/usr/libexec/getNAME
SEDFILE=/usr/share/man/makewhatis.sed
BASEMANLIST="/usr/share/man /usr/local/man /usr/pkg/man /usr/X11R6/man \
/usr/X11R5/man"
LIST=/tmp/makewhatislist$$
TMP=/tmp/whatis$$
trap "rm -f $LIST $TMP; exit 1" 1 2 15
if [ -n "$1" ] ; then
TMPMANLIST=$1
else
if [ -f /etc/man.conf ] ; then
TMPMANLIST=`awk '/^_whatdb/ { print $2 }' /etc/man.conf`
fi
if [ -z "$TMPMANLIST" ] ; then
TMPMANLIST=$BASEMANLIST
fi
fi
for TMPMAN in $TMPMANLIST ; do
if [ -d $TMPMAN ] ; then
MANLIST="$MANLIST $TMPMAN/whatis.db"
elif [ -d `dirname $TMPMAN` ] ; then
MANLIST="$MANLIST $TMPMAN"
fi
done
# now make the list.
for TMPMAN in $MANLIST
do
rm -f $TMP $LIST
TMPDIR=`dirname $TMPMAN`
find ${DESTDIR}$TMPDIR \( -type f -o -type l \) -name '*.[0-9]*' -ls | \
awk '{if (u[$1]) next; u[$1]++ ; print $11}' > $LIST
egrep '\.[1-9]$' $LIST | xargs ${GETNAME} | \
sed -e 's/ [a-zA-Z0-9]* \\-/ -/' > $TMP
egrep '\.0$' $LIST | while read file
do
sed -n -f ${DESTDIR}${SEDFILE} $file;
done >> $TMP
egrep '\.[0].(gz|Z)$' $LIST | while read file
do
gzip -fdc $file | sed -n -f ${DESTDIR}${SEDFILE};
done >> $TMP
sort -u -o $TMP $TMP
install -o bin -g bin -m 444 $TMP $TMPMAN
done
rm -f $LIST $TMP
exit 0
--
Geoff Wing <gcw@pobox.com> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/