Bug 1514806 Part 6 - Disable running UPX in the installer package for targets it doesn't support. r=firefox-build-system-reviewers,mshal#firefox-build-system-reviewers
☠☠ backed out by 113f3db802c4 ☠ ☠
authorMatt Howell <mhowell@mozilla.com>
Mon, 14 Jan 2019 21:59:06 +0000
changeset 511047 63debb1d02d3ca285def538c88c1e47295923613
parent 511046 803d20ba3f80ac06fecc01646440d288592fbef4
child 511048 ad473f67f76950921b049ffe896dd25a0e987de6
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, mshal
bugs1514806
milestone66.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 1514806 Part 6 - Disable running UPX in the installer package for targets it doesn't support. r=firefox-build-system-reviewers,mshal#firefox-build-system-reviewers Differential Revision: https://phabricator.services.mozilla.com/D15984
python/mozbuild/mozbuild/action/exe_7z_archive.py
python/mozbuild/mozbuild/mach_commands.py
python/mozbuild/mozbuild/repackaging/installer.py
toolkit/mozapps/installer/windows/nsis/makensis.mk
--- a/python/mozbuild/mozbuild/action/exe_7z_archive.py
+++ b/python/mozbuild/mozbuild/action/exe_7z_archive.py
@@ -8,42 +8,47 @@ import os
 import shutil
 import sys
 import subprocess
 import tempfile
 import mozpack.path as mozpath
 import buildconfig
 from mozbuild.base import BuildEnvironmentNotFoundException
 
-def archive_exe(pkg_dir, tagfile, sfx_package, package):
+def archive_exe(pkg_dir, tagfile, sfx_package, package, use_upx):
     tmpdir = tempfile.mkdtemp(prefix='tmp')
     try:
         if pkg_dir:
             shutil.move(pkg_dir, 'core')
-        subprocess.check_call(['upx', '--best', '-o', mozpath.join(tmpdir, '7zSD.sfx'), sfx_package])
+
+        if use_upx:
+            final_sfx = mozpath.join(tmpdir, '7zSD.sfx')
+            subprocess.check_call(['upx', '--best', '-o', final_sfx, sfx_package])
+        else:
+            final_sfx = sfx_package
 
         try:
             sevenz = buildconfig.config.substs['7Z']
         except BuildEnvironmentNotFoundException:
             # configure hasn't been run, just use the default
             sevenz = '7z'
         subprocess.check_call([sevenz, 'a', '-r', '-t7z', mozpath.join(tmpdir, 'app.7z'), '-mx', '-m0=BCJ2', '-m1=LZMA:d25', '-m2=LZMA:d19', '-m3=LZMA:d19', '-mb0:1', '-mb0s1:2', '-mb0s2:3'])
 
         with open(package, 'wb') as o:
-            for i in [mozpath.join(tmpdir, '7zSD.sfx'), tagfile, mozpath.join(tmpdir, 'app.7z')]:
+            for i in [final_sfx, tagfile, mozpath.join(tmpdir, 'app.7z')]:
                 shutil.copyfileobj(open(i, 'rb'), o)
         os.chmod(package, 0o0755)
     finally:
         if pkg_dir:
             shutil.move('core', pkg_dir)
         shutil.rmtree(tmpdir)
 
 def main(args):
     if len(args) != 4:
