aboutsummaryrefslogtreecommitdiff
path: root/linaro_image_tools/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'linaro_image_tools/utils.py')
-rw-r--r--linaro_image_tools/utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/linaro_image_tools/utils.py b/linaro_image_tools/utils.py
index c8d9682..2710c02 100644
--- a/linaro_image_tools/utils.py
+++ b/linaro_image_tools/utils.py
@@ -89,11 +89,21 @@ CommandNotFound = try_import('CommandNotFound.CommandNotFound')
def path_in_tarfile_exists(path, tar_file):
exists = True
try:
- tarinfo = tarfile.open(tar_file, 'r:gz')
+ tarinfo = tarfile.open(tar_file, 'r:*')
tarinfo.getmember(path)
tarinfo.close()
except KeyError:
exists = False
+ except (tarfile.ReadError, tarfile.CompressionError):
+ exists = False
+ # Fallback to tar command
+ cmd = ['tar', '-tf', tar_file, '--wildcards', '*' + path]
+ proc = cmd_runner.run(cmd,
+ stdout=open('/dev/null', 'w'),
+ stderr=open('/dev/null', 'w'))
+ proc.wait()
+ if proc.returncode == 0:
+ exists = True
finally:
return exists