Bug 1733273 - Pre: Allow to have UnpackFinder not unpack embedded XPI files. r=firefox-build-system-reviewers,mhentges,glandium

Signed langpack XPI files produced by automation are ZIP files that
have central and local directory mismatches, which `mozjar.py` and
therefore `UnpackFinder` do not handle at this time.  This flag, which
defaults to unpacking, allows to not unpack the embedded XPI files.

Differential Revision: https://phabricator.services.mozilla.com/D127582
This commit is contained in:
Nick Alexander 2021-10-07 18:48:09 +00:00
parent 27d1eec33b
commit 1fa8bb82c7

View File

@ -42,7 +42,7 @@ class UnpackFinder(BaseFinder):
or with files from a FileFinder using the given path as its root.
"""
def __init__(self, source, omnijar_name=None):
def __init__(self, source, omnijar_name=None, unpack_xpi=True):
if isinstance(source, BaseFinder):
self._finder = source
else:
@ -59,6 +59,7 @@ class UnpackFinder(BaseFinder):
self.omnijar = substs.get("OMNIJAR_NAME", "omni.ja")
self.jarlogs = {}
self.compressed = False
self._unpack_xpi = unpack_xpi
jars = set()
@ -89,9 +90,9 @@ class UnpackFinder(BaseFinder):
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):
# If we're unpacking packed addons and the file is a packed addon,
# unpack it under a directory named after the xpi.
if self._unpack_xpi and p.endswith(".xpi") and self._maybe_zip(f):
self._fill_with_jar(p[:-4], self._open_jar(p, f))
continue
if p not in jars: