From 2a2b88eb557c655c2b4960a8d8f3e23a05a3472c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 11 Sep 2024 19:28:11 +0200 Subject: [PATCH 1/2] auto-patchelf: fix test for hook Fix suggested by Yann Hamdaoui in https://github.com/NixOS/nixpkgs/pull/340858#issuecomment-2344155304. --- pkgs/test/auto-patchelf-hook/package.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test/auto-patchelf-hook/package.nix b/pkgs/test/auto-patchelf-hook/package.nix index 7b8fb5fdfc9ec..37413c7301eef 100644 --- a/pkgs/test/auto-patchelf-hook/package.nix +++ b/pkgs/test/auto-patchelf-hook/package.nix @@ -60,7 +60,6 @@ stdenv.mkDerivation { # Additional phase performing the actual test. installCheckPhase = let allDeps = runtimeDependencies ++ [ - (lib.getLib stdenv.cc.libc) (lib.getLib freetype) ]; in From bc0395ee6f9964065665adf3d365a2f93c3b4ca5 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 24 Aug 2024 23:26:56 +0200 Subject: [PATCH 2/2] auto-patchelf: refactor structuredAttrs support stdenv now provides better tooling to support structuredAttrs without depending on $__structuredAttrs itself. --- .../build-support/setup-hooks/auto-patchelf.sh | 18 +++++------------- pkgs/stdenv/generic/setup.sh | 2 ++ pkgs/test/stdenv/default.nix | 8 ++++---- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 59b596d271726..392163646aa8e 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -53,19 +53,11 @@ autoPatchelf() { esac done - if [ -n "$__structuredAttrs" ]; then - local ignoreMissingDepsArray=( "${autoPatchelfIgnoreMissingDeps[@]}" ) - local appendRunpathsArray=( "${appendRunpaths[@]}" ) - local runtimeDependenciesArray=( "${runtimeDependencies[@]}" ) - local patchelfFlagsArray=( "${patchelfFlags[@]}" ) - local autoPatchelfFlagsArray=( "${autoPatchelfFlags[@]}" ) - else - readarray -td' ' ignoreMissingDepsArray < <(echo -n "$autoPatchelfIgnoreMissingDeps") - local appendRunpathsArray=($appendRunpaths) - local runtimeDependenciesArray=($runtimeDependencies) - local patchelfFlagsArray=($patchelfFlags) - local autoPatchelfFlagsArray=($autoPatchelfFlags) - fi + concatTo ignoreMissingDepsArray autoPatchelfIgnoreMissingDeps + concatTo appendRunpathsArray appendRunpaths + concatTo runtimeDependenciesArray runtimeDependencies + concatTo patchelfFlagsArray patchelfFlags + concatTo autoPatchelfFlagsArray autoPatchelfFlags # Check if ignoreMissingDepsArray contains "1" and if so, replace it with # "*", printing a deprecation warning. diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 3c197171e801d..230c18c3e3640 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -389,6 +389,8 @@ appendToVar() { # Arrays are simply concatenated, strings are split on whitespace. # Default values can be passed via name=default. concatTo() { + local - + set -o noglob local -n targetref="$1"; shift local arg default name type for arg in "$@"; do diff --git a/pkgs/test/stdenv/default.nix b/pkgs/test/stdenv/default.nix index 6ed430f5da3fd..0a0e5930d9d48 100644 --- a/pkgs/test/stdenv/default.nix +++ b/pkgs/test/stdenv/default.nix @@ -101,7 +101,7 @@ let ({ inherit name; - string = "a b"; + string = "a *"; list = ["c" "d"]; passAsFile = [ "buildCommand" ] ++ lib.optionals (extraAttrs ? extraTest) [ "extraTest" ]; @@ -116,7 +116,7 @@ let concatTo flagsArray string list notset=e=f empty_array=g empty_string=h declare -p flagsArray [[ "''${flagsArray[0]}" == "a" ]] || (echo "'\$flagsArray[0]' was not 'a'" && false) - [[ "''${flagsArray[1]}" == "b" ]] || (echo "'\$flagsArray[1]' was not 'b'" && false) + [[ "''${flagsArray[1]}" == "*" ]] || (echo "'\$flagsArray[1]' was not '*'" && false) [[ "''${flagsArray[2]}" == "c" ]] || (echo "'\$flagsArray[2]' was not 'c'" && false) [[ "''${flagsArray[3]}" == "d" ]] || (echo "'\$flagsArray[3]' was not 'd'" && false) [[ "''${flagsArray[4]}" == "e=f" ]] || (echo "'\$flagsArray[4]' was not 'e=f'" && false) @@ -127,7 +127,7 @@ let concatTo nonExistant string list notset=e=f empty_array=g empty_string=h declare -p nonExistant [[ "''${nonExistant[0]}" == "a" ]] || (echo "'\$nonExistant[0]' was not 'a'" && false) - [[ "''${nonExistant[1]}" == "b" ]] || (echo "'\$nonExistant[1]' was not 'b'" && false) + [[ "''${nonExistant[1]}" == "*" ]] || (echo "'\$nonExistant[1]' was not '*'" && false) [[ "''${nonExistant[2]}" == "c" ]] || (echo "'\$nonExistant[2]' was not 'c'" && false) [[ "''${nonExistant[3]}" == "d" ]] || (echo "'\$nonExistant[3]' was not 'd'" && false) [[ "''${nonExistant[4]}" == "e=f" ]] || (echo "'\$nonExistant[4]' was not 'e=f'" && false) @@ -344,7 +344,7 @@ in concatTo flagsWithSpaces string listWithSpaces declare -p flagsWithSpaces [[ "''${flagsWithSpaces[0]}" == "a" ]] || (echo "'\$flagsWithSpaces[0]' was not 'a'" && false) - [[ "''${flagsWithSpaces[1]}" == "b" ]] || (echo "'\$flagsWithSpaces[1]' was not 'b'" && false) + [[ "''${flagsWithSpaces[1]}" == "*" ]] || (echo "'\$flagsWithSpaces[1]' was not '*'" && false) [[ "''${flagsWithSpaces[2]}" == "c c" ]] || (echo "'\$flagsWithSpaces[2]' was not 'c c'" && false) [[ "''${flagsWithSpaces[3]}" == "d d" ]] || (echo "'\$flagsWithSpaces[3]' was not 'd d'" && false) '';