qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Don Slutz <dslutz@verizon.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files
Date: Tue, 06 May 2014 08:36:27 -0600	[thread overview]
Message-ID: <5368F36B.3040804@redhat.com> (raw)
In-Reply-To: <1399382220-14874-1-git-send-email-peter.maydell@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1896 bytes --]

On 05/06/2014 07:17 AM, Peter Maydell wrote:
> 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...
> 

> +
> +TMPDIR1=$(mktemp -t -d)

mktemp is not POSIX.  BSD mktemp lacks -t:

http://www.freebsd.org/cgi/man.cgi?query=mktemp&apropos=0&sektion=1&manpath=Red+Hat+Linux%2Fi386+9&format=html

and there are probably systems that lack mktemp(1) altogether.  You'll
need to come up with a more portable alternative.

Here's what autoconf recommends (modify to fit...):

# Create a (secure) tmp directory for tmp files.

{
  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
  test -d "$tmp"
}  ||
{
  tmp=./conf$$-$RANDOM
  (umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp

The use of $$ and $RANDOM is safe (even on shells that lack $RANDOM)
because of the fact that mkdir is atomic and the umask is correctly set
prior to the mkdir.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-05-06 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 13:17 [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files Peter Maydell
2014-05-06 14:36 ` Eric Blake [this message]
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=5368F36B.3040804@redhat.com \
    --to=eblake@redhat.com \
    --cc=dslutz@verizon.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).