Bug 1216371 - Pack addons that can be packed as XPIs. r=gps

This commit is contained in:
Mike Hommey 2015-11-11 18:02:41 +09:00
parent 64caa928cc
commit eb0978518b
3 changed files with 49 additions and 22 deletions

View File

@ -187,9 +187,14 @@ class JarFormatter(PiecemealFormatter):
self._optimize=optimize
def _add_base(self, base, addon=False):
self._sub_formatter[base] = JarSubFormatter(
FileRegistrySubtree(base, self.copier),
self._compress, self._optimize)
if addon is True:
jarrer = Jarrer(self._compress, self._optimize)
self.copier.add(base + '.xpi', jarrer)
self._sub_formatter[base] = FlatSubFormatter(jarrer)
else:
self._sub_formatter[base] = JarSubFormatter(
FileRegistrySubtree(base, self.copier),
self._compress, self._optimize)
class JarSubFormatter(PiecemealFormatter):

View File

@ -64,7 +64,7 @@ class UnpackFinder(FileFinder):
if 'chrome.manifest' in jar:
self.kind = 'omni'
self.omnijar = mozpath.basename(p)
self._fill_with_omnijar(base, jar)
self._fill_with_jar(base, jar)
continue
# If the file is a manifest, scan its entries for some referencing
# jar: urls. If there are some, the files contained in the jar they
@ -77,10 +77,15 @@ class UnpackFinder(FileFinder):
if self.files.contains(p):
continue
f = m
# If the file is a packed addon, unpack it under a directory named
# after the xpi.
if p.endswith('.xpi') and self._maybe_zip(f):
self._fill_with_jar(p[:-4], self._open_jar(p, f))
continue
if not p in jars:
self.files.add(p, f)
def _fill_with_omnijar(self, base, jar):
def _fill_with_jar(self, base, jar):
for j in jar:
path = mozpath.join(base, j.filename)
if is_manifest(j.filename):

View File

@ -35,7 +35,8 @@ CONTENTS = {
# base_path: is_addon?
'': False,
'app': False,
'addon0': True,
'addon0': 'unpacked',
'addon1': True,
},
'manifests': [
ManifestContent('chrome/f', 'oo', 'oo/'),
@ -45,6 +46,7 @@ CONTENTS = {
ManifestContent('app/chrome', 'content', 'foo/'),
ManifestComponent('app/components', '{foo-id}', 'foo.js'),
ManifestContent('addon0/chrome', 'content', 'foo/bar/'),
ManifestContent('addon1/chrome', 'content', 'foo/bar/'),
],
'files': {
'chrome/f/oo/bar/baz': GeneratedFile('foobarbaz'),
@ -59,6 +61,9 @@ CONTENTS = {
'addon0/chrome/foo/bar/baz': GeneratedFile('foobarbaz'),
'addon0/components/foo.xpt': foo2_xpt,
'addon0/components/bar.xpt': bar_xpt,
'addon1/chrome/foo/bar/baz': GeneratedFile('foobarbaz'),
'addon1/components/foo.xpt': foo2_xpt,
'addon1/components/bar.xpt': bar_xpt,
},
}
@ -102,23 +107,30 @@ RESULT_FLAT = {
'component {foo-id} foo.js',
],
'app/components/foo.js': FILES['app/components/foo.js'],
'addon0/chrome.manifest': [
'manifest chrome/chrome.manifest',
'manifest components/components.manifest',
],
'addon0/chrome/chrome.manifest': [
'content content foo/bar/',
],
'addon0/chrome/foo/bar/baz': FILES['addon0/chrome/foo/bar/baz'],
'addon0/components/components.manifest': [
'interfaces interfaces.xpt',
],
'addon0/components/interfaces.xpt': {
'foo': read_interfaces(foo2_xpt.open())['foo'],
'bar': read_interfaces(bar_xpt.open())['bar'],
},
}
for addon in ('addon0', 'addon1'):
RESULT_FLAT.update({
mozpath.join(addon, p): f
for p, f in {
'chrome.manifest': [
'manifest chrome/chrome.manifest',
'manifest components/components.manifest',
],
'chrome/chrome.manifest': [
'content content foo/bar/',
],
'chrome/foo/bar/baz': FILES[mozpath.join(addon, 'chrome/foo/bar/baz')],
'components/components.manifest': [
'interfaces interfaces.xpt',
],
'components/interfaces.xpt': {
'foo': read_interfaces(foo2_xpt.open())['foo'],
'bar': read_interfaces(bar_xpt.open())['bar'],
},
}.iteritems()
})
RESULT_JAR = {
p: RESULT_FLAT[p]
for p in (
@ -160,6 +172,11 @@ RESULT_JAR.update({
'addon0/chrome/foo.jar': {
'bar/baz': FILES['addon0/chrome/foo/bar/baz'],
},
'addon1.xpi': {
mozpath.relpath(p, 'addon1'): f
for p, f in RESULT_FLAT.iteritems()
if p.startswith('addon1/')
},
})
RESULT_OMNIJAR = {
@ -173,7 +190,7 @@ RESULT_OMNIJAR = {
RESULT_OMNIJAR.update({
p: RESULT_JAR[p]
for p in RESULT_JAR
if p.startswith('addon0/')
if p.startswith('addon')
})
RESULT_OMNIJAR.update({