Bug 1546870 - Make extracting .tar.xz work with mach artifact toolchain. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 27 Apr 2019 21:56:47 +0000
changeset 530492 deb76e88424bd4e39b1fd949bec3233ea3e505bd
parent 530491 a584e4e9473fd33a2d97fd4da72facb53e0dd53e
child 530493 8c3a37a0a53e8a2b99473cb8bb44201165b402be
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1546870
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
python/mozbuild/mozbuild/action/tooltool.py
--- a/python/mozbuild/mozbuild/action/tooltool.py
+++ b/python/mozbuild/mozbuild/action/tooltool.py
@@ -554,17 +554,22 @@ def unpack_file(filename):
         tar.extractall()
         tar.close()
     elif filename.endswith('.tar.xz'):
         base_file = filename.replace('.tar.xz', '')
         if _cache_checksum_matches(base_file, checksum):
             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', '')
         if _cache_checksum_matches(base_file, checksum):
             return True
         clean_path(base_file)
         log.info('unzipping "%s"' % filename)
         z = zipfile.ZipFile(filename)