From 8717623f081eb63ad3851cf68c521cc40e420ec2 Mon Sep 17 00:00:00 2001 From: jay Date: Sat, 2 Oct 2004 13:07:19 +0000 Subject: [PATCH] Added new option --changecwd to updatedb so that the 'cd /' which it does can be compatible with the requirements of the test suite. Specifically, the test suite relies on being able to use relative pathnames --- locate/testsuite/config/unix.exp | 12 ++++++++++-- locate/testsuite/locate.gnu/ignore_case1.exp | 11 ++++++----- locate/testsuite/locate.gnu/ignore_case3.exp | 11 ++++++----- locate/updatedb.sh | 19 ++++++++++++++----- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/locate/testsuite/config/unix.exp b/locate/testsuite/config/unix.exp index 7b7a1c0..ae7a993 100644 --- a/locate/testsuite/config/unix.exp +++ b/locate/testsuite/config/unix.exp @@ -23,9 +23,15 @@ # use the local version of find for updatedb -set env(find) ../../find/find +# +# We normalise (normalize for those over the water) pathnames +# because the updatedb shell script uses "cd", which means that +# any relative paths no longer point where we thought they did. +set env(find) [file normalize "../../find/find"] + # use the local help commands for updatedb -set env(LIBEXECDIR) .. +set env(LIBEXECDIR) [file normalize .. ] + # do not ignore any file systems for this test set env(PRUNEFS) "" global UPDATEDB @@ -144,6 +150,8 @@ proc locate_start { passfail updatedb_options locate_options send_log "$cmp_cmd\n" catch "exec $cmp_cmd" cmpout if {$cmpout != ""} then { + #catch "exec diff locate.out $outfile" diffout + #puts $diffout fail "$testname, $cmpout" return } diff --git a/locate/testsuite/locate.gnu/ignore_case1.exp b/locate/testsuite/locate.gnu/ignore_case1.exp index b1e5ffe..0cc4369 100644 --- a/locate/testsuite/locate.gnu/ignore_case1.exp +++ b/locate/testsuite/locate.gnu/ignore_case1.exp @@ -1,7 +1,8 @@ # tests to determine if "-i" causes the match to ignore the case -exec rm -rf tmp -exec mkdir tmp -exec mkdir tmp/subdir -exec touch tmp/subdir/fred -locate_start p {--output=tmp/locatedb --localpaths=tmp/subdir/} {--database=tmp/locatedb -i FRed} {} +set tmp "tmp" +exec rm -rf $tmp +exec mkdir $tmp +exec mkdir $tmp/subdir +exec touch $tmp/subdir/fred +locate_start p "--changecwd=. --output=$tmp/locatedb --localpaths=tmp/subdir/" "--database=$tmp/locatedb -i FRed" {} diff --git a/locate/testsuite/locate.gnu/ignore_case3.exp b/locate/testsuite/locate.gnu/ignore_case3.exp index b84c2a2..cf2dc01 100644 --- a/locate/testsuite/locate.gnu/ignore_case3.exp +++ b/locate/testsuite/locate.gnu/ignore_case3.exp @@ -1,9 +1,10 @@ # tests to determine if "-i" causes the match to ignore the case -exec rm -rf tmp -exec mkdir tmp -exec mkdir tmp/subdir -exec touch tmp/subdir/fred -locate_start p {--output=tmp/locatedb --localpaths=tmp/subdir/} {--database=tmp/locatedb fred} {} +set tmp "tmp" +exec rm -rf $tmp +exec mkdir $tmp +exec mkdir $tmp/subdir +exec touch $tmp/subdir/fred +locate_start p {--changecwd=. --output=tmp/locatedb --localpaths=tmp/subdir/} {--database=tmp/locatedb fred} {} #updatedb --output=locatedb #locate --database=locatedb FRed #locate --database=locatedb -i FRed diff --git a/locate/updatedb.sh b/locate/updatedb.sh index 06c3098..9db2ff9 100644 --- a/locate/updatedb.sh +++ b/locate/updatedb.sh @@ -27,7 +27,7 @@ Usage: updatedb [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...'] Report bugs to . " - +changeto=/ old=no for arg do @@ -46,6 +46,7 @@ do --netuser) NETUSER="$val" ;; --localuser) LOCALUSER="$val" ;; --old-format) old=yes ;; + --changecwd) changeto="$val" ;; --version) echo "GNU updatedb version @VERSION@"; exit 0 ;; --help) echo "$usage"; exit 0 ;; *) echo "updatedb: invalid option $opt @@ -94,10 +95,18 @@ export TMPDIR : ${NETUSER=daemon} # The directory containing the subprograms. -: ${LIBEXECDIR=@libexecdir@} +if test -n "$LIBEXECDIR" ; then + : LIBEXECDIR already set, do nothing +else + : ${LIBEXECDIR=@libexecdir@} +fi # The directory containing find. -: ${BINDIR=@bindir@} +if test -n "$BINDIR" ; then + : BINDIR already set, do nothing +else + : ${BINDIR=@bindir@} +fi # The names of the utilities to run to build the database. : ${find:=${BINDIR}/@find@} @@ -126,7 +135,7 @@ if test $old = no; then # FIXME figure out how to sort null-terminated strings, and use -print0. if { -cd / +cd "$changeto" if test -n "$SEARCHPATHS"; then if [ "$LOCALUSER" != "" ]; then # : A1 @@ -196,7 +205,7 @@ trap 'rm -f $bigrams $filelist $LOCATE_DB.n; exit' 1 15 # "to get everything in monotonic collating sequence, to avoid some # breakage i'll have to think about." { -cd / +cd "$changeto" if test -n "$SEARCHPATHS"; then if [ "$LOCALUSER" != "" ]; then # : A5 -- 2.11.4.GIT