diff options
Diffstat (limited to 'scripts/patchfns.in')
-rw-r--r-- | scripts/patchfns.in | 54 |
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: |