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%/bar%g'" 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.2.15.orig/doc/find.texi findutils-4.2.15/doc/find.texi --- findutils-4.2.15.orig/doc/find.texi 2005-01-28 00:16:50.000000000 +0100 +++ findutils-4.2.15/doc/find.texi 2005-01-31 13:20:49.000000000 +0100 @@ -2788,6 +2788,12 @@ non-ASCII characters in filenames (that is, filenames containing characters which have the eighth bit set, such as many of the characters from the ISO-8859-1 character set). + address@hidden address@hidden +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%/bar%g'"} when +building the database on the server. Default is no filter. @item --help Print a summary of the command-line argument format and exit. @item --version diff -ur -x Makefile.in -x aclocal.m4 -x autom4te.cache -x configure findutils-4.2.15.orig/locate/updatedb.1 findutils-4.2.15/locate/updatedb.1 --- findutils-4.2.15.orig/locate/updatedb.1 2004-11-08 01:45:43.000000000 +0100 +++ findutils-4.2.15/locate/updatedb.1 2005-01-31 13:21:33.000000000 +0100 @@ -84,6 +84,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%/bar%g'"\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.2.15.orig/locate/updatedb.sh findutils-4.2.15/locate/updatedb.sh --- findutils-4.2.15.orig/locate/updatedb.sh 2005-01-23 18:19:16.000000000 +0100 +++ findutils-4.2.15/locate/updatedb.sh 2005-01-31 13:18:58.000000000 +0100 @@ -24,7 +24,7 @@ [--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 ." changeto=/ @@ -46,6 +46,7 @@ --output) LOCATE_DB="$val" ;; --netuser) NETUSER="$val" ;; --localuser) LOCALUSER="$val" ;; + --pathfilter) PATHFILTER="$val" ;; --old-format) old=yes ;; --changecwd) changeto="$val" ;; --version) echo "GNU updatedb version @VERSION@"; exit 0 ;; @@ -191,7 +192,13 @@ exit $? fi fi -} | $sort -f | $frcode $frcode_options > $LOCATE_DB.n +} | { +if test -n "$PATHFILTER"; then + $PATHFILTER | $sort -f +else + $sort -f +fi +} | $frcode $frcode_options > $LOCATE_DB.n then # OK so far true @@ -205,8 +212,12 @@ # 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 @@ -261,7 +272,13 @@ exit $? 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 $bigram_opts < $filelist | sort | uniq -c | sort -nr |