From patchwork Mon May 26 07:19:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 30923 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4FC7120491 for ; Mon, 26 May 2014 08:37:53 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rq2sf35838008pbb.9 for ; Mon, 26 May 2014 01:37:53 -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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=i14WORaQiXvPLLB3swb8b/9egU8x7xpIZtrowM1Nm/0=; b=mSad5rRuEFRE+lImUiqv/uI/hiESVL7wMbeZdu5xFhhhFI9Nt6purauI4+/ZQDJlrK Jqcool86iFtjvMJ1swyPHaQOJqBnyfTr+GJuwTsoRirU3upzDYl2k/W8Y7/oJXjcZ0Tp b9iKsWIPKKOJL5fCRakrbEE3mR/0rn8Rizsm2fYQl/PBEOaTyeaHVvtazWL5yw2g2eLp WMkw7WekRHiG9zeC/VcMI2eNrHGLNBnZjxFoWRYHzR5ix2092m8dUu6c75C3WzJRSDHw ppuGLn3DpgP+0J46yGHd+/L7ignNTQDq0dUSkygZMX8u8IEnSRlmFOKZYWwWeMMITGs+ fInQ== X-Gm-Message-State: ALoCoQnM0TwpuLdJkdTtIJIMo2cDMDjG5BnYSSkbtfu7ILaeiEoYw65FKcmVGvtakfSRz1EocBU3 X-Received: by 10.68.230.193 with SMTP id ta1mr9986275pbc.6.1401093473163; Mon, 26 May 2014 01:37:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.42 with SMTP id 39ls2591640qgq.26.gmail; Mon, 26 May 2014 01:37:53 -0700 (PDT) X-Received: by 10.220.106.7 with SMTP id v7mr5469234vco.46.1401093473003; Mon, 26 May 2014 01:37:53 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id s1si5923862vep.80.2014.05.26.01.37.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:37:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so8840019veb.6 for ; Mon, 26 May 2014 01:37:52 -0700 (PDT) X-Received: by 10.221.24.207 with SMTP id rf15mr20164834vcb.17.1401093472907; Mon, 26 May 2014 01:37:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp27097vcb; Mon, 26 May 2014 01:37:52 -0700 (PDT) X-Received: by 10.140.37.135 with SMTP id r7mr28339458qgr.61.1401093472310; Mon, 26 May 2014 01:37:52 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y5si8043039qab.8.2014.05.26.01.37.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 May 2014 01:37:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:55389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoqPn-0000Ou-W3 for patch@linaro.org; Mon, 26 May 2014 04:37:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoqPD-0008Jl-B2 for qemu-devel@nongnu.org; Mon, 26 May 2014 04:37:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoqP8-0007Me-Qd for qemu-devel@nongnu.org; Mon, 26 May 2014 04:37:15 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:57142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoqP8-0007LX-CD; Mon, 26 May 2014 04:37:10 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 3638542FAC; Mon, 26 May 2014 12:37:09 +0400 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 19DF56B1; Mon, 26 May 2014 11:20:15 +0400 (MSK) Received: (nullmailer pid 23010 invoked by uid 1000); Mon, 26 May 2014 07:20:13 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 26 May 2014 11:19:59 +0400 Message-Id: <1401088811-22923-12-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401088811-22923-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1401088811-22923-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, Peter Maydell , Michael Tokarev Subject: [Qemu-devel] [PULL 11/23] configure: Put tempfiles in a subdir of the build directory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mjt@tls.msk.ru X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell 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 Signed-off-by: Michael Tokarev --- .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 678a106..cde4325 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"