Use /etc/locate.conf for configuration, per discussion at tech-userlevel.

This commit is contained in:
itohy 2004-02-06 14:29:51 +00:00
parent 13057976a6
commit 0822f845c4
1 changed files with 85 additions and 12 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: updatedb.sh,v 1.7 2002/05/05 07:27:35 kim Exp $
# $NetBSD: updatedb.sh,v 1.8 2004/02/06 14:29:51 itohy Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
@ -39,12 +39,93 @@
# @(#)updatedb.csh 8.4 (Berkeley) 10/27/94
#
SRCHPATHS="/" # directories to be put in the database
LIBDIR="/usr/libexec" # for subprograms
# for temp files
TMPDIR=/tmp
FCODES="/var/db/locate.database" # the database
CONF=/etc/locate.conf # configuration file
PATH="/bin:/usr/bin"
ignorefs_default='! -fstype local -o -fstype cd9660 -o -fstype fdesc -o -fstype kernfs -o -fstype procfs'
ignorefs=unset
ignore=
SRCHPATHS=
# read configuration file
if [ -f "$CONF" ]; then
exec 5<&0 < "$CONF"
while read com args; do
case "$com/$args" in /) continue;; esac # skip blank lines
case "$com" in
'#'*) ;; # lines start with # is comment
searchpath)
SRCHPATHS="$SRCHPATHS $args";;
ignorefs)
for i in $args; do
case "$args" in
none) ignorefs=;;
*) fs=`echo "$i" | sed -e 's/^!/! -fstype /' -e t -e 's/^/-fstype /'`
case "$ignorefs" in
''|unset)
ignorefs="$fs";;
*) ignorefs="$ignorefs -o $fs";;
esac;;
esac
done;;
ignore)
set -f
for i in $args; do
case "$ignore" in
'') ;;
*) ignore="$ignore -o";;
esac
ignore="$ignore -path $i"
done
set +f;;
ignorecontents)
set -f
for i in $args; do
case "$ignore" in
'') ;;
*) ignore="$ignore -o";;
esac
ignore="$ignore -path $i -print"
done
set +f;;
workdir)
if [ -d "$args" ]; then
TMPDIR="$args"
else
echo "$CONF: workdir: $args nonexistent" >&2
fi;;
*)
echo "$CONF: $com: unknown config command" >&2
exit 1;;
esac
done
exec <&5 5>&-
fi
# default value when "ignorefs" is absent
case "$ignorefs" in
unset) ignorefs=$ignorefs_default;;
esac
: ${SRCHPATHS:=/} # directories to be put in the database
export TMPDIR
case "$ignorefs/$ignore" in
/) lp= ; rp= ;;
*) lp='('; rp=') -prune -o' ;;
esac
# insert '-o' if neither $ignorefs or $ignore are empty
case "$ignorefs $ignore" in
' '*|*' ') ;;
*) ignore="-o $ignore";;
esac
FILELIST=`mktemp -t locate.list` || exit 1
trap "rm -f '$FILELIST'" EXIT
trap "rm -f '$FILELIST'; exit 1" INT QUIT TERM
@ -52,16 +133,8 @@ trap "rm -f '$FILELIST'; exit 1" INT QUIT TERM
# Make a file list and compute common bigrams.
# Entries of each directory shall be sorted (find -s).
# search locally or everything
# find -s $SRCHPATHS -print \
find -s $SRCHPATHS \( \
! -fstype local \
-o -fstype cd9660 \
-o -fstype fdesc \
-o -fstype kernfs \
-o -fstype procfs \
\) -a -prune -o -print \
>> "$FILELIST"
set -f
find -s ${SRCHPATHS} $lp $ignorefs $ignore $rp -print >> "$FILELIST"
BIGRAMS=`$LIBDIR/locate.bigram <"$FILELIST"`