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 938ea631011863..b72c4ef022ccdd 100644 --- a/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py +++ b/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py @@ -317,6 +317,7 @@ def auto_patchelf( ignore_missing: list[str] = [], append_rpaths: list[Path] = [], keep_libc: bool = False, + add_existing: bool = True, extra_args: list[str] = []) -> None: if not paths_to_patch: @@ -324,7 +325,9 @@ def auto_patchelf( # Add all shared objects of the current output path to the cache, # before lib_dirs, so that they are chosen first in find_dependency. - populate_cache(paths_to_patch, recursive) + if add_existing: + populate_cache(paths_to_patch, recursive) + populate_cache(lib_dirs) dependencies = [] @@ -362,30 +365,46 @@ def main() -> None: "--ignore-missing", nargs="*", type=str, - help="Do not fail when some dependencies are not found.") + default=[], + help="Do not fail when some dependencies are not found." + ) parser.add_argument( "--no-recurse", dest="recursive", action="store_false", - help="Disable the recursive traversal of paths to patch.") + help="Disable the recursive traversal of paths to patch." + ) parser.add_argument( - "--paths", nargs="*", type=Path, + "--paths", + nargs="*", + type=Path, + required=True, help="Paths whose content needs to be patched." " Single files and directories are accepted." - " Directories are traversed recursively by default.") + " Directories are traversed recursively by default." + ) parser.add_argument( - "--libs", nargs="*", type=Path, + "--libs", + nargs="*", + type=Path, + default=[], help="Paths where libraries are searched for." " Single files and directories are accepted." - " Directories are not searched recursively.") + " Directories are not searched recursively." + ) parser.add_argument( - "--runtime-dependencies", nargs="*", type=Path, + "--runtime-dependencies", + nargs="*", + type=Path, + default=[], help="Paths to prepend to the runtime path of executable binaries." - " Subject to deduplication, which may imply some reordering.") + " Subject to deduplication, which may imply some reordering." + ) parser.add_argument( "--append-rpaths", nargs="*", type=Path, + default=[], help="Paths to append to all runtime paths unconditionally", ) parser.add_argument( @@ -394,6 +413,12 @@ def main() -> None: action="store_true", help="Attempt to search for and relink libc dependencies.", ) + parser.add_argument( + "--no-add-existing", + dest="add_existing", + action="store_false", + help="Do not add the existing rpaths of the patched files to the list of directories to search for dependencies.", + ) parser.add_argument( "--extra-args", # Undocumented Python argparse feature: consume all remaining arguments @@ -401,7 +426,8 @@ def main() -> None: # last. nargs="...", type=str, - help="Extra arguments to pass to patchelf. This argument should always come last." + default=[], + help="Extra arguments to pass to patchelf. This argument should always come last.", ) print("automatically fixing dependencies for ELF files") @@ -416,6 +442,7 @@ def main() -> None: args.ignore_missing, append_rpaths=args.append_rpaths, keep_libc=args.keep_libc, + add_existing=args.add_existing, extra_args=args.extra_args)