Followup for bug 1539355: Make it work for the root directory. r=me
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 31 Mar 2019 07:24:23 +0900
changeset 466993 ac337210f1802a23ba1d158f668f56e4995ae572
parent 466992 040b3a4dc232ee725c756dc054bc23f1baae26d2
child 466994 64d80d922f15c38d97217ea6915e59ddcdb3bd03
push id35789
push userbtara@mozilla.com
push dateSun, 31 Mar 2019 09:00:52 +0000
treeherdermozilla-central@c06dfc552c64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1539355, 1525762
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
Followup for bug 1539355: Make it work for the root directory. r=me When an added file is not under an app or addon directory, its base directory is ''. The code added in bug 1539355 would skip doing its thing in that case, which it shouldn't. Also revert the workaround from bug 1525762.
python/mozbuild/mozpack/packager/__init__.py
python/mozbuild/mozpack/packager/formats.py
--- a/python/mozbuild/mozpack/packager/__init__.py
+++ b/python/mozbuild/mozpack/packager/__init__.py
@@ -280,18 +280,17 @@ class SimplePackager(object):
         else:
             self._file_queue.append(self.formatter.add, path, file)
             if mozpath.basename(path) == 'install.rdf':
                 addon = True
                 install_rdf = file.open().read()
                 if self.UNPACK_ADDON_RE.search(install_rdf):
                     addon = 'unpacked'
                 self._add_addon(mozpath.dirname(path), addon)
-            elif (mozpath.basename(path) == 'manifest.json' and
-                  'modules/' not in path):
+            elif mozpath.basename(path) == 'manifest.json':
                 manifest = file.open().read()
                 try:
                     parsed = json.loads(manifest)
                 except ValueError:
                     pass
                 if isinstance(parsed, dict) and 'manifest_version' in parsed:
                     self._add_addon(mozpath.dirname(path), True)
 
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -266,27 +266,26 @@ class OmniJarFormatter(JarFormatter):
         self._non_resources = non_resources
 
     def _add_base(self, base, addon=False):
         if addon:
             # Because add_base is always called with parents before children,
             # all the possible ancestry of `base` is already present in
             # `_sub_formatter`.
             parent_base = mozpath.basedir(base, self._sub_formatter.keys())
-            if parent_base:
-                rel_base = mozpath.relpath(base, parent_base)
-                # If the addon is under a resource directory, package it in the
-                # omnijar.
-                parent_sub_formatter = self._sub_formatter[parent_base]
-                if parent_sub_formatter.is_resource(rel_base):
-                    omnijar_sub_formatter = \
-                        parent_sub_formatter._sub_formatter[self._omnijar_name]
-                    self._sub_formatter[base] = FlatSubFormatter(
-                        FileRegistrySubtree(rel_base, omnijar_sub_formatter.copier))
-                    return
+            rel_base = mozpath.relpath(base, parent_base)
+            # If the addon is under a resource directory, package it in the
+            # omnijar.
+            parent_sub_formatter = self._sub_formatter[parent_base]
+            if parent_sub_formatter.is_resource(rel_base):
+                omnijar_sub_formatter = \
+                    parent_sub_formatter._sub_formatter[self._omnijar_name]
+                self._sub_formatter[base] = FlatSubFormatter(
+                    FileRegistrySubtree(rel_base, omnijar_sub_formatter.copier))
+                return
             JarFormatter._add_base(self, base, addon)
         else:
             # Initialize a chrome.manifest next to the omnijar file so that
             # there's always a chrome.manifest file, even an empty one.
             path = mozpath.normpath(mozpath.join(base, 'chrome.manifest'))
             if not self.copier.contains(path):
                 self.copier.add(path, ManifestFile(''))
             self._sub_formatter[base] = OmniJarSubFormatter(