diff -ur -N findutils-4.4.0.orig/locate/updatedb.sh findutils-4.4.0/locate/updatedb.sh --- findutils-4.4.0.orig/locate/updatedb.sh 2008-02-09 11:11:43.000000000 +0100 +++ findutils-4.4.0/locate/updatedb.sh 2008-03-24 21:00:56.000000000 +0100 @@ -37,7 +37,8 @@ [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...'] [--prunepaths='dir1 dir2...'] [--prunefs='fs1 fs2...'] [--output=dbfile] [--netuser=user] [--localuser=user] - [--old-format] [--dbformat] [--version] [--help] + [--old-format] [--dbformat] [--relpath=pathprefix] + [--version] [--help] Report bugs to ." changeto=/ @@ -60,6 +61,7 @@ --netuser) NETUSER="$val" ;; --localuser) LOCALUSER="$val" ;; --old-format) old=yes ;; + --relpath) PATHPREFIX="$val";; --changecwd) changeto="$val" ;; --dbformat) dbformat="$val" ;; --version) fail=0; echo "$version" || fail=1; exit $fail ;; @@ -151,6 +153,53 @@ # What shell shoud we use? We should use a POSIX-ish sh. : ${SHELL="/bin/sh"} +# If --relpath was given, check parameters for consistency +if test -n "$PATHPREFIX" ; then + bad=no + case "$PATHPREFIX" in + "") $PATHPREFIX=. ;; + */) bad=yes ;; + *) test -d "$PATHPREFIX" || bad=yes ;; + esac + if test $bad = yes; then + echo "updatedb: invalid PATHPREFIX $PATHPREFIX + must be existing directory without trailing '/'" >&2 + exit 1 + fi + # We silently ignore the value given by (the undocumented) --changecwd + changeto="$PATHPREFIX" + if test "$old" = yes ; then + echo "updatedb: conflicting options --relpath and --old-format" >&2 + exit 1 + fi + frcode_options="$frcode_options -r" + if test -n "$NETPATHS" ; then + echo "updatedb: conflicting options --relpath and --netpaths" >&2 + exit 1 + fi + : ${LOCATE_DB=.locatedb} + case $LOCATE_DB in + */*) echo="updatedb: --output must specify a basename" >&2 + exit 1; + esac + LOCATE_DB="$PATHPREFIX/$LOCATE_DB" + : ${SEARCHPATHS="."} + if test "$SEARCHPATHS" != . ; then + NEWPATHS= + for p in $SEARCHPATHS ; do + case "$p" in + /*) echo "updatedb: invalid searchpath $p + --relpath requires relative paths" >&2 + exit 1;; + ./*) NEWPATHS="$NEWPATHS $p" ;; + *) NEWPATHS="$NEWPATHS ./$p" ;; + esac + done + SEARCHPATHS="$NEWPATHS" + fi + : ${PRUNEPATHS=} +fi + # Non-network directories to put in the database. : ${SEARCHPATHS="/"} @@ -165,7 +214,7 @@ # constructs. for p in $PRUNEPATHS; do case "$p" in - /*/) echo "$0: $p: pruned paths should not contain trailing slashes" >&2 + */) echo "$0: $p: pruned paths should not contain trailing slashes" >&2 exit 1 esac done