From bedc267a787ee68b4c02f168414f67885907f7b0 Mon Sep 17 00:00:00 2001 From: Lin Yinfeng Date: Thu, 14 Apr 2022 11:47:59 +0800 Subject: [PATCH] autoPatchelfHook: fix precise dependency ignorance This commit fixes precise dependency ignorance by converting the environment variable `autoPatchelfIgnoreMissingDeps` into a bash array `ignoreMissingDepsArray`, passing `"${ignoreMissingDepsArray[@]}"` instead of `"${autoPatchelfIgnoreMissingDeps[@]}"` to the python script. The original implementation does not work when `autoPatchelfIgnoreMissingDeps` contains multiple dependency names. Because it mistakenly passes `"${autoPatchelfIgnoreMissingDeps[@]}"` to the python script. According to the Nix manual (https://nixos.org/manual/nix/stable/expressions/derivations.html), lists of strings are concatenated into whitespace-separated strings, then passed to the builder as environment variables. So, if `autoPatchelfIgnoreMissingDeps = [ "dep1" "dep2" "dep3" ]`, `"${autoPatchelfIgnoreMissingDeps[@]}"` will be expanded to a single argument `"dep1 dep2 dep3"`, which is not the intended behavior, because the python script takes the long argument as a dependency name. With this commit, `"${ignoreMissingDepsArray[@]}"` will be expanded to three arguments `"dep1" "dep2" "dep3"` arguments as expected, fixing the issue. --- pkgs/build-support/setup-hooks/auto-patchelf.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 661b8597efea..b56f9ce2dbf4 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -53,17 +53,18 @@ autoPatchelf() { esac done - if [ "${autoPatchelfIgnoreMissingDeps[*]}" == "1" ]; then + local ignoreMissingDepsArray=($autoPatchelfIgnoreMissingDeps) + if [ "$autoPatchelfIgnoreMissingDeps" == "1" ]; then echo "autoPatchelf: WARNING: setting 'autoPatchelfIgnoreMissingDeps" \ "= true;' is deprecated and will be removed in a future release." \ "Use 'autoPatchelfIgnoreMissingDeps = [ \"*\" ];' instead." >&2 - autoPatchelfIgnoreMissingDeps=( "*" ) + ignoreMissingDepsArray=( "*" ) fi local runtimeDependenciesArray=($runtimeDependencies) @pythonInterpreter@ @autoPatchelfScript@ \ ${norecurse:+--no-recurse} \ - --ignore-missing "${autoPatchelfIgnoreMissingDeps[@]}" \ + --ignore-missing "${ignoreMissingDepsArray[@]}" \ --paths "$@" \ --libs "${autoPatchelfLibs[@]}" \ "${extraAutoPatchelfLibs[@]}" \