summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
diff options
context:
space:
mode:
authorNicolas Mattia <nicolas@nmattia.com>2019-04-25 17:07:58 +0200
committerNicolas Mattia <nicolas@nmattia.com>2019-04-25 17:07:58 +0200
commitcc9b4029bc7ec91237ce44d04230b921005db6a0 (patch)
tree1110800eac810b869f98d752f5693bd385c9fb7e /pkgs/build-support/setup-hooks
parent82f338b83701cb1fb87d0b6a83ca20b4dca4f9eb (diff)
downloadnixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar.gz
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar.bz2
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar.lz
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar.xz
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.tar.zst
nixpkgs-cc9b4029bc7ec91237ce44d04230b921005db6a0.zip
patchShebangs: create timestamp in tmp dir
Creating the timestamp in the patched script's directory has a few
drawbacks:

* if "foo.timestamp" already exists, it will be overwritten
* it requires the directory to be writable
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r--pkgs/build-support/setup-hooks/patch-shebangs.sh7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh
index 1433d1e1f14..73fe23f88be 100644
--- a/pkgs/build-support/setup-hooks/patch-shebangs.sh
+++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh
@@ -55,10 +55,11 @@ patchShebangs() {
                 # escape the escape chars so that sed doesn't interpret them
                 escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
                 # Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
-                touch -r "$f" "$f.timestamp"
+                timestamp=$(mktemp)
+                touch -r "$f" "$timestamp"
                 sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
-                touch -r "$f.timestamp" "$f"
-                rm "$f.timestamp"
+                touch -r "$timestamp" "$f"
+                rm "$timestamp"
             fi
         fi
     done