diff options
author | K900 <me@0upti.me> | 2023-10-02 08:07:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 08:07:03 +0300 |
commit | 03fddbfb87e99d1505eb483213988c1937fb2f21 (patch) | |
tree | b20be8cb041b7c19d22f0c85800cc99d154eedbc /pkgs/build-support | |
parent | 3bf47679b788c3dd77c553a92b7414b26ee843f6 (diff) | |
parent | 2893902201e2cb2cebaaf3a8da61622675f20887 (diff) | |
download | nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar.gz nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar.bz2 nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar.lz nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar.xz nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.tar.zst nixpkgs-03fddbfb87e99d1505eb483213988c1937fb2f21.zip |
Merge pull request #256525 from K900/auto-patchelf-flags
autoPatchelfHook: add `patchelfFlags` option
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.py | 20 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.sh | 4 |
2 files changed, 17 insertions, 7 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.py b/pkgs/build-support/setup-hooks/auto-patchelf.py index 965384b876f..261f5585480 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.py +++ b/pkgs/build-support/setup-hooks/auto-patchelf.py @@ -174,7 +174,7 @@ class Dependency: found: bool = False # Whether it was found somewhere -def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = []) -> list[Dependency]: +def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = [], extra_args: List[str] = []) -> list[Dependency]: try: with open_elf(path) as elf: @@ -213,7 +213,7 @@ def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List if file_is_dynamic_executable: print("setting interpreter of", path) subprocess.run( - ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()], + ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()] + extra_args, check=True) rpath += runtime_deps @@ -250,7 +250,7 @@ def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List if rpath: print("setting RPATH to:", rpath_str) subprocess.run( - ["patchelf", "--set-rpath", rpath_str, path.as_posix()], + ["patchelf", "--set-rpath", rpath_str, path.as_posix()] + extra_args, check=True) return dependencies @@ -262,7 +262,8 @@ def auto_patchelf( runtime_deps: List[Path], recursive: bool = True, ignore_missing: List[str] = [], - append_rpaths: List[Path] = []) -> None: + append_rpaths: List[Path] = [], + extra_args: List[str] = []) -> None: if not paths_to_patch: sys.exit("No paths to patch, stopping.") @@ -275,7 +276,7 @@ def auto_patchelf( dependencies = [] for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch): if not path.is_symlink() and path.is_file(): - dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths) + dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths, extra_args) missing = [dep for dep in dependencies if not dep.found] @@ -333,6 +334,12 @@ def main() -> None: type=Path, help="Paths to append to all runtime paths unconditionally", ) + parser.add_argument( + "--extra-args", + nargs="*", + type=str, + help="Extra arguments to pass to patchelf" + ) print("automatically fixing dependencies for ELF files") args = parser.parse_args() @@ -344,7 +351,8 @@ def main() -> None: args.runtime_dependencies, args.recursive, args.ignore_missing, - append_rpaths=args.append_rpaths) + append_rpaths=args.append_rpaths, + extra_args=args.extra_args) interpreter_path: Path = None # type: ignore diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 0625565606f..371389df427 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -63,6 +63,7 @@ autoPatchelf() { local appendRunpathsArray=($appendRunpaths) local runtimeDependenciesArray=($runtimeDependencies) + local patchelfFlagsArray=($patchelfFlags) @pythonInterpreter@ @autoPatchelfScript@ \ ${norecurse:+--no-recurse} \ --ignore-missing "${ignoreMissingDepsArray[@]}" \ @@ -70,7 +71,8 @@ autoPatchelf() { --libs "${autoPatchelfLibs[@]}" \ "${extraAutoPatchelfLibs[@]}" \ --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \ - --append-rpaths "${appendRunpathsArray[@]}" + --append-rpaths "${appendRunpathsArray[@]}" \ + --extra-args "${patchelfFlagsArray[@]}" } # XXX: This should ultimately use fixupOutputHooks but we currently don't have |