[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] configure: Put tempfiles in subd
Re: [Qemu-trivial] [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files
Tue, 6 May 2014 15:53:35 +0100
On 6 May 2014 15:36, Eric Blake <address@hidden> wrote:
> mktemp is not POSIX. BSD mktemp lacks -t:
> 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"
> } ||
> (umask 077 && mkdir "$tmp")
> } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
> 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.
I dislike the use of $RANDOM, because it means we behave
inconsistently. If it's OK for $RANDOM to expand to "" then we
should just not use it at all, because that's OK and the same
Similarly, if it's OK not to use mktemp on some systems,
we should use the same non-mktemp code everywhere.
We could sidestep this rubbish by not trying to put our temp
files in /tmp/, and instead just put them in the build directory
(ie ./conf-temps/ or something similar, which we blow away
and recreate every time).