From 2bd3aa4bc265d34b8ab18e917261b0dc24c5076d Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Tue, 9 Feb 2021 12:51:09 +0900 Subject: [PATCH] Revert "Revert "stdenv/patchShebangs: avoid temporary time reference file"" This reverts commit df21fb8afa235a71b4e814f1ed1c4003ce34b220. --- pkgs/build-support/setup-hooks/patch-shebangs.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index bd254be24f9..d0efe039ced 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -88,17 +88,15 @@ 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=$(mktemp) - touch -r "$f" "$timestamp" + timestamp=$(stat --printf "%y" "$f") sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" - touch -r "$timestamp" "$f" - rm "$timestamp" + touch --date "$timestamp" "$f" fi fi done < <(find "$@" -type f -perm -0100 -print0)