1#!/bin/csh -f
2#
3# Copyright (c) 1989, 1993
4#	The Regents of the University of California.  All rights reserved.
5#
6# This code is derived from software contributed to Berkeley by
7# James A. Woods.
8#
9# %sccs.include.redist.sh%
10#
11#	@(#)updatedb.csh	8.1 (Berkeley) 06/06/93
12#
13
14set SRCHPATHS = "/"			# directories to be put in the database
15set LIBDIR = /usr/libexec		# for subprograms
16if (! $?TMPDIR) set TMPDIR = /var/tmp	# for temp files
17set FCODES = /var/db/locate.database	# the database
18
19set path = ( /bin /usr/bin )
20set bigrams = $TMPDIR/locate.bigrams.$$
21set filelist = $TMPDIR/locate.list.$$
22set errs = $TMPDIR/locate.errs.$$
23
24# Make a file list and compute common bigrams.
25# Alphabetize '/' before any other char with 'tr'.
26# If the system is very short of sort space, 'bigram' can be made
27# smarter to accumulate common bigrams directly without sorting
28# ('awk', with its associative memory capacity, can do this in several
29# lines, but is too slow, and runs out of string space on small machines).
30
31# search locally or everything
32# find ${SRCHPATHS} -print | \
33find ${SRCHPATHS} \! -fstype local -prune -or -print | \
34	tr '/' '\001' | \
35	(sort -T /var/tmp -f; echo $status > $errs) | tr '\001' '/' > $filelist
36
37$LIBDIR/locate.bigram < $filelist | \
38	(sort -T /var/tmp; echo $status >> $errs) | \
39	uniq -c | sort -T /var/tmp -nr | \
40	awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
41
42# code the file list
43
44if { grep -s -v 0 $errs } then
45	printf 'locate: updatedb failed\n\n'
46else
47	$LIBDIR/locate.code $bigrams < $filelist > $FCODES
48	chmod 644 $FCODES
49	rm $bigrams $filelist $errs
50endif
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79