diff options
-rw-r--r-- | usr.bin/locate/locate/Makefile | 8 | ||||
-rw-r--r-- | usr.bin/locate/locate/concatdb.sh | 51 | ||||
-rw-r--r-- | usr.bin/locate/locate/locate.updatedb.8 | 58 | ||||
-rw-r--r-- | usr.bin/locate/locate/mklocatedb.sh | 54 | ||||
-rw-r--r-- | usr.bin/locate/locate/updatedb.sh | 64 |
5 files changed, 231 insertions, 4 deletions
diff --git a/usr.bin/locate/locate/Makefile b/usr.bin/locate/locate/Makefile index f7b55ded607..20d8d374bd8 100644 --- a/usr.bin/locate/locate/Makefile +++ b/usr.bin/locate/locate/Makefile @@ -1,12 +1,12 @@ -# $OpenBSD: Makefile,v 1.4 1996/08/17 04:45:40 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 1996/08/17 09:37:45 michaels Exp $ # # @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $Id: Makefile,v 1.4 1996/08/17 04:45:40 deraadt Exp $ +# $Id: Makefile,v 1.5 1996/08/17 09:37:45 michaels Exp $ PROG= locate -MAN= locate.1 #locate.updatedb.8 +MAN= locate.1 locate.updatedb.8 SCRIPTS= updatedb mklocatedb concatdb -#MLINKS+= locate.updatedb.8 updatedb.8 +MLINKS+= locate.updatedb.8 updatedb.8 LIBEXECDIR=/usr/libexec beforeinstall: diff --git a/usr.bin/locate/locate/concatdb.sh b/usr.bin/locate/locate/concatdb.sh new file mode 100644 index 00000000000..f25fc6e9a1b --- /dev/null +++ b/usr.bin/locate/locate/concatdb.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# $OpenBSD: concatdb.sh,v 1.1 1996/08/17 09:37:46 michaels Exp $ +# +# (c) Wolfram Schneider, Berlin. September 1995. Public domain. +# +# concatdb - concatenate locate databases +# +# usage: concatdb database1 ... databaseN > newdb +# +# Sequence of databases is important. +# +# $Id: concatdb.sh,v 1.1 1996/08/17 09:37:46 michaels Exp $ + +# The directory containing locate subprograms +: ${LIBEXECDIR=/usr/libexec}; export LIBEXECDIR + +PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH + +umask 077 # protect temp files + +: ${TMPDIR=/tmp}; export TMPDIR; +if test X"$TMPDIR" = X -o ! -d "$TMPDIR"; then + TMPDIR=/tmp; export TMPDIR +fi + +# utilities to built locate database +: ${bigram=locate.bigram} +: ${code=locate.code} +: ${sort=sort} + + +case $# in + [01]) echo 'usage: concatdb databases1 ... databaseN > newdb' + exit 1 + ;; +esac + + +bigrams=$TMPDIR/_concatdb$$.bigrams +trap 'rm -f $bigrams' 0 1 2 3 5 10 15 + +for db +do + $locate -d $db / +done | $bigram | $sort -nr | awk 'NR <= 128 { printf $2 }' > $bigrams + +for db +do + $locate -d $db / +done | $code $bigrams diff --git a/usr.bin/locate/locate/locate.updatedb.8 b/usr.bin/locate/locate/locate.updatedb.8 new file mode 100644 index 00000000000..eeaa9c00621 --- /dev/null +++ b/usr.bin/locate/locate/locate.updatedb.8 @@ -0,0 +1,58 @@ +.\" Copyright (c) 1996 +.\" Mike Pritchard <mpp@FreeBSD.org>. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Mike Pritchard. +.\" 4. Neither the name of the author nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd February 11, 1996 +.Dt LOCATE.UPDATEDB 8 +.Os BSD 4.4 +.Sh NAME +.Nm locate.updatedb +.Nd update locate database +.Sh SYNOPSIS +.Nm /usr/libexec/locate.updatedb +.Sh DESCRIPTION +.Nm Locate.updatedb +updates the database used by +.Xr locate 1 . +It is typically run once a week by the +.Nm /etc/weekly script. +.Sh FILES +.Bl -tag -width /var/db/locate.database -compact +.It Pa /var/db/locate.database the actual database +.El +.Sh SEE ALSO +.Xr locate 1 +.Rs +.%A Woods, James A. +.%D 1983 +.%T "Finding Files Fast" +.%J ";login" +.%V 8:1 +.%P pp. 8-10 +.Re diff --git a/usr.bin/locate/locate/mklocatedb.sh b/usr.bin/locate/locate/mklocatedb.sh new file mode 100644 index 00000000000..4ea9c8e1575 --- /dev/null +++ b/usr.bin/locate/locate/mklocatedb.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# $OpenBSD: mklocatedb.sh,v 1.1 1996/08/17 09:37:46 michaels Exp $ +# +# (c) Wolfram Schneider, September 1995. Public domain. +# +# mklocatedb - build locate database +# +# usage: mklocatedb [-presort] < filelist > database +# +# $Id: mklocatedb.sh,v 1.1 1996/08/17 09:37:46 michaels Exp $ + + +# The directory containing locate subprograms +: ${LIBEXECDIR=/usr/libexec}; export LIBEXECDIR + +PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH + +umask 077 # protect temp files + +: ${TMPDIR=/tmp}; export TMPDIR; +if test X"$TMPDIR" = X -o ! -d "$TMPDIR"; then + TMPDIR=/tmp; export TMPDIR +fi + +# utilities to built locate database +: ${bigram=locate.bigram} +: ${code=locate.code} +: ${sort=sort} + + +sortopt="-u -T $TMPDIR" +sortcmd=$sort + +# Input already sorted +case X"$1" in + X-nosort|X-presort) sortcmd=cat; sortopt=;shift;; +esac + + +bigrams=$TMPDIR/_mklocatedb$$.bigrams +filelist=$TMPDIR/_mklocatedb$$.list + +trap 'rm -f $bigrams $filelist' 0 1 2 3 5 10 15 + + +if $sortcmd $sortopt > $filelist; then + $bigram < $filelist | $sort -nr | + awk 'NR <= 128 { printf $2 }' > $bigrams && + $code $bigrams < $filelist +else + echo "`basename $0`: cannot build locate database" >&2 + exit 1 +fi diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh new file mode 100644 index 00000000000..e303b213257 --- /dev/null +++ b/usr.bin/locate/locate/updatedb.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# +# $OpenBSD: updatedb.sh,v 1.1 1996/08/17 09:37:47 michaels Exp $ +# +# (c) Wolfram Schneider, Berlin. September 1995. Public domain. +# +# updatedb - update locate database for local mounted filesystems +# +# $Id: updatedb.sh,v 1.1 1996/08/17 09:37:47 michaels Exp $ + +LOCATE_CONFIG="/etc/locate.rc" +if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then + . $LOCATE_CONFIG +fi + +# The directory containing locate subprograms +: ${LIBEXECDIR=/usr/libexec}; export LIBEXECDIR + +PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH + + +: ${mklocatedb=locate.mklocatedb} # make locate database program +: ${FCODES=/var/db/locate.database} # the database +: ${SEARCHPATHS="/"} # directories to be put in the database +: ${PRUNEPATHS="/tmp /usr/tmp /var/tmp"} # unwanted directories +: ${FILESYSTEMS="ufs"} # allowed filesystems +: ${find=find} + +case X"$SEARCHPATHS" in + X) echo "$0: empty variable SEARCHPATHS"; exit 1;; esac +case X"$FILESYSTEMS" in + X) echo "$0: empty variable FILESYSTEMS"; exit 1;; esac + +# Make a list a paths to exclude in the locate run +excludes="! (" or="" +for fstype in $FILESYSTEMS +do + excludes="$excludes $or -fstype $fstype" + or="-or" +done +excludes="$excludes ) -prune" + +case X"$PRUNEPATHS" in + X) ;; + *) for path in $PRUNEPATHS + do + excludes="$excludes -or -path $path -prune" + done;; +esac + +tmp=${TMPDIR=/tmp}/_updatedb$$ +trap 'rm -f $tmp' 0 1 2 3 5 10 15 + +# search locally +# echo $find $SEARCHPATHS $excludes -or -print && exit +if $find $SEARCHPATHS $excludes -or -print 2>/dev/null | + $mklocatedb > $tmp +then + case X"`$find $tmp -size -257c -print`" in + X) cat $tmp > $FCODES;; + *) echo "updatedb: locate database $tmp is empty" + exit 1 + esac +fi |