summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorPeter Maydell2014-05-23 18:07:24 +0200
committerMichael Tokarev2014-05-23 22:34:38 +0200
commit8cd05ab65a92a592e771a0a1847c7e5505d9a024 (patch)
tree05b83733766e2de26962810c82553767d95240f5 /configure
parentdma-helpers: avoid calling dma_bdrv_unmap() twice (diff)
downloadqemu-8cd05ab65a92a592e771a0a1847c7e5505d9a024.tar.gz
qemu-8cd05ab65a92a592e771a0a1847c7e5505d9a024.tar.xz
qemu-8cd05ab65a92a592e771a0a1847c7e5505d9a024.zip
configure: Put tempfiles in a subdir of the build directory
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 as a subdirectory of the build directory, so we can easily clean it up, and don't need fragile or complicated code for creation to avoid it clashing with temporary directories from other instances of QEMU configure or being subject to attack from adversaries who can write to /tmp. Since the temporaries now live in the build tree, we have no need to jump through hoops with a trap handler to try to remove them when configure exits; this fixes some weird bugs where hitting ^C during a configure run wouldn't actually make it stop, because we would run the trap handler but then not stop. (It is possible to get the trap handler semantics right but it is convoluted largely because of bugs in dash, so it is simpler to just avoid it.) Note that "temporary files go in the build directory, not /tmp" is the way autoconf behaves. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure29
1 files changed, 16 insertions, 13 deletions
diff --git a/configure b/configure
index 678a1061ad..cde432520d 100755
--- a/configure
+++ b/configure
@@ -2,26 +2,28 @@
#
# 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"
+
+# Temporary directory used for files created while
+# configure runs. Since it is in the build directory
+# we can safely blow away any previous version of it
+# (and we need not jump through hoops to try to delete
+# it when configure exits.)
+TMPDIR1="config-temp"
+rm -rf "${TMPDIR1}"
+mkdir -p "${TMPDIR1}"
+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
rm -f config.log
# Print a helpful header at the top of config.log
@@ -5235,3 +5237,4 @@ printf " '%s'" "$0" "$@" >>config.status
echo >>config.status
chmod +x config.status
+rm -r "$TMPDIR1"