commit: 6912679ba7a2fe42f13244dff537fa8338050c2c
Author: Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Fri Apr 16 01:27:56 2021 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Apr 16 01:37:31 2021 +0000
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=6912679b
lddtree: don't crash when interp is missing
Easy way to reproduce is to copy a cross-compile ELF like:
$ ./lddtree.py --copy-to-tree $PWD/foo /usr/share/qemu/s390-ccw.img
lddtree.py: warning: /usr/share/qemu/s390-ccw.img: [Errno 2] No such file or
directory: '/lib/ld64.so.1'
We have checks for missing libs already, but interps are full paths
and thus bypass the resolution logic.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
lddtree.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lddtree.py b/lddtree.py
index b65c3f2..e3dafda 100755
--- a/lddtree.py
+++ b/lddtree.py
@@ -589,8 +589,14 @@ def _ActionCopy(options, elf):
os.makedirs(os.path.dirname(dst), exist_ok=True)
try:
shutil.copy2(realsrc, dst)
+ except FileNotFoundError as e:
+ warn(f'{elf["path"]}: {e}')
+ return
except IOError:
- os.unlink(dst)
+ try:
+ os.unlink(dst)
+ except FileNotFoundError:
+ pass
shutil.copy2(realsrc, dst)
if wrapit: