Subject: Re: bin/5231: makewhatis does not deal with multiple MANDIR's
To: None <mason@primenet.com.au>
From: Tim Rightnour <root@garbled.net>
List: netbsd-bugs
Date: 03/30/1998 05:22:32
On 30-Mar-98 Geoff Wing spoke unto us all:
# Charlie Root <root@polaris.garbled.net> typed:
# :>Number: 5231
# :>Category: bin
# :>Synopsis: makewhatis does not deal with multiple man dirs
# :>Organization:
#
# We already have B. RTFM, makewhatis(8)
My stupid mistake.. ugh.. (slaps self in forehead)
#
#
# run ``/usr/libexec/makewhatis /usr/pkg/man'' and not be disappointed. What
# should really be done is grep the _whatdb lines from man.conf, makewhatis
# on the path of those and install on the full name.
You are correct, so here is a redo.. this grabs the _whatdb lines and builds
each of them. It requires that your _whatdb lines are set up correctly in
man.conf.
#! /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
LIST=/tmp/makewhatislist$$
TMP=/tmp/whatis$$
trap "rm -f $LIST $TMP; exit 1" 1 2 15
# first perform a quick sanity check, and make sure all the dirs exist.
# could do all of this in one loop, But we waste no CPU if the last path
# element is bogus this way.
MANX=`cat /etc/man.conf | grep '^_whatdb' | awk '{print $2}' | xargs`
for TMPWHAT in $MANX
do
TMPDIR=`echo $TMPWHAT | sed 's/\/whatis.db//'`
if test ! -d "${DESTDIR}$TMPDIR"; then
echo "makewhatis: ${DESTDIR}$TMPDIR: not a directory"
exit 1
fi
done
# now make the list.
for TMPWHAT in $MANX
do
rm -f $TMP $LIST
TMPDIR=`echo $TMPWHAT | sed 's/\/whatis.db//'`
find ${DESTDIR}$TMPDIR \( -type f -o -type l \) -name '*.[0-9]*' -ls | \
sort -n | 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 "$TMPWHAT"
done
rm -f $LIST $TMP
exit 0
---
Tim Rightnour - root@garbled.net
http://www.zynetwc.com/~garbled/garbled.html