diff options
author | Samuel Ainsworth <skainsworth@gmail.com> | 2022-04-11 01:28:55 +0000 |
---|---|---|
committer | Samuel Ainsworth <skainsworth@gmail.com> | 2022-04-11 01:28:55 +0000 |
commit | a7fc2f6392be849f811c0a3f29f559311dc695df (patch) | |
tree | 16ff6b58c9c149bc47e321fd7c236762a032488b /pkgs/build-support | |
parent | f22dc92e9ff0444f1dae325ca30bbdc67972a8cf (diff) | |
download | nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar.gz nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar.bz2 nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar.lz nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar.xz nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.tar.zst nixpkgs-a7fc2f6392be849f811c0a3f29f559311dc695df.zip |
autoPatchelfHook: more precise dependency ignorance
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.py | 40 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.sh | 9 |
2 files changed, 31 insertions, 18 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.py b/pkgs/build-support/setup-hooks/auto-patchelf.py index 26fd623e3da..861d772698d 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.py +++ b/pkgs/build-support/setup-hooks/auto-patchelf.py @@ -1,23 +1,21 @@ #!/usr/bin/env python3 -from collections import defaultdict -from contextlib import contextmanager -from dataclasses import dataclass -from elftools.common.exceptions import ELFError # type: ignore -from elftools.elf.dynamic import DynamicSection # type: ignore -from elftools.elf.elffile import ELFFile # type: ignore -from elftools.elf.enums import ENUM_E_TYPE, ENUM_EI_OSABI # type: ignore -from itertools import chain -from pathlib import Path, PurePath - -from typing import Tuple, Optional, Iterator, List, DefaultDict, Set - import argparse import os import pprint import subprocess import sys +from collections import defaultdict +from contextlib import contextmanager +from dataclasses import dataclass +from itertools import chain +from pathlib import Path, PurePath +from typing import DefaultDict, Iterator, List, Optional, Set, Tuple +from elftools.common.exceptions import ELFError # type: ignore +from elftools.elf.dynamic import DynamicSection # type: ignore +from elftools.elf.elffile import ELFFile # type: ignore +from elftools.elf.enums import ENUM_E_TYPE, ENUM_EI_OSABI # type: ignore @contextmanager @@ -246,7 +244,7 @@ def auto_patchelf( lib_dirs: List[Path], runtime_deps: List[Path], recursive: bool =True, - ignore_missing: bool =False) -> None: + ignore_missing: List[str] = []) -> None: if not paths_to_patch: sys.exit("No paths to patch, stopping.") @@ -264,12 +262,19 @@ def auto_patchelf( missing = [dep for dep in dependencies if not dep.found] # Print a summary of the missing dependencies at the end + print(f"auto-patchelf: {len(missing)} dependencies could not be satisfied") + failure = False for dep in missing: - print(f"auto-patchelf could not satisfy dependency {dep.name} wanted by {dep.file}") + if dep.name.name in ignore_missing or "*" in ignore_missing: + print(f"warn: auto-patchelf ignoring missing {dep.name} wanted by {dep.file}") + else: + print(f"error: auto-patchelf could not satisfy dependency {dep.name} wanted by {dep.file}") + failure = True - if missing and not ignore_missing: + if failure: sys.exit('auto-patchelf failed to find all the required dependencies.\n' - 'Add the missing dependencies to --libs or use --ignore-missing.') + 'Add the missing dependencies to --libs or use ' + '`--ignore-missing="foo.so.1 bar.so etc.so"`.') def main() -> None: @@ -280,7 +285,8 @@ def main() -> None: 'libraries in the provided paths.') parser.add_argument( "--ignore-missing", - action="store_true", + nargs="*", + type=str, help="Do not fail when some dependencies are not found.") parser.add_argument( "--no-recurse", diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 9822674196a..661b8597efe 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -53,10 +53,17 @@ autoPatchelf() { esac done + 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=( "*" ) + fi + local runtimeDependenciesArray=($runtimeDependencies) @pythonInterpreter@ @autoPatchelfScript@ \ ${norecurse:+--no-recurse} \ - ${autoPatchelfIgnoreMissingDeps:+--ignore-missing} \ + --ignore-missing "${autoPatchelfIgnoreMissingDeps[@]}" \ --paths "$@" \ --libs "${autoPatchelfLibs[@]}" \ "${extraAutoPatchelfLibs[@]}" \ |