From df21fb8afa235a71b4e814f1ed1c4003ce34b220 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 9 Feb 2021 01:33:33 +0100 Subject: [PATCH] Revert "stdenv/patchShebangs: avoid temporary time reference file" This reverts commit 6e3f4c90790f112f6b6da54b9f1eb0e85310ee64. This apparently breaks the x86_64 darwin stdenv. Details in #112417. --- pkgs/build-support/setup-hooks/patch-shebangs.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index d0efe039ced..bd254be24f9 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -88,15 +88,17 @@ patchShebangs() { newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}} if [[ -n "$oldPath" && "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]]; then - if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then + if [[ -n "$newPath" ]] && [[ "$newPath" != "$oldPath" ]]; then echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\"" # escape the escape chars so that sed doesn't interpret them escapedInterpreterLine=${newInterpreterLine//\\/\\\\} # Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281 - timestamp=$(stat --printf "%y" "$f") + timestamp=$(mktemp) + touch -r "$f" "$timestamp" sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" - touch --date "$timestamp" "$f" + touch -r "$timestamp" "$f" + rm "$timestamp" fi fi done < <(find "$@" -type f -perm -0100 -print0)