Skip to content

Commit

Permalink
auto-patchelf: Fix missing defaults and add --no-add-existing option
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Nov 7, 2024
1 parent 3718e9c commit b28ce12
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,17 @@ 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:
sys.exit("No paths to patch, stopping.")

# 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 = []
Expand Down Expand Up @@ -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(
Expand All @@ -394,14 +413,21 @@ 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
# as values for this one. This means this argument should always be passed
# 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")
Expand All @@ -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)


Expand Down

0 comments on commit b28ce12

Please sign in to comment.