From 6fe292d721703094893801578c08d4f0bb33c235 Mon Sep 17 00:00:00 2001 From: Adrian Gierakowski Date: Fri, 24 Jul 2020 12:28:05 +0100 Subject: [PATCH] writers.makeScriptWriter: fail build if interpreter of interpreter is a script --- pkgs/build-support/writers/default.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 90d0e5c98be0e..6a53824eac655 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -27,11 +27,20 @@ rec { # arguments to the interpreter are allowed. if [[ -n "${toString pkgs.stdenvNoCC.isDarwin}" ]] && isScript $interpreter then - wrapperInterpreter=$(head -1 "$interpreter" | tail -c+3) + wrapperInterpreterLine=$(head -1 "$interpreter" | tail -c+3) + # Get first word from the line (note: xargs echo remove leading spaces) + wrapperInterpreter=$(echo "$wrapperInterpreterLine" | xargs echo | cut -d " " -f1) + + if isScript $wrapperInterpreter + then + echo "error: passed interpreter ($interpreter) is a script which has another script ($wrapperInterpreter) as an interpreter, which is not supported." + exit 1 + fi + # This should work as long as wrapperInterpreter is a shell, which is # the case for programs wrapped with makeWrapper, like # python3.withPackages etc. - interpreterLine="$wrapperInterpreter $interpreter" + interpreterLine="$wrapperInterpreterLine $interpreter" else interpreterLine=$interpreter fi