From patchwork Fri May 23 16:07:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 30832 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E8E6620369 for ; Fri, 23 May 2014 16:07:27 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf24389924iec.0 for ; Fri, 23 May 2014 09:07:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=XNC58dJ3zCBL0A4NEWOJGahkFEfkCiFAp0LgQLyX4e8=; b=MJYxQlXDi+tZ3Xo6bMhhd0yxlxP5Lg4GoakwT2u1RT/+7skQ5konocG3fZ9HRNhDLq ig5siCd2gdI7ipvyBMQB71dPk+D5X9ABg84BnDy6sSje94FDYkGIdPqnZPhbj+quuZiv hDjgGCCnzJsWgABwxZluHfWle9o5iV/ZyCWlimG3xJYfbkVqIsQbW6HaPc6fD1tCXhK0 LvviReNpDbefADNwV94BAD65eBMMXTfAyBwPDciFTDcXGaaOT0wDieBNULwVClobKQ95 cQqtCt7LK8IsG16NUxyLhjfhBiYrePVwhqN2u+NYc5ZUaOHDFowoc8Au8VRMRHfnL+2n 1O2w== X-Gm-Message-State: ALoCoQnydoUFVBskVwnC2MQHVucg67qzOivzG8x3x/d8GlZTc1cuCLDyrLEYpCheNlFez+r8F+VD X-Received: by 10.50.111.15 with SMTP id ie15mr1950727igb.2.1400861247398; Fri, 23 May 2014 09:07:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.247 with SMTP id h110ls1852100qgf.44.gmail; Fri, 23 May 2014 09:07:27 -0700 (PDT) X-Received: by 10.221.64.20 with SMTP id xg20mr1463373vcb.3.1400861247257; Fri, 23 May 2014 09:07:27 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id c8si1892337vee.90.2014.05.23.09.07.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 09:07:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id lc6so6430930vcb.2 for ; Fri, 23 May 2014 09:07:27 -0700 (PDT) X-Received: by 10.220.5.129 with SMTP id 1mr1331958vcv.71.1400861247141; Fri, 23 May 2014 09:07:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp43828vcb; Fri, 23 May 2014 09:07:26 -0700 (PDT) X-Received: by 10.194.187.240 with SMTP id fv16mr2851313wjc.81.1400861246092; Fri, 23 May 2014 09:07:26 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id bv2si2937973wjc.77.2014.05.23.09.07.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 May 2014 09:07:26 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Wns0C-0004A5-2w; Fri, 23 May 2014 17:07:24 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-trivial@nongnu.org, Paolo Bonzini , Eric Blake Subject: [PATCH v2] configure: Put tempfiles in a subdir of the build directory Date: Fri, 23 May 2014 17:07:24 +0100 Message-Id: <1400861244-15972-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Reviewed-by: Eric Blake --- v1->v2: added rm -r "$TMPDIR1" on successful exit. .gitignore | 1 + configure | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 8a52709..c658613 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /config-host.* /config-target.* /config.status +/config-temp /trace/generated-tracers.h /trace/generated-tracers.c /trace/generated-tracers-dtrace.h diff --git a/configure b/configure index 605a0ec..e6f0d29 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 @@ -5219,3 +5221,4 @@ printf " '%s'" "$0" "$@" >>config.status echo >>config.status chmod +x config.status +rm -r "$TMPDIR1"