From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhgU0-0001rr-B5 for qemu-devel@nongnu.org; Tue, 06 May 2014 10:36:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhgTv-0004qT-Qc for qemu-devel@nongnu.org; Tue, 06 May 2014 10:36:36 -0400 Message-ID: <5368F36B.3040804@redhat.com> Date: Tue, 06 May 2014 08:36:27 -0600 From: Eric Blake MIME-Version: 1.0 References: <1399382220-14874-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1399382220-14874-1-git-send-email-peter.maydell@linaro.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E2hBSILk9THAI8ucgPpi5i42h7dTH03sP" Subject: Re: [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Paolo Bonzini , Don Slutz , patches@linaro.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --E2hBSILk9THAI8ucgPpi5i42h7dTH03sP Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > 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). >=20 > Note that because we now use mktemp's tempdir-finding logic rather > than handrolling it, we no longer honour TEMPDIR (only TMPDIR). >=20 > Signed-off-by: Peter Maydell > --- > I don't know why we were looking at TEMPDIR; that code was > in there from the initial commit by Fabrice back in 2003... >=20 > + > +TMPDIR1=3D$(mktemp -t -d) mktemp is not POSIX. BSD mktemp lacks -t: http://www.freebsd.org/cgi/man.cgi?query=3Dmktemp&apropos=3D0&sektion=3D1= &manpath=3DRed+Hat+Linux%2Fi386+9&format=3Dhtml 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=3D`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=3D./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" = 5 ac_tmp=3D$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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --E2hBSILk9THAI8ucgPpi5i42h7dTH03sP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTaPNrAAoJEKeha0olJ0Nqz90H/R5iaSWrA4iAufvGUXdY6cYJ p8b9/x0k7C1eg6IiQFdW7nKf9FHuSH/3a99hQsHr/Ec17+55Q1W2YvMdIyIIxv3l ueLtHczLn6HHRoSzkEG91z/sCT4vkKoH7h8Z00NSMC2fkWg0yGTmSbFuAgukEgwT jfmjJkLs/QXt1/pktZ/zOzHsDEOLsVmWVSSUU5YSNrY5OAp4wxX0HuUM/cKPvw8h xCrmjNrjQ0ggEbWSA1CiiIIC1aP5eERbnDnpBefCcGFk3A6haAsrXYjR+pQH1Uu4 uZPFWT6LvgrhbinUve3pUvmSCPAfxd0W31uOL8eBMDQz8wnjNrMJiSQbpnhDGOQ= =KN96 -----END PGP SIGNATURE----- --E2hBSILk9THAI8ucgPpi5i42h7dTH03sP--