From 41c09640e7315be703af7840cf33e606c220beea Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 10 Oct 2022 14:21:06 +1300 Subject: [PATCH 1/2] autoPatchelfHook: fix turning `[ "*" ]` into bash array Previously globs were incorrectly handled and expanded by bash into the files in the temporary build directory. --- pkgs/build-support/setup-hooks/auto-patchelf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index b56f9ce2dbf4..7f5ff146e30b 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -53,7 +53,7 @@ autoPatchelf() { esac done - local ignoreMissingDepsArray=($autoPatchelfIgnoreMissingDeps) + readarray -td' ' ignoreMissingDepsArray < <(echo -n "$autoPatchelfIgnoreMissingDeps") if [ "$autoPatchelfIgnoreMissingDeps" == "1" ]; then echo "autoPatchelf: WARNING: setting 'autoPatchelfIgnoreMissingDeps" \ "= true;' is deprecated and will be removed in a future release." \ From 01535ff0b07a73c94a3831a2f68bede5a1652ae1 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 10 Oct 2022 14:22:58 +1300 Subject: [PATCH 2/2] autoPatchelfHook: support glob patterns so for example cuda could be ignored by setting: ``` nix autoPatchelfIgnoreMissingDeps = [ "*cuda*.so*" ]; ``` --- pkgs/build-support/setup-hooks/auto-patchelf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.py b/pkgs/build-support/setup-hooks/auto-patchelf.py index 861d772698d0..efb65a809962 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.py +++ b/pkgs/build-support/setup-hooks/auto-patchelf.py @@ -5,6 +5,7 @@ import os import pprint import subprocess import sys +from fnmatch import fnmatch from collections import defaultdict from contextlib import contextmanager from dataclasses import dataclass @@ -265,8 +266,10 @@ def auto_patchelf( print(f"auto-patchelf: {len(missing)} dependencies could not be satisfied") failure = False for dep in missing: - if dep.name.name in ignore_missing or "*" in ignore_missing: - print(f"warn: auto-patchelf ignoring missing {dep.name} wanted by {dep.file}") + for pattern in ignore_missing: + if fnmatch(dep.name.name, pattern): + print(f"warn: auto-patchelf ignoring missing {dep.name} wanted by {dep.file}") + break else: print(f"error: auto-patchelf could not satisfy dependency {dep.name} wanted by {dep.file}") failure = True