aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2021-04-15 21:27:56 -0400
committerMike Frysinger <vapier@gentoo.org>2021-04-15 21:37:31 -0400
commit6912679ba7a2fe42f13244dff537fa8338050c2c (patch)
tree039dba57440cacfba685720a895b2a74bc2c3ebc /lddtree.py
parentlddtree: require Python 3.6+ (diff)
downloadpax-utils-6912679ba7a2fe42f13244dff537fa8338050c2c.tar.gz
pax-utils-6912679ba7a2fe42f13244dff537fa8338050c2c.tar.bz2
pax-utils-6912679ba7a2fe42f13244dff537fa8338050c2c.zip
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@gentoo.org>
Diffstat (limited to 'lddtree.py')
-rwxr-xr-xlddtree.py8
1 files changed, 7 insertions, 1 deletions
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: