Apart from a trivial bugfix in configure.in (leading to a spurious error message during configure), this patch introduces an option '--pathfilter=filter' for updatedb. If a filesystem is, e.g. mounted on a fileserver as /mnt/foo but accessed on clients as /bar one could specify --pathfilter="sed -e 's%^/mnt/foo%/bar0'" when building the database on the server. Default is no filter. diff -ur -x Makefile.in -x aclocal.m4 -x autom4te.cache -x configure findutils-4.1.20.orig/configure.in findutils-4.1.20/configure.in --- findutils-4.1.20.orig/configure.in 2003-05-26 20:16:09.000000000 +0200 +++ findutils-4.1.20/configure.in 2003-05-29 14:38:24.000000000 +0200 @@ -96,8 +96,6 @@ AC_FUNC_GETMNTENT AC_FUNC_CLOSEDIR_VOID -gl_XALLOC - dnl internationalization macros AM_GNU_GETTEXT diff -ur -x Makefile.in -x aclocal.m4 -x autom4te.cache -x configure findutils-4.1.20.orig/doc/find.texi findutils-4.1.20/doc/find.texi --- findutils-4.1.20.orig/doc/find.texi 2001-05-20 21:45:13.000000000 +0200 +++ findutils-4.1.20/doc/find.texi 2003-05-29 14:50:19.000000000 +0200 @@ -1898,6 +1898,12 @@ The user to search network directories as, using @code{su}. Default is @code{daemon}. You can also use the environment variable @code{NETUSER} to set this user. + +@item --pathfilter=@var{filter} +A filter to transform pathnames. If a filesystem is, e.g. mounted on a +fileserver as @file{/mnt/foo} but accessed on clients as @file{/bar} one +could specify @code{--pathfilter="sed -e 's%^/mnt/foo%/bar0'"} when +building the database on the server. Default is no filter. @end table @node Database Formats diff -ur -x Makefile.in -x aclocal.m4 -x autom4te.cache -x configure findutils-4.1.20.orig/locate/updatedb.1 findutils-4.1.20/locate/updatedb.1 --- findutils-4.1.20.orig/locate/updatedb.1 1998-11-28 18:29:39.000000000 +0100 +++ findutils-4.1.20/locate/updatedb.1 2003-05-29 14:52:36.000000000 +0200 @@ -79,6 +79,12 @@ Default is \fBdaemon\fP. You can also use the environment variable \fBNETUSER\fP to set this user. .TP +.B \-\-pathfilter=\fIfilter\fP +A filter to transform pathnames. If a filesystem is, e.g. mounted on a +fileserver as \fB/mnt/foo\fP but accessed on clients as \fB/bar\fP one could +specify \fB\-\-pathfilter="sed \-e 's%^/mnt/foo%/bar0'"\fP when building the +database on the server. Default is no filter. +.TP .B \-\-old\-format Create the database in the old format instead of the new one. .TP diff -ur -x Makefile.in -x aclocal.m4 -x autom4te.cache -x configure findutils-4.1.20.orig/locate/updatedb.sh findutils-4.1.20/locate/updatedb.sh --- findutils-4.1.20.orig/locate/updatedb.sh 2003-05-24 20:36:25.000000000 +0200 +++ findutils-4.1.20/locate/updatedb.sh 2003-05-29 14:59:35.000000000 +0200 @@ -23,7 +23,7 @@ Usage: updatedb [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...'] [--prunepaths='dir1 dir2...'] [--prunefs='fs1 fs2...'] [--output=dbfile] [--netuser=user] [--localuser=user] - [--old-format] [--version] [--help] + [--pathfilter=filter] [--old-format] [--version] [--help] Report bugs to <bug-findutils@gnu.org>. " @@ -41,6 +41,7 @@ --output) LOCATE_DB="$val" ;; --netuser) NETUSER="$val" ;; --localuser) LOCALUSER="$val" ;; + --pathfilter) PATHFILTER="$val" ;; --old-format) old=yes ;; --version) echo "GNU updatedb version @VERSION@"; exit 0 ;; --help) echo "$usage"; exit 0 ;; @@ -136,13 +137,23 @@ $find $NETPATHS \( -type d -regex "$PRUNEREGEX" -prune \) -o -print fi fi -} | sort -f | $frcode > $LOCATE_DB.n +} | { +if test -n "$PATHFILTER"; then + $PATHFILTER | sort -f +else + sort -f +fi +} | $frcode > $LOCATE_DB.n # To avoid breaking locate while this script is running, put the # results in a temp file, then rename it atomically. if test -s $LOCATE_DB.n; then - rm -f $LOCATE_DB - mv $LOCATE_DB.n $LOCATE_DB + # try atomic move first; mv may not have -f flag on some systems + mv -f $LOCATE_DB.n $LOCATE_DB >/dev/null 2>&1 || { + # for systems whose mv does not grok -f + rm -f $LOCATE_DB + mv $LOCATE_DB.n $LOCATE_DB + } chmod 644 $LOCATE_DB else echo "updatedb: new database would be empty" >&2 @@ -189,7 +200,13 @@ $find $NETPATHS \( -type d -regex "$PRUNEREGEX" -prune \) -o -print fi fi -} | tr / '\001' | sort -f | tr '\001' / > $filelist +} | { +if test -n "$PATHFILTER"; then + $PATHFILTER | tr / '\001' +else + tr / '\001' +fi +} | sort -f | tr '\001' / > $filelist # Compute the (at most 128) most common bigrams in the file list. $bigram < $filelist | sort | uniq -c | sort -nr |