summary refs log tree commit diff
path: root/pkgs/build-support/fetchbzr/nix-prefetch-bzr
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/fetchbzr/nix-prefetch-bzr')
-rwxr-xr-xpkgs/build-support/fetchbzr/nix-prefetch-bzr7
1 files changed, 3 insertions, 4 deletions
diff --git a/pkgs/build-support/fetchbzr/nix-prefetch-bzr b/pkgs/build-support/fetchbzr/nix-prefetch-bzr
index 2f46819323f..8143fca7025 100755
--- a/pkgs/build-support/fetchbzr/nix-prefetch-bzr
+++ b/pkgs/build-support/fetchbzr/nix-prefetch-bzr
@@ -43,11 +43,10 @@ fi
 # 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.
 if test -z "$finalPath"; then
-    tmpPath=/tmp/bzr-checkout-tmp-$$
-    tmpFile=$tmpPath/$dstFile
-    mkdir $tmpPath
+    tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/bzr-checkout-tmp-XXXXXXXX")"
+    trap "rm -rf \"$tmpPath\"" EXIT
 
-    trap "rm -rf $tmpPath" EXIT
+    tmpFile="$tmpPath/$dstFile"
 
     # Perform the checkout.
     bzr -Ossl.cert_reqs=none export $revarg --format=dir "$tmpFile" "$url"