]> git.pld-linux.org Git - packages/findutils.git/blob - findutils-mktemp.patch
- fixes for findutils.
[packages/findutils.git] / findutils-mktemp.patch
1 --- findutils-4.1/locate/updatedb.sh.mktemp     Mon Mar  2 18:02:21 1998
2 +++ findutils-4.1/locate/updatedb.sh    Mon Mar  2 18:40:06 1998
3 @@ -69,6 +69,12 @@
4    : ${TMPDIR=/usr/tmp}
5  fi
6  
7 +if test -x /bin/mktemp; then
8 +  : ${MKTEMP=/bin/mktemp}
9 +else
10 +  : ${MKTEMP=/bin/touch}
11 +fi
12 +
13  # The user to search network directories as.
14  : ${NETUSER=daemon}
15  
16 @@ -91,6 +97,11 @@
17  
18  if test $old = no; then
19  
20 +NEW_LOCATE_DB=`$MKTEMP $LOCATE_DB.n.XXXXXX` || {
21 +  echo "could not create temporary locate db" >&2
22 +  exit 1
23 +}
24 +
25  # FIXME figure out how to sort null-terminated strings, and use -print0.
26  {
27  if test -n "$SEARCHPATHS"; then
28 @@ -102,23 +113,27 @@
29    su $NETUSER -c \
30    "$find $NETPATHS \\( -type d -regex \"$PRUNEREGEX\" -prune \\) -o -print"
31  fi
32 -} | sort -f | $frcode > $LOCATE_DB.n
33 +} | sort -f | $frcode > $NEW_LOCATE_DB
34  
35  # To avoid breaking locate while this script is running, put the
36  # results in a temp file, then rename it atomically.
37 -if test -s $LOCATE_DB.n; then
38 -  rm -f $LOCATE_DB
39 -  mv $LOCATE_DB.n $LOCATE_DB
40 +if test -s $NEW_LOCATE_DB; then
41 +  # try atomic move first; mv may not have -f flag on some systems
42 +  mv -f $NEW_LOCATE_DB $LOCATE_DB >/dev/null 2>&1 || {
43 +    # for systems whose mv does not grok -f
44 +    rm -f $LOCATE_DB
45 +    mv $NEW_LOCATE_DB $LOCATE_DB
46 +  }
47    chmod 644 $LOCATE_DB
48  else
49    echo "updatedb: new database would be empty" >&2
50 -  rm -f $LOCATE_DB.n
51 +  rm -f $NEW_LOCATE_DB
52  fi
53  
54  else # old
55  
56 -bigrams=$TMPDIR/f.bigrams$$
57 -filelist=$TMPDIR/f.list$$
58 +bigrams=`$MKTEMP $TMPDIR/f.bigrams$$XXXXXX`
59 +filelist=`$MKTEMP $TMPDIR/f.list$$XXXXXX`
60  trap 'rm -f $bigrams $filelist; exit' 1 15
61  
62  # Alphabetize subdirectories before file entries using tr.  James says:
This page took 0.078086 seconds and 4 git commands to generate.