From a86020b885b7a67284e533eeef44fd0d4a161d4a Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 16 Sep 2018 15:29:50 -0500 Subject: [PATCH] Revert "Merge pull request #46108 from obsidiansystems/cross-patch-shebangs" This reverts commit 6877b4c13e302fee846b711d38d6ddef1dccdf97, reversing changes made to 69b6db0ec5d871af72645fd6ee15e9f791c92615. --- .../setup-hooks/patch-shebangs.sh | 53 ++----------------- pkgs/stdenv/generic/setup.sh | 4 +- pkgs/tools/networking/dhcpcd/default.nix | 10 ++-- 3 files changed, 11 insertions(+), 56 deletions(-) diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index 04d7b6d8efa5..1433d1e1f144 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -5,32 +5,10 @@ # rewritten to /nix/store//bin/python. Interpreters that are # already in the store are left untouched. -fixupOutputHooks+=(patchShebangsAuto) - -# Run patch shebangs on a directory. -# patchShebangs [--build | --host] directory - -# Flags: -# --build : Lookup commands available at build-time -# --host : Lookup commands available at runtime - -# Example use cases, -# $ patchShebangs --host /nix/store/...-hello-1.0/bin -# $ patchShebangs --build configure +fixupOutputHooks+=('if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi') patchShebangs() { - local pathName - - if [ "$1" = "--host" ]; then - pathName=HOST_PATH - shift - elif [ "$1" = "--build" ]; then - pathName=PATH - shift - fi - local dir="$1" - header "patching script interpreter paths in $dir" local f local oldPath @@ -49,14 +27,6 @@ patchShebangs() { oldInterpreterLine=$(head -1 "$f" | tail -c+3) read -r oldPath arg0 args <<< "$oldInterpreterLine" - if [ -z "$pathName" ]; then - if [[ "$f" = "$NIX_STORE"* ]]; then - pathName=HOST_PATH - else - pathName=PATH - fi - fi - if $(echo "$oldPath" | grep -q "/bin/env$"); then # Check for unsupported 'env' functionality: # - options: something starting with a '-' @@ -65,17 +35,14 @@ patchShebangs() { echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" exit 1 fi - - newPath="$(PATH="${!pathName}" command -v "$arg0" || true)" + newPath="$(command -v "$arg0" || true)" else if [ "$oldPath" = "" ]; then # If no interpreter is specified linux will use /bin/sh. Set # oldpath="/bin/sh" so that we get /nix/store/.../sh. oldPath="/bin/sh" fi - - newPath="$(PATH="${!pathName}" command -v "$(basename "$oldPath")" || true)" - + newPath="$(command -v "$(basename "$oldPath")" || true)" args="$arg0 $args" fi @@ -98,17 +65,3 @@ patchShebangs() { stopNest } - -patchShebangsAuto () { - if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then - - # Dev output will end up being run on the build platform. An - # example case of this is sdl2-config. Otherwise, we can just - # use the runtime path (--host). - if [ "$output" != out ] && [ "$output" = "${!outputDev}" ]; then - patchShebangs --build "$prefix" - else - patchShebangs --host "$prefix" - fi - fi -} diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 83a34c58a956..141e94c5ed46 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -500,11 +500,11 @@ activatePackage() { # the transition, we do include everything in thatcase. # # TODO(@Ericson2314): Don't special-case native compilation - if [[ ( -z "${strictDeps-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then + if [[ ( -z "${strictDeps-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then addToSearchPath _PATH "$pkg/bin" fi - if [[ ( -z "${strictDeps-}" || "$hostOffset" -eq 0 ) && -d "$pkg/bin" ]]; then + if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then addToSearchPath HOST_PATH "$pkg/bin" fi diff --git a/pkgs/tools/networking/dhcpcd/default.nix b/pkgs/tools/networking/dhcpcd/default.nix index bb568bd2c1e7..1fe29b8b96ff 100644 --- a/pkgs/tools/networking/dhcpcd/default.nix +++ b/pkgs/tools/networking/dhcpcd/default.nix @@ -11,10 +11,7 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkgconfig ]; - buildInputs = [ - udev - runtimeShellPackage # So patchShebangs finds a bash suitable for the installed scripts - ]; + buildInputs = [ udev ]; preConfigure = "patchShebangs ./configure"; @@ -32,6 +29,11 @@ stdenv.mkDerivation rec { # Check that the udev plugin got built. postInstall = stdenv.lib.optional (udev != null) "[ -e $out/lib/dhcpcd/dev/udev.so ]"; + # TODO shlevy remove once patchShebangs is fixed + postFixup = '' + find $out -type f -print0 | xargs --null sed -i 's|${stdenv.shellPackage}|${runtimeShellPackage}|' + ''; + meta = { description = "A client for the Dynamic Host Configuration Protocol (DHCP)"; homepage = https://roy.marples.name/projects/dhcpcd;