Module Name:    src
Committed By:   simonb
Date:           Thu Feb  6 08:45:44 UTC 2020

Modified Files:
        src/usr.bin/locate/locate: locate.updatedb.8 updatedb.sh

Log Message:
Add support for specifying an alternate locate.updatedb config file.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/locate/locate/locate.updatedb.8
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/locate/locate/updatedb.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/locate/locate/locate.updatedb.8
diff -u src/usr.bin/locate/locate/locate.updatedb.8:1.3 src/usr.bin/locate/locate/locate.updatedb.8:1.4
--- src/usr.bin/locate/locate/locate.updatedb.8:1.3	Mon Sep 22 13:10:25 2008
+++ src/usr.bin/locate/locate/locate.updatedb.8	Thu Feb  6 08:45:44 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: locate.updatedb.8,v 1.3 2008/09/22 13:10:25 hubertf Exp $
+.\"	$NetBSD: locate.updatedb.8,v 1.4 2020/02/06 08:45:44 simonb Exp $
 .\"
 .\" Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 5, 2005
+.Dd February 6, 2020
 .Dt LOCATE.UPDATEDB 8
 .Os
 .Sh NAME
@@ -35,6 +35,7 @@
 .Nd update locate database
 .Sh SYNOPSIS
 .Nm /usr/libexec/locate.updatedb
+.Op Fl c Ar file
 .Sh DESCRIPTION
 The
 .Nm
@@ -46,6 +47,19 @@ It is usually run once per week, see
 .Pp
 The file systems and files (not) scanned can be configured in
 .Xr locate.conf 5 .
+.Sh OPTIONS
+The
+.Nm
+program supports this option:
+.Bl -tag -width XcXfileXX
+.It Fl c Ar file
+Use
+.Ar file
+(in
+.Xr locate.conf 5
+format) as the configuration file instead of the default
+.Pa /etc/locate.conf .
+.El
 .Sh FILES
 .Bl -tag -width /usr/libexec/locate.updatedb -compact
 .It Pa /var/db/locate.database

Index: src/usr.bin/locate/locate/updatedb.sh
diff -u src/usr.bin/locate/locate/updatedb.sh:1.15 src/usr.bin/locate/locate/updatedb.sh:1.16
--- src/usr.bin/locate/locate/updatedb.sh:1.15	Mon Aug  4 21:56:30 2014
+++ src/usr.bin/locate/locate/updatedb.sh	Thu Feb  6 08:45:44 2020
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#	$NetBSD: updatedb.sh,v 1.15 2014/08/04 21:56:30 apb Exp $
+#	$NetBSD: updatedb.sh,v 1.16 2020/02/06 08:45:44 simonb Exp $
 #
 # Copyright (c) 1989, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -40,10 +40,9 @@
 #
 
 LIBDIR="/usr/libexec"			# for subprograms
-					# for temp files
-TMPDIR=/tmp
+TMPDIR="/tmp"				# for temp files
 FCODES="/var/db/locate.database"	# the database
-CONF=/etc/locate.conf			# configuration file
+CONF="/etc/locate.conf"			# configuration file
 
 PATH="/bin:/usr/bin"
 
@@ -97,6 +96,26 @@ shell_quote()
 	printf "%s\n" "$result"
 )}
 
+args=`getopt c: $*`
+if [ $? -ne 0 ]; then
+	progname=`basename $0`
+	echo 'Usage: ...'
+	echo "usage: ${progname} [-c config]"
+	exit 2
+fi
+set -- $args
+while [ $# -gt 0 ]; do
+	case "$1" in
+		-c)
+			CONF=$2; shift
+			;;
+		--)
+			shift; break
+			;;
+	esac
+	shift
+done
+
 # read configuration file
 if [ -f "$CONF" ]; then
 	while read -r com args; do
@@ -149,6 +168,13 @@ if [ -f "$CONF" ]; then
 				echo "$CONF: workdir: $1 nonexistent" >&2
 			fi
 			;;
+		database)
+			if [ $# -ne 1 ]; then
+				echo "$CONF: database takes exactly one argument" >&2
+			else
+				FCODES="$1"
+			fi
+			;;
 		*)
 			echo "$CONF: $com: unknown config command" >&2
 			exit 1

Reply via email to