mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
build-support: Use mktemp -d in nix-prefetch-*.
Instead of relying on $$ to not collide with an existing path. Quoting the Bash manual about $$: > Expands to the process ID of the shell. In a () subshell, it expands > to the process ID of the current shell, not the subshell. So, this is different from $BASHPID: > Expands to the process ID of the current bash process. This differs > from $$ under certain circumstances, such as subshells that do not > require bash to be re-initialized. But even $BASHPID is prone to race conditions if the process IDs wrap around, so to be on the safe side, we're using mktemp here. Closes #3784. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
39b1e2fffc
commit
f83af95f8a
@ -43,11 +43,10 @@ fi
|
|||||||
# If we don't know the hash or a path with that hash doesn't exist,
|
# If we don't know the hash or a path with that hash doesn't exist,
|
||||||
# download the file and add it to the store.
|
# download the file and add it to the store.
|
||||||
if test -z "$finalPath"; then
|
if test -z "$finalPath"; then
|
||||||
tmpPath=/tmp/bzr-checkout-tmp-$$
|
tmpPath="$(mktemp --tmpdir -d bzr-checkout-tmp-XXXXXXXX)"
|
||||||
tmpFile=$tmpPath/$dstFile
|
trap "rm -rf \"$tmpPath\"" EXIT
|
||||||
mkdir $tmpPath
|
|
||||||
|
|
||||||
trap "rm -rf $tmpPath" EXIT
|
tmpFile="$tmpPath/$dstFile"
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
bzr -Ossl.cert_reqs=none export $revarg --format=dir "$tmpFile" "$url"
|
bzr -Ossl.cert_reqs=none export $revarg --format=dir "$tmpFile" "$url"
|
||||||
|
@ -256,11 +256,11 @@ else
|
|||||||
# download the file and add it to the store.
|
# download the file and add it to the store.
|
||||||
if test -z "$finalPath"; then
|
if test -z "$finalPath"; then
|
||||||
|
|
||||||
tmpPath=/tmp/git-checkout-tmp-$$
|
tmpPath="$(mktemp --tmpdir -d git-checkout-tmp-XXXXXXXX)"
|
||||||
tmpFile=$tmpPath/git-export
|
trap "rm -rf \"$tmpPath\"" EXIT
|
||||||
mkdir $tmpPath $tmpFile
|
|
||||||
|
|
||||||
trap "rm -rf $tmpPath" EXIT
|
tmpFile="$tmpPath/git-export"
|
||||||
|
mkdir "$tmpFile"
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
clone_user_rev "$tmpFile" "$url" "$rev"
|
clone_user_rev "$tmpFile" "$url" "$rev"
|
||||||
|
@ -35,11 +35,10 @@ fi
|
|||||||
# download the file and add it to the store.
|
# download the file and add it to the store.
|
||||||
if test -z "$finalPath"; then
|
if test -z "$finalPath"; then
|
||||||
|
|
||||||
tmpPath=/tmp/hg-checkout-tmp-$$
|
tmpPath="$(mktemp --tmpdir -d hg-checkout-tmp-XXXXXXXX)"
|
||||||
tmpArchive=$tmpPath/hg-archive
|
trap "rm -rf \"$tmpPath\"" EXIT
|
||||||
mkdir $tmpPath
|
|
||||||
|
|
||||||
trap "rm -rf $tmpPath" EXIT
|
tmpArchive="$tmpPath/hg-archive"
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
if [[ $url != /* ]]; then
|
if [[ $url != /* ]]; then
|
||||||
|
@ -41,11 +41,10 @@ fi
|
|||||||
# If we don't know the hash or a path with that hash doesn't exist,
|
# If we don't know the hash or a path with that hash doesn't exist,
|
||||||
# download the file and add it to the store.
|
# download the file and add it to the store.
|
||||||
if test -z "$finalPath"; then
|
if test -z "$finalPath"; then
|
||||||
tmpPath=/tmp/svn-checkout-tmp-$$
|
tmpPath="$(mktemp --tmpdir -d svn-checkout-tmp-XXXXXXXX)"
|
||||||
tmpFile=$tmpPath/$dstFile
|
trap "rm -rf \"$tmpPath\"" EXIT
|
||||||
mkdir $tmpPath
|
|
||||||
|
|
||||||
trap "rm -rf $tmpPath" EXIT
|
tmpFile="$tmpPath/$dstFile"
|
||||||
|
|
||||||
# Perform the checkout.
|
# Perform the checkout.
|
||||||
if test "$NIX_PREFETCH_SVN_LEAVE_DOT_SVN" != 1
|
if test "$NIX_PREFETCH_SVN_LEAVE_DOT_SVN" != 1
|
||||||
|
Loading…
Reference in New Issue
Block a user