diff --git a/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py b/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py index 87081048343b..33813168f560 100644 --- a/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py +++ b/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py @@ -256,6 +256,15 @@ class SetInterpreter: return f"setting interpreter of {self.file}" +@dataclass +class IgnoredDependency: + file: Path # The file that contains the ignored dependency + name: Path # The name of the dependency + pattern: str # The pattern that caused this missing dep to be ignored + + def to_human_readable_str(self) -> str: + return f"warn: auto-patchelf ignoring missing {self.name} wanted by {self.file}" + @dataclass class Dependency: file: Path # The file that contains the dependency @@ -464,7 +473,7 @@ def auto_patchelf( for dep in missing: for pattern in ignore_missing: if fnmatch(dep.name.name, pattern): - logger.debug(f"warn: auto-patchelf ignoring missing {dep.name} wanted by {dep.file}") + logger.log(IgnoredDependency(file=dep.file, name=dep.name, pattern=pattern)) break else: logger.debug(f"error: auto-patchelf could not satisfy dependency {dep.name} wanted by {dep.file}") diff --git a/pkgs/test/auto-patchelf-structured-log/default.nix b/pkgs/test/auto-patchelf-structured-log/default.nix index b75e5cb58ca1..b8e73f040964 100644 --- a/pkgs/test/auto-patchelf-structured-log/default.nix +++ b/pkgs/test/auto-patchelf-structured-log/default.nix @@ -31,7 +31,8 @@ stdenv.mkDerivation { auto-patchelf \ --paths ./usr/bin/ToneLib-Jam \ --libs ${lib.getLib freetype}/lib \ - --structured-logs > log.jsonl || true + --ignore-missing "libasound.so.*" "libGL.so.*" \ + --structured-logs | tee log.jsonl # Expect 1 SetInterpreter line jq -e -s '[.[] | select(has("SetInterpreter"))] | length == 1' log.jsonl @@ -39,13 +40,16 @@ stdenv.mkDerivation { # We expect 3 Dependency lines jq -e -s '[.[] | select(has("Dependency"))] | length == 3' log.jsonl - # Expect the last line to set the rpath as expected - jq -e -s 'last == { + # We expect 2 IgnoredDependency lines + jq -e -s '[.[] | select(has("IgnoredDependency"))] | length == 2' log.jsonl + + # Expect there to be a SetRpath event using the expected rpath + jq -e -s 'any(.[]; . == { "SetRpath": { "file": "usr/bin/ToneLib-Jam", "rpath": "${lib.getLib freetype}/lib" } - }' log.jsonl + })' log.jsonl cp log.jsonl $out '';