Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions infra/base-images/base-builder/indexer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def patch_binary_rpath_and_interpreter(
lib_mount_path: pathlib.Path,
ld_binary_path: pathlib.Path = LD_BINARY_PATH_X86_64,
extra_rpath_entries: Sequence[pathlib.Path] = (),
patch_interpreter: bool = True,
):
"""Patches the binary rpath and interpreter.

Expand All @@ -142,6 +143,7 @@ def patch_binary_rpath_and_interpreter(
ld_binary_path: Basename / path of the dynamic linker.
extra_rpath_entries: Additional directories prepended to the RPATH (searched
before ``lib_mount_path``).
patch_interpreter: Whether to patch the ELF interpreter.
"""
rpath = ":".join(p.as_posix() for p in [*extra_rpath_entries, lib_mount_path])
subprocess.run(
Expand All @@ -155,15 +157,16 @@ def patch_binary_rpath_and_interpreter(
check=True,
)

subprocess.run(
[
"patchelf",
"--set-interpreter",
(lib_mount_path / ld_binary_path.name).as_posix(),
binary_path,
],
check=True,
)
if patch_interpreter:
subprocess.run(
[
"patchelf",
"--set-interpreter",
(lib_mount_path / ld_binary_path.name).as_posix(),
binary_path,
],
check=True,
)


def get_library_mount_path(binary_id: str) -> pathlib.Path:
Expand Down
Loading