summaryrefslogtreecommitdiffstats
path: root/scripts/patchfns.in
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2003-02-16 20:16:58 +0000
committerAndreas Gruenbacher <agruen@suse.de>2003-02-16 20:16:58 +0000
commit867131b0791c4276cfdd273c20c3136ab63557f3 (patch)
tree1cc8c29e66126becc5457c48cd434d11424a4be6 /scripts/patchfns.in
parent114573d37141d67fbfe8dec85169142cbc14a1e1 (diff)
downloadquilt-867131b0791c4276cfdd273c20c3136ab63557f3.tar.gz
Merge version of James's temp file patch (some further improvements,
hopefully). Also, fix some messages that seem to have been reset to a previous version during I18N, and update the test script.
Diffstat (limited to 'scripts/patchfns.in')
-rw-r--r--scripts/patchfns.in54
1 files changed, 49 insertions, 5 deletions
diff --git a/scripts/patchfns.in b/scripts/patchfns.in
index 28f58de..a605b19 100644
--- a/scripts/patchfns.in
+++ b/scripts/patchfns.in
@@ -119,7 +119,7 @@ change_db_strip_level()
if [ -e $SERIES ]
then
- local tmpfile=$(@MKTEMP@ /tmp/patch-scripts.XXXXXX)
+ local tmpfile=$(gen_tempfile)
awk '
/^'"$(quote_re $patch)"'(\.patch|\.diff?)(|\.gz|\.bz2)([ \t]|$)/ \
{ for(i=2; i<=NF; i++)
@@ -166,7 +166,7 @@ insert_in_series()
patch_args=" $patch_args"
fi
- tmpfile=$(@MKTEMP@ /tmp/patch-scripts.XXXXXX) || return 1
+ tmpfile=$(gen_tempfile) || return 1
mkdir -p $(dirname $SERIES)
if [ -n "$top" ]
then
@@ -195,7 +195,7 @@ remove_from_series()
{
local patch=$1
- tmpfile=$(@MKTEMP@ /tmp/patch-scripts.XXXXXX) || return 1
+ tmpfile=$(gen_tempfile) || return 1
awk '
! /^'"$(quote_re $patch)"'(|\.patch|\.diff?)(|\.gz|\.bz2)([ \t]|$)/ \
{ print }
@@ -429,7 +429,7 @@ remove_from_db()
{
local patch=$1
local tmpfile
- if tmpfile=$(@MKTEMP@ /tmp/patch-scripts.XXXXXX)
+ if tmpfile=$(gen_tempfile)
then
grep -v -E "^$(quote_re $patch)\$" $DB > $tmpfile
mv -f $tmpfile $DB
@@ -497,7 +497,7 @@ refresh_file_list()
then
local tmpfile status
if ! mkdir -p $(dirname $pc_file) || \
- ! tmpfile=$(@MKTEMP@ /tmp/patch-scripts.XXXXXX)
+ ! tmpfile=$(gen_tempfile)
then
return 1
fi
@@ -620,6 +620,50 @@ in_array()
done
return 1
}
+
+gen_tempfile()
+{
+ # This is a substitute for the mktemp executable.
+ internal_mktemp()
+ {
+ local try n
+ if [ x"$1" = x"-d" ]
+ then
+ for ((n=0 ; $n<100 ; n++))
+ do
+ try=${2%XXXXXX}$RANDOM
+ mkdir -m 700 $try 2>/dev/null \
+ && break
+ done
+ else
+ local user_mask=$(umask)
+ umask 077
+ set -o noclobber
+ for ((n=0 ; $n<100 ; n++))
+ do
+ try=${1%XXXXXX}$RANDOM
+ echo -n "" 2> /dev/null > $try \
+ && break
+ done
+ set +o noclobber
+ umask $user_mask
+ fi
+ if [ $n -lt 100 ]
+ then
+ echo $try
+ else
+ return 1
+ fi
+ }
+
+ local dir
+ if [ x"$1" = x"-d" ]
+ then
+ dir=-d
+ shift
+ fi
+ @MKTEMP@ $dir ${1:-${TMPDIR:-/tmp}/quilt}.XXXXXX
+}
### Local Variables:
### mode: shell-script
### End: