]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
git-archive-all.sh: use an actually unique tmp dir 12011/head
authorDan Mick <dan.mick@redhat.com>
Wed, 16 Nov 2016 03:42:06 +0000 (19:42 -0800)
committerDan Mick <dan.mick@redhat.com>
Wed, 16 Nov 2016 03:45:02 +0000 (19:45 -0800)
git archive into $TMPDIR/$(basename "$(pwd)").$FORMAT is not unique;
if two runs are running simultaneously, this will collide.  Make
TMPDIR actually unique, and then the cleanup can just remove the whole
directory as well.

Signed-off-by: Dan Mick <dan.mick@redhat.com>
bin/git-archive-all.sh

index 68c31eac497595055e6b9a318fd3d3497054f9d7..8c292b54d522859ce03d1cc3932a14174dd37803 100755 (executable)
@@ -48,8 +48,7 @@ IFS='
        '
 
 function cleanup () {
-    rm -f $TMPFILE
-    rm -f $TOARCHIVE
+    rm -rf $TMPDIR
     IFS="$OLD_IFS"
 }
 
@@ -105,7 +104,7 @@ readonly PROGRAM=`basename "$0"`
 readonly VERSION=0.2
 
 OLD_PWD="`pwd`"
-TMPDIR=${TMPDIR:-/tmp}
+TMPDIR=`mktemp -d "${TMPDIR:-/tmp}/$PROGRAM.XXXXXX"`
 TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress
 TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"`
 OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default