Bug 1376550 - Support tar.gz (mac) regeneration of complete.mar r=mshal
authorJustin Wood <Callek@gmail.com>
Tue, 27 Jun 2017 14:00:52 -0700
changeset 601440 f98b5c33cecccc780ed8743f1ea3125105cbed0a
parent 601255 cc903e3f61894e60c3b0efaf05e9a446d1d85888
child 601441 19f13a4e5272de41f21bf3bd8bbd8fbb6718651f
push id66056
push userCallek@gmail.com
push dateWed, 28 Jun 2017 19:19:30 +0000
reviewersmshal
bugs1376550
milestone56.0a1
Bug 1376550 - Support tar.gz (mac) regeneration of complete.mar r=mshal Support OSX Signed nightlies (in the complete.mar too) MozReview-Commit-ID: HXiFGE14wYJ
python/mozbuild/mozbuild/repackaging/mar.py
--- a/python/mozbuild/mozbuild/repackaging/mar.py
+++ b/python/mozbuild/mozbuild/repackaging/mar.py
@@ -2,38 +2,49 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import sys
 import tempfile
 import shutil
 import zipfile
+import tarfile
 import subprocess
 import mozpack.path as mozpath
 from application_ini import get_application_ini_value
 from mozbuild.util import ensureParentDir
 
+
 def repackage_mar(topsrcdir, package, mar, output):
-    if not zipfile.is_zipfile(package):
-        raise Exception("Package file %s is not a valid .zip file." % package)
+    if not zipfile.is_zipfile(package) and not tarfile.is_tarfile(package):
+        raise Exception("Package file %s is not a valid .zip or .tar file." % package)
 
     ensureParentDir(output)
     tmpdir = tempfile.mkdtemp()
     try:
-        z = zipfile.ZipFile(package)
-        z.extractall(tmpdir)
-        filelist = z.namelist()
-        z.close()
+        if zipfile.is_zipfile(package):
+            z = zipfile.ZipFile(package)
+            z.extractall(tmpdir)
+            filelist = z.namelist()
+            z.close()
+        else:
+            z = tarfile.open(package)
+            z.extractall(tmpdir)
+            filelist = z.getnames()
+            z.close()
 
+        toplevel_dirs = set([mozpath.split(f)[0] for f in filelist])
+        excluded_stuff = set([' ', '.background', '.DS_Store', '.VolumeIcon.icns'])
+        toplevel_dirs = toplevel_dirs - excluded_stuff
         # Make sure the .zip file just contains a directory like 'firefox/' at
         # the top, and find out what it is called.
-        toplevel_dirs = set([mozpath.split(f)[0] for f in filelist])
         if len(toplevel_dirs) != 1:
-            raise Exception("Package file is expected to have a single top-level directory (eg: 'firefox'), not: %s" % toplevel_dirs)
+            raise Exception("Package file is expected to have a single top-level directory"
+                            "(eg: 'firefox'), not: %s" % toplevel_dirs)
         ffxdir = mozpath.join(tmpdir, toplevel_dirs.pop())
 
         make_full_update = mozpath.join(topsrcdir, 'tools/update-packaging/make_full_update.sh')
 
         env = os.environ.copy()
         env['MOZ_FULL_PRODUCT_VERSION'] = get_application_ini_value(tmpdir, 'App', 'Version')
         env['MAR'] = mozpath.normpath(mar)