Subject: bin/5231: makewhatis does not deal with multiple MANDIR's
To: None <gnats-bugs@gnats.netbsd.org>
From: Charlie Root <root@polaris.garbled.net>
List: netbsd-bugs
Date: 03/29/1998 19:32:20
>Number: 5231
>Category: bin
>Synopsis: makewhatis does not deal with multiple man dirs
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Mar 29 18:35:01 1998
>Last-Modified:
>Originator: Charlie Root
>Organization:
Tim Rightnour - root@garbled.net
http://www.zynetwc.com/~garbled/garbled.html
>Release: 1.3<NetBSD-current source date>
>Environment:
System: NetBSD polaris 1.3 NetBSD 1.3 (POLARIS) #0: Thu Mar 26 13:17:18 MST 1998 root@polaris:/usr/src/sys/arch/i386/compile/POLARIS i386
>Description:
Installing new packages in NetBSD, or even the X11 stuff that "comes with it" does not
update the whatis.db file.. thus man -k functionality does not extend past the
/usr/share/man hierarchy.
With the /usr/pkg tree, and the /usr/X11R6 tree more or less integrated into NetBSD,
we should really deal better with the man pages that get installed there as well.
There are one of two approaches to this:
A> Create a large whatis.db file in /usr/share/man and have appropos read that
one file to find it's information.
B> Create multiple whatis.db files in the various man roots and have apropos
search for those. (our default man.conf allready handles this)
I like to be able to look up all my pages.. and it doesn't really matter to
me which method we use.. It's a bit simpler to simply deal with one whatis.db
file, and the search is probably faster from apropos's point of view than to have
to open 3-4 different files up.
>How-To-Repeat:
install a pkg. Type man -k "pkgname" and be dissapointed.
run /usr/libexec/makewhatis and be more disappointed.
>Fix:
The following replacement for makewhatis will do what I proposed above in
A. It parses the owner's MANPATH and creats a whatis.db based on that. It also
provides a few hooks for local hacks, in that the makewhatis.sed, and getNAME
file can be easily replaced by modifying the variables at the top. If the
consensus is that we would prefer "B".. I will gladly implement such a device,
and put it up..
#! /bin/sh -x
#
# $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. <garbled@garbled.net>
#
# 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.
#
# this relies on $MANDIR containing the manpath,
# ie /usr/share/man:/usr/local/man, 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$$
# where to put the completed man file:
WHATLOC=/usr/share/man
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=`echo $MANDIR | sed 's/:/ /g'`
for TMPDIR in $MANX
do
if test ! -d "${DESTDIR}$TMPDIR"; then
echo "makewhatis: ${DESTDIR}$TMPDIR: not a directory"
exit 1
fi
done
# now make the list.
touch $LIST
for TMPDIR in $MANX
do
find ${DESTDIR}$TMPDIR \( -type f -o -type l \) -name '*.[0-9]*' -ls | \
sort -n | awk '{if (u[$1]) next; u[$1]++ ; print $11}' >> $LIST
done
# Ok.. this is the tough part.. do the sed, and related hashing.
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 "$WHATLOC/whatis.db"
rm -f $LIST $TMP
exit 0
>Audit-Trail:
>Unformatted: