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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Howell 2019-01-14 21:59:06 +00:00
Родитель 37e3810088
Коммит f8a790571f
4 изменённых файлов: 26 добавлений и 10 удалений

Просмотреть файл

@ -13,12 +13,17 @@ 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']
@ -28,7 +33,7 @@ def archive_exe(pkg_dir, tagfile, sfx_package, package):
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:
@ -38,11 +43,11 @@ def archive_exe(pkg_dir, tagfile, sfx_package, package):
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__':

Просмотреть файл

@ -3054,7 +3054,9 @@ class Repackage(MachCommandBase):
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,
@ -3064,6 +3066,7 @@ class Repackage(MachCommandBase):
output=output,
package_name=package_name,
sfx_stub=sfx_stub,
use_upx=use_upx,
)
@SubCommand('repackage', 'msi',

Просмотреть файл

@ -11,7 +11,7 @@ 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:
@ -42,7 +42,7 @@ def repackage_installer(topsrcdir, tag, setupexe, package, output, package_name,
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)

Просмотреть файл

@ -12,6 +12,12 @@ 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 \
@ -64,7 +70,8 @@ installer:: $(CONFIG_DIR)/setup.exe $(ZIP_IN)
--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
@ -73,7 +80,8 @@ ifdef MOZ_STUB_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::