lol

autoPatchelfHook: add `patchelfFlags` option

This may be useful. Eventually. Maybe.

K900 10cb2bd4 c3c65740

+17 -7
+14 -6
pkgs/build-support/setup-hooks/auto-patchelf.py
··· 174 found: bool = False # Whether it was found somewhere 175 176 177 - def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = []) -> list[Dependency]: 178 try: 179 with open_elf(path) as elf: 180 ··· 213 if file_is_dynamic_executable: 214 print("setting interpreter of", path) 215 subprocess.run( 216 - ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()], 217 check=True) 218 rpath += runtime_deps 219 ··· 250 if rpath: 251 print("setting RPATH to:", rpath_str) 252 subprocess.run( 253 - ["patchelf", "--set-rpath", rpath_str, path.as_posix()], 254 check=True) 255 256 return dependencies ··· 262 runtime_deps: List[Path], 263 recursive: bool = True, 264 ignore_missing: List[str] = [], 265 - append_rpaths: List[Path] = []) -> None: 266 267 if not paths_to_patch: 268 sys.exit("No paths to patch, stopping.") ··· 275 dependencies = [] 276 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch): 277 if not path.is_symlink() and path.is_file(): 278 - dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths) 279 280 missing = [dep for dep in dependencies if not dep.found] 281 ··· 333 type=Path, 334 help="Paths to append to all runtime paths unconditionally", 335 ) 336 337 print("automatically fixing dependencies for ELF files") 338 args = parser.parse_args() ··· 344 args.runtime_dependencies, 345 args.recursive, 346 args.ignore_missing, 347 - append_rpaths=args.append_rpaths) 348 349 350 interpreter_path: Path = None # type: ignore
··· 174 found: bool = False # Whether it was found somewhere 175 176 177 + def auto_patchelf_file(path: Path, runtime_deps: list[Path], append_rpaths: List[Path] = [], extra_args: List[str] = []) -> list[Dependency]: 178 try: 179 with open_elf(path) as elf: 180 ··· 213 if file_is_dynamic_executable: 214 print("setting interpreter of", path) 215 subprocess.run( 216 + ["patchelf", "--set-interpreter", interpreter_path.as_posix(), path.as_posix()] + extra_args, 217 check=True) 218 rpath += runtime_deps 219 ··· 250 if rpath: 251 print("setting RPATH to:", rpath_str) 252 subprocess.run( 253 + ["patchelf", "--set-rpath", rpath_str, path.as_posix()] + extra_args, 254 check=True) 255 256 return dependencies ··· 262 runtime_deps: List[Path], 263 recursive: bool = True, 264 ignore_missing: List[str] = [], 265 + append_rpaths: List[Path] = [], 266 + extra_args: List[str] = []) -> None: 267 268 if not paths_to_patch: 269 sys.exit("No paths to patch, stopping.") ··· 276 dependencies = [] 277 for path in chain.from_iterable(glob(p, '*', recursive) for p in paths_to_patch): 278 if not path.is_symlink() and path.is_file(): 279 + dependencies += auto_patchelf_file(path, runtime_deps, append_rpaths, extra_args) 280 281 missing = [dep for dep in dependencies if not dep.found] 282 ··· 334 type=Path, 335 help="Paths to append to all runtime paths unconditionally", 336 ) 337 + parser.add_argument( 338 + "--extra-args", 339 + nargs="*", 340 + type=str, 341 + help="Extra arguments to pass to patchelf" 342 + ) 343 344 print("automatically fixing dependencies for ELF files") 345 args = parser.parse_args() ··· 351 args.runtime_dependencies, 352 args.recursive, 353 args.ignore_missing, 354 + append_rpaths=args.append_rpaths, 355 + extra_args=args.extra_args) 356 357 358 interpreter_path: Path = None # type: ignore
+3 -1
pkgs/build-support/setup-hooks/auto-patchelf.sh
··· 63 64 local appendRunpathsArray=($appendRunpaths) 65 local runtimeDependenciesArray=($runtimeDependencies) 66 @pythonInterpreter@ @autoPatchelfScript@ \ 67 ${norecurse:+--no-recurse} \ 68 --ignore-missing "${ignoreMissingDepsArray[@]}" \ ··· 70 --libs "${autoPatchelfLibs[@]}" \ 71 "${extraAutoPatchelfLibs[@]}" \ 72 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \ 73 - --append-rpaths "${appendRunpathsArray[@]}" 74 } 75 76 # XXX: This should ultimately use fixupOutputHooks but we currently don't have
··· 63 64 local appendRunpathsArray=($appendRunpaths) 65 local runtimeDependenciesArray=($runtimeDependencies) 66 + local patchelfFlagsArray=($patchelfFlags) 67 @pythonInterpreter@ @autoPatchelfScript@ \ 68 ${norecurse:+--no-recurse} \ 69 --ignore-missing "${ignoreMissingDepsArray[@]}" \ ··· 71 --libs "${autoPatchelfLibs[@]}" \ 72 "${extraAutoPatchelfLibs[@]}" \ 73 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \ 74 + --append-rpaths "${appendRunpathsArray[@]}" \ 75 + --extra-args "${patchelfFlagsArray[@]}" 76 } 77 78 # XXX: This should ultimately use fixupOutputHooks but we currently don't have