NetBSD/libexec/makewhatis/makewhatis.sh

51 lines
1.1 KiB
Bash
Raw Normal View History

#! /bin/sh
#
1998-03-22 02:46:00 +03:00
# $NetBSD: makewhatis.sh,v 1.13 1998/03/21 23:46:00 tron Exp $
1998-01-09 11:03:16 +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>.
#
# Public domain.
#
LIST=/tmp/makewhatislist$$
TMP=/tmp/whatis$$
trap "rm -f $LIST $TMP; exit 1" 1 2 15
MANDIR=${1-/usr/share/man}
1998-03-22 02:46:00 +03:00
if test ! -d "${DESTDIR}$MANDIR"; then
echo "makewhatis: ${DESTDIR}$MANDIR: not a directory"
exit 1
fi
1998-03-22 02:46:00 +03:00
find ${DESTDIR}$MANDIR \( -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 /usr/libexec/getNAME | \
sed -e 's/ [a-zA-Z0-9]* \\-/ -/' > $TMP
egrep '\.0$' $LIST | while read file
do
1998-03-22 02:46:00 +03:00
sed -n -f ${DESTDIR}/usr/share/man/makewhatis.sed $file;
done >> $TMP
egrep '\.[0].(gz|Z)$' $LIST | while read file
do
1998-03-22 02:46:00 +03:00
gzip -fdc $file | sed -n -f ${DESTDIR}/usr/share/man/makewhatis.sed;
done >> $TMP
sort -u -o $TMP $TMP
make -f - install <<_Install_Whatis_Db_
FILES=$TMP
FILESDIR=$MANDIR
FILESNAME=whatis.db
NOOBJ=noobj
.include <bsd.prog.mk>
_Install_Whatis_Db_
rm -f $LIST $TMP
exit 0