]> git.pld-linux.org Git - packages/findutils.git/blob - findutils-mktemp.patch
- some pld.org.pl->pld-linux.org cosmetics
[packages/findutils.git] / findutils-mktemp.patch
1 --- findutils-4.1.5/locate/updatedb.sh.wiget    Wed Feb 23 18:04:28 2000
2 +++ findutils-4.1.5/locate/updatedb.sh  Wed May 31 14:24:38 2000
3 @@ -74,6 +74,12 @@
4    : ${TMPDIR=/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 @@ -108,6 +114,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 @@ -131,33 +142,33 @@
29      $find $NETPATHS \( -type d -regex "$PRUNEREGEX" -prune \) -o -print
30    fi
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 +if test -s $NEW_LOCATE_DB; then
39    rm -f $LOCATE_DB
40 -  mv $LOCATE_DB.n $LOCATE_DB
41 +  mv $NEW_LOCATE_DB $LOCATE_DB
42    chmod 644 $LOCATE_DB
43  else
44    echo "updatedb: new database would be empty" >&2
45 -  rm -f $LOCATE_DB.n
46 +  rm -f $NEW_LOCATE_DB
47  fi
48  
49  else # old
50  
51 -if ! bigrams=`tempfile -p updatedb`; then
52 +if ! bigrams=`$MKTEMP $TMPDIR/f.bigrams$$XXXXXX`; then
53      echo tempfile failed
54      exit 1
55  fi
56  
57 -if ! filelist=`tempfile -p updatedb`; then
58 +if ! filelist=`$MKTEMP $TMPDIR/f.list$$XXXXXX`; then
59      echo tempfile failed
60      exit 1
61  fi
62  
63 -rm -f $LOCATE_DB.n
64 -trap 'rm -f $bigrams $filelist $LOCATE_DB.n; exit' 1 15
65 +rm -f $NEW_LOCATE_DB
66 +trap 'rm -f $bigrams $filelist $NEW_LOCATE_DB; exit' 1 15
67  
68  # Alphabetize subdirectories before file entries using tr.  James says:
69  # "to get everything in monotonic collating sequence, to avoid some
70 @@ -191,19 +202,19 @@
71    awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
72  
73  # Code the file list.
74 -$code $bigrams < $filelist > $LOCATE_DB.n
75 +$code $bigrams < $filelist > $NEW_LOCATE_DB
76  
77  rm -f $bigrams $filelist
78  
79  # To reduce the chances of breaking locate while this script is running,
80  # put the results in a temp file, then rename it atomically.
81 -if test -s $LOCATE_DB.n; then
82 +if test -s $NEW_LOCATE_DB; then
83    rm -f $LOCATE_DB
84 -  mv $LOCATE_DB.n $LOCATE_DB
85 +  mv $NEW_LOCATE_DB $LOCATE_DB
86    chmod 644 $LOCATE_DB
87  else
88    echo "updatedb: new database would be empty" >&2
89 -  rm -f $LOCATE_DB.n
90 +  rm -f $NEW_LOCATE_DB
91  fi
92  
93  fi
This page took 0.071843 seconds and 3 git commands to generate.