Bug 1546870 - Make extracting .tar.xz work with mach artifact toolchain. r=froydnj

For some reason, using `tar -Jxf` with Windows paths fails, and that makes
`mach artifact toolchain` unable to pull .tar.xz archives on Windows.

However, executing `xz -d -c` works, and we can feed its output to
python's tarfile.

Differential Revision: https://phabricator.services.mozilla.com/D28779

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2019-04-27 21:56:47 +00:00
Родитель ca39c407dd
Коммит 53b22118b5
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -559,7 +559,12 @@ def unpack_file(filename):
return True
clean_path(base_file)
log.info('untarring "%s"' % filename)
if not execute('tar -Jxf %s 2>&1' % filename):
# Not using tar -Jxf because it fails on Windows for some reason.
process = Popen(['xz', '-d', '-c', filename], stdout=PIPE)
tar = tarfile.open(fileobj=process.stdout, mode='r|')
tar.extractall()
tar.close()
if not process.wait():
return False
elif zipfile.is_zipfile(filename):
base_file = filename.replace('.zip', '')