diff options
author | 2015-11-17 14:42:43 +0000 | |
---|---|---|
committer | 2015-11-18 15:23:57 +0000 | |
commit | 976211dd45215a6146e0ab312186de0eaa955a75 (patch) | |
tree | f3c7e211fb52787072aba3fd557233549cf1cfc2 /tools/build_defs/pkg/archive.py | |
parent | 3d8469522d4b356feb2fc85e65314abb74d47d91 (diff) |
[docker] Print a clearer message when xzcat cannot be found and is needed
Also use the default shell env for docker deb files.
Fixes #611.
--
MOS_MIGRATED_REVID=108035989
Diffstat (limited to 'tools/build_defs/pkg/archive.py')
-rw-r--r-- | tools/build_defs/pkg/archive.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/build_defs/pkg/archive.py b/tools/build_defs/pkg/archive.py index 6660663c41..10d5298ae4 100644 --- a/tools/build_defs/pkg/archive.py +++ b/tools/build_defs/pkg/archive.py @@ -15,6 +15,7 @@ import os from StringIO import StringIO +import subprocess import tarfile @@ -290,6 +291,9 @@ class TarFileWriter(object): the file is to be added to the final tar and false otherwise. root: place all non-absolute content under given root direcory, if not None. + + Raises: + TarFileWriter.Error: if an error happens when uncompressing the tar file. """ compression = os.path.splitext(tar)[-1][1:] if compression == 'tgz': @@ -308,7 +312,14 @@ class TarFileWriter(object): # large files. # TODO(dmarting): once our py3 support gets better, compile this tools # with py3 for proper lzma support. - f = StringIO(os.popen('cat %s | xzcat' % tar).read()) + if subprocess.call('which xzcat', shell=True): + raise self.Error('Cannot handle .xz and .lzma compression: ' + 'xzcat not found.') + p = subprocess.Popen('cat %s | xzcat' % tar, + shell=True, + stdout=subprocess.PIPE) + p.wait() + f = StringIO(p.stdout.read()) intar = tarfile.open(fileobj=f, mode='r:') else: intar = tarfile.open(name=tar, mode='r:' + compression) |