From 2533a1124192c9da20087514986c3d37cc106c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sun, 11 Jan 2015 20:07:38 +0100 Subject: [PATCH] stdenv substitute: avoid using a temporary file - IMO using a temporary is not needed here (anymore), - temporary at that location can cause a problem (in a specific case): for example, when using the substituteAll function from nixpkgs on a single file directly under /nix/store/ (or ./foo-file), the stdenv's substitute tries to create a temporary directly under /nix/store, which causes problems on chrooted darwin (according to @copumpkin earlier today on IRC) --- pkgs/stdenv/generic/setup.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 1cc60ebf02bc..d72fddf439eb 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -370,9 +370,8 @@ substitute() { content="${content//"$pattern"/$replacement}" done - printf "%s" "$content" > "$output".tmp - if [ -x "$output" ]; then chmod +x "$output".tmp; fi - mv -f "$output".tmp "$output" + chmod -f +w "$output" || true + printf "%s" "$content" > "$output" }