depfixer: always print the file name in messages

The messages are not useful unless we know what file they are about.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-10-13 16:16:11 +02:00
parent c2f1d91b8a
commit 7a5eb6f9aa
1 changed files with 6 additions and 6 deletions

View File

@ -313,17 +313,17 @@ class Elf(DataSizes):
self.bf.seek(offset) self.bf.seek(offset)
self.bf.write(newname) self.bf.write(newname)
def fix_rpath(self, rpath_dirs_to_remove: T.Set[bytes], new_rpath: bytes) -> None: def fix_rpath(self, fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: bytes) -> None:
# The path to search for can be either rpath or runpath. # The path to search for can be either rpath or runpath.
# Fix both of them to be sure. # Fix both of them to be sure.
self.fix_rpathtype_entry(rpath_dirs_to_remove, new_rpath, DT_RPATH) self.fix_rpathtype_entry(fname, rpath_dirs_to_remove, new_rpath, DT_RPATH)
self.fix_rpathtype_entry(rpath_dirs_to_remove, new_rpath, DT_RUNPATH) self.fix_rpathtype_entry(fname, rpath_dirs_to_remove, new_rpath, DT_RUNPATH)
def fix_rpathtype_entry(self, rpath_dirs_to_remove: T.Set[bytes], new_rpath: bytes, entrynum: int) -> None: def fix_rpathtype_entry(self, fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: bytes, entrynum: int) -> None:
rp_off = self.get_entry_offset(entrynum) rp_off = self.get_entry_offset(entrynum)
if rp_off is None: if rp_off is None:
if self.verbose: if self.verbose:
print('File does not have rpath. It should be a fully static executable.') print(f'File {fname!r} does not have an rpath. It should be a fully static executable.')
return return
self.bf.seek(rp_off) self.bf.seek(rp_off)
@ -388,7 +388,7 @@ def fix_elf(fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: T.Optiona
if new_rpath is not None: if new_rpath is not None:
with Elf(fname, verbose) as e: with Elf(fname, verbose) as e:
# note: e.get_rpath() and e.get_runpath() may be useful # note: e.get_rpath() and e.get_runpath() may be useful
e.fix_rpath(rpath_dirs_to_remove, new_rpath) e.fix_rpath(fname, rpath_dirs_to_remove, new_rpath)
def get_darwin_rpaths_to_remove(fname: str) -> T.List[str]: def get_darwin_rpaths_to_remove(fname: str) -> T.List[str]:
out = subprocess.check_output(['otool', '-l', fname], out = subprocess.check_output(['otool', '-l', fname],