1993-12-21 06:28:00 +03:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
1999-03-30 07:17:26 +04:00
|
|
|
# $NetBSD: makewhatis.sh,v 1.18 1999/03/30 03:17:26 cjs Exp $
|
1998-01-09 11:03:16 +03:00
|
|
|
#
|
1997-11-01 18:06:09 +03:00
|
|
|
# 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>.
|
1997-08-04 07:01:59 +04:00
|
|
|
#
|
1995-05-12 03:03:44 +04:00
|
|
|
# Public domain.
|
1993-12-21 06:28:00 +03:00
|
|
|
#
|
|
|
|
|
1997-11-01 18:06:09 +03:00
|
|
|
LIST=/tmp/makewhatislist$$
|
|
|
|
TMP=/tmp/whatis$$
|
1997-11-02 04:26:10 +03:00
|
|
|
trap "rm -f $LIST $TMP; exit 1" 1 2 15
|
|
|
|
|
|
|
|
MANDIR=${1-/usr/share/man}
|
1998-05-21 15:40:11 +04:00
|
|
|
if test ! -d "$MANDIR"; then
|
|
|
|
echo "makewhatis: $MANDIR: not a directory"
|
1993-12-21 06:28:00 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1998-05-23 17:42:25 +04:00
|
|
|
if test -f $MANDIR/makewhatis.sed; then
|
|
|
|
MKWHATIS=$MANDIR/makewhatis.sed
|
|
|
|
elif test -f $DESTDIR/usr/share/man/makewhatis.sed; then
|
|
|
|
MKWHATIS=$DESTDIR/usr/share/man/makewhatis.sed
|
|
|
|
elif test -f /usr/share/man/makewhatis.sed; then
|
|
|
|
MKWHATIS=/usr/share/man/makewhatis.sed
|
|
|
|
else
|
|
|
|
echo Cannot find makewhatis.sed; exit 1
|
|
|
|
fi
|
|
|
|
|
1998-05-21 15:40:11 +04:00
|
|
|
find $MANDIR \( -type f -o -type l \) -name '*.[0-9]*' -ls | \
|
1997-11-02 17:01:54 +03:00
|
|
|
sort -n | awk '{if (u[$1]) next; u[$1]++ ; print $11}' > $LIST
|
|
|
|
|
|
|
|
egrep '\.[1-9]$' $LIST | xargs /usr/libexec/getNAME | \
|
1997-11-18 10:17:09 +03:00
|
|
|
sed -e 's/ [a-zA-Z0-9]* \\-/ -/' > $TMP
|
1997-11-01 18:06:09 +03:00
|
|
|
|
1998-05-23 18:26:05 +04:00
|
|
|
egrep '\.[1-9].(gz|Z)$' $LIST | while read file
|
|
|
|
do
|
|
|
|
gzip -fdc $file | nroff -man | \
|
|
|
|
sed -n -f $MKWHATIS;
|
|
|
|
done >> $TMP
|
|
|
|
|
1997-11-01 18:06:09 +03:00
|
|
|
egrep '\.0$' $LIST | while read file
|
1993-12-21 06:28:00 +03:00
|
|
|
do
|
1998-05-23 17:42:25 +04:00
|
|
|
sed -n -f $MKWHATIS $file;
|
1997-11-18 10:17:09 +03:00
|
|
|
done >> $TMP
|
1994-03-19 11:09:16 +03:00
|
|
|
|
1997-11-01 18:06:09 +03:00
|
|
|
egrep '\.[0].(gz|Z)$' $LIST | while read file
|
1994-03-19 11:09:16 +03:00
|
|
|
do
|
1998-05-23 18:26:05 +04:00
|
|
|
gzip -fdc $file | sed -n -f $MKWHATIS;
|
1997-11-01 18:06:09 +03:00
|
|
|
done >> $TMP
|
1994-03-19 11:09:16 +03:00
|
|
|
|
1997-11-02 04:26:10 +03:00
|
|
|
sort -u -o $TMP $TMP
|
1993-12-21 06:28:00 +03:00
|
|
|
|
1999-03-30 07:17:26 +04:00
|
|
|
make -f - DESTDIR="" install <<_Install_Whatis_Db_
|
1998-02-09 04:34:57 +03:00
|
|
|
FILES=$TMP
|
|
|
|
FILESDIR=$MANDIR
|
|
|
|
FILESNAME=whatis.db
|
|
|
|
NOOBJ=noobj
|
|
|
|
|
|
|
|
.include <bsd.prog.mk>
|
|
|
|
_Install_Whatis_Db_
|
|
|
|
|
1997-11-02 04:26:10 +03:00
|
|
|
rm -f $LIST $TMP
|
1993-12-21 06:28:00 +03:00
|
|
|
exit 0
|