qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Don Slutz <dslutz@verizon.com>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files
Date: Tue,  6 May 2014 14:17:00 +0100	[thread overview]
Message-ID: <1399382220-14874-1-git-send-email-peter.maydell@linaro.org> (raw)

When libtool support was added to configure, the new temporary files
were left out of the list of files cleaned up on exit; this results
in a lot of stale .lo files being left around in /tmp. Worse, libtool
creates a /tmp/.libs directory which we can't easily clean up.

Put all our temporary files in a single temporary directory created
via mktemp -d, so we can easily clean it up. This has the bonus
result that we no longer use $RANDOM (which silently expands to the
empty string if your shell is not bash, and so is pretty useless).

Note that because we now use mktemp's tempdir-finding logic rather
than handrolling it, we no longer honour TEMPDIR (only TMPDIR).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I don't know why we were looking at TEMPDIR; that code was
in there from the initial commit by Fabrice back in 2003...

 configure | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index 870c939..84c600f 100755
--- a/configure
+++ b/configure
@@ -2,26 +2,25 @@
 #
 # qemu configure script (c) 2003 Fabrice Bellard
 #
-# set temporary file name
-if test ! -z "$TMPDIR" ; then
-    TMPDIR1="${TMPDIR}"
-elif test ! -z "$TEMPDIR" ; then
-    TMPDIR1="${TEMPDIR}"
-else
-    TMPDIR1="/tmp"
+
+TMPDIR1=$(mktemp -t -d)
+if [ $? -ne 0 ]; then
+    echo "ERROR: failed to create temporary directory"
+    exit 1
 fi
 
-TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
+TMPB="qemu-conf"
+TMPC="${TMPDIR1}/${TMPB}.c"
 TMPO="${TMPDIR1}/${TMPB}.o"
 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
 TMPL="${TMPDIR1}/${TMPB}.lo"
 TMPA="${TMPDIR1}/lib${TMPB}.la"
-TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
+TMPE="${TMPDIR1}/${TMPB}.exe"
 
 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
 # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
-trap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM
+trap "rm -rf ${TMPDIR1}" EXIT INT QUIT TERM
+
 rm -f config.log
 
 # Print a helpful header at the top of config.log
-- 
1.9.2

             reply	other threads:[~2014-05-06 13:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 13:17 Peter Maydell [this message]
2014-05-06 14:36 ` [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files Eric Blake
2014-05-06 14:53   ` Peter Maydell
2014-05-06 15:43     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399382220-14874-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=dslutz@verizon.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).