-        print('Usage: exe_7z_archive.py <pkg_dir> <tagfile> <sfx_package> <package>',
+        print('Usage: exe_7z_archive.py <pkg_dir> <tagfile> <sfx_package> <package> <use_upx>',
               file=sys.stderr)
         return 1
     else:
-        archive_exe(args[0], args[1], args[2], args[3])
+        archive_exe(args[0], args[1], args[2], args[3], args[4])
         return 0
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -3049,26 +3049,29 @@ class Repackage(MachCommandBase):
     @CommandArgument('--package', type=str, required=False,
         help='Optional package .zip for building a full installer')
     @CommandArgument('--output', '-o', type=str, required=True,
         help='Output filename')
     @CommandArgument('--package-name', type=str, required=False,
         help='Name of the package being rebuilt')
     @CommandArgument('--sfx-stub', type=str, required=True,
         help='Path to the self-extraction stub.')
-    def repackage_installer(self, tag, setupexe, package, output, package_name, sfx_stub):
+    @CommandArgument('--use-upx', required=False, action='store_true',
+        help='Run UPX on the self-extraction stub.')
+    def repackage_installer(self, tag, setupexe, package, output, package_name, sfx_stub, use_upx):
         from mozbuild.repackaging.installer import repackage_installer
         repackage_installer(
             topsrcdir=self.topsrcdir,
             tag=tag,
             setupexe=setupexe,
             package=package,
             output=output,
             package_name=package_name,
             sfx_stub=sfx_stub,
+            use_upx=use_upx,
         )
 
     @SubCommand('repackage', 'msi',
                 description='Repackage into a MSI')
     @CommandArgument('--wsx', type=str, required=True,
         help='The wsx file used to build the installer')
     @CommandArgument('--version', type=str, required=True,
         help='The Firefox version used to create the installer')
--- a/python/mozbuild/mozbuild/repackaging/installer.py
+++ b/python/mozbuild/mozbuild/repackaging/installer.py
@@ -6,17 +6,17 @@ import os
 import tempfile
 import shutil
 import zipfile
 import mozpack.path as mozpath
 from mozbuild.action.exe_7z_archive import archive_exe
 from mozbuild.util import ensureParentDir
 
 
-def repackage_installer(topsrcdir, tag, setupexe, package, output, package_name, sfx_stub):
+def repackage_installer(topsrcdir, tag, setupexe, package, output, package_name, sfx_stub, use_upx):
     if package and not zipfile.is_zipfile(package):
         raise Exception("Package file %s is not a valid .zip file." % package)
     if package is not None and package_name is None:
         raise Exception("Package name must be provided, if a package is provided.")
     if package is None and package_name is not None:
         raise Exception("Package name must not be provided, if a package is not provided.")
 
     # We need the full path for the tag and output, since we chdir later.
@@ -37,13 +37,13 @@ def repackage_installer(topsrcdir, tag, 
         shutil.copyfile(setupexe, mozpath.join(tmpdir, mozpath.basename(setupexe)))
 
         # archive_exe requires us to be in the directory where the package is
         # unpacked (the tmpdir)
         os.chdir(tmpdir)
 
         sfx_package = mozpath.join(topsrcdir, sfx_stub)
 
-        archive_exe(package_name, tag, sfx_package, output)
+        archive_exe(package_name, tag, sfx_package, output, use_upx)
 
     finally:
         os.chdir(old_cwd)
         shutil.rmtree(tmpdir)
--- a/toolkit/mozapps/installer/windows/nsis/makensis.mk
+++ b/toolkit/mozapps/installer/windows/nsis/makensis.mk
@@ -7,16 +7,22 @@ ifndef CONFIG_DIR
 endif
 
 include $(MOZILLA_DIR)/toolkit/mozapps/installer/signing.mk
 
 ABS_CONFIG_DIR := $(abspath $(CONFIG_DIR))
 
 SFX_MODULE ?= $(error SFX_MODULE is not defined)
 
+ifeq ($(CPU_ARCH), aarch64)
+USE_UPX := 
+else
+USE_UPX := --use-upx
+endif
+
 TOOLKIT_NSIS_FILES = \
 	common.nsh \
 	locale.nlf \
 	locale-fonts.nsh \
 	locale-rtl.nlf \
 	locales.nsi \
 	overrides.nsh \
 	setup.ico \
@@ -59,26 +65,28 @@ installer:: $(CONFIG_DIR)/setup.exe $(ZI
 	@echo 'Packaging $(WIN32_INSTALLER_OUT).'
 	$(NSINSTALL) -D '$(ABS_DIST)/$(PKG_INST_PATH)'
 	$(MOZILLA_DIR)/mach repackage installer \
 	  -o '$(ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe' \
 	  --package-name '$(MOZ_PKG_DIR)' \
 	  --package '$(ZIP_IN)' \
 	  --tag $(topsrcdir)/$(MOZ_BUILD_APP)/installer/windows/app.tag \
 	  --setupexe $(CONFIG_DIR)/setup.exe \
-	  --sfx-stub $(SFX_MODULE)
+	  --sfx-stub $(SFX_MODULE) \
+	  $(USE_UPX)
 ifdef MOZ_EXTERNAL_SIGNING_FORMAT
 	$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) "$(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
 endif
 ifdef MOZ_STUB_INSTALLER
 	$(MOZILLA_DIR)/mach repackage installer \
 	  -o '$(ABS_DIST)/$(PKG_INST_PATH)$(PKG_STUB_BASENAME).exe' \
 	  --tag $(topsrcdir)/browser/installer/windows/stub.tag \
 	  --setupexe $(CONFIG_DIR)/setup-stub.exe \
-	  --sfx-stub $(SFX_MODULE)
+	  --sfx-stub $(SFX_MODULE) \
+	  $(USE_UPX)
 endif
 else
 installer::
 	$(error ZIP_IN must be set when building installer)
 endif
 
 # For building the uninstaller during the application build so it can be
 # included for mar file generation.