bug 1287881 - windows repackage refactored as actions; r=mshal
MozReview-Commit-ID: 2vI6LlMVvLE
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/7z_exe_archive.py
@@ -0,0 +1,35 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+
+import os
+import shutil
+import sys
+import subprocess
+import tempfile
+import mozpack.path as mozpath
+
+def archive_exe(pkg_dir, tagfile, package):
+ tmpdir = tempfile.mkdtemp(prefix='tmp')
+ subprocess.check_call(['upx', '--best', '-o', mozpath.join(tmpdir, '7zSD.sfx'), '../../../other-licenses/7zstub/firefox/7zSD.sfx'])
+ shutil.move(pkg_dir, 'core')
+ subprocess.check_call(['7z', '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'])
+ shutil.move('core', pkg_dir)
+ with open(package, 'wb') as o:
+ for i in [mozpath.join(tmpdir, '7zSD.sfx'), mozpath.join('../../../browser/installer/windows', tagfile), mozpath.join(tmpdir, 'app.7z')]:
+ shutil.copyfileobj(open(i, 'rb'), o)
+ os.chmod(package, 755)
+
+def main(args):
+ if len(args) != 3:
+ print('Usage: 7z_exe_archive.py <pkg_dir> <tagfile> <package>',
+ file=sys.stderr)
+ return 1
+ else:
+ archive_exe(args[0], args[1], args[2])
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/7z_exe_extract.py
@@ -0,0 +1,25 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+
+import shutil
+import sys
+import subprocess
+
+def extract_exe(package, target):
+ subprocess.check_call(['7z', 'x', package, 'core'])
+ shutil.move('core', target)
+
+def main(args):
+ if len(args) != 2:
+ print('Usage: 7z_exe_extract.py <package> <target>',
+ file=sys.stderr)
+ return 1
+ else:
+ extract_exe(args[0], args[1])
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/make_unzip.py
@@ -0,0 +1,23 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+
+import sys
+import subprocess
+
+def make_unzip(package):
+ subprocess.check_call(['unzip', package])
+
+def main(args):
+ if len(args) != 1:
+ print('Usage: make_unzip.py <package>',
+ file=sys.stderr)
+ return 1
+ else:
+ make_unzip(args[0])
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/make_zip.py
@@ -0,0 +1,23 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+
+import sys
+import subprocess
+
+def make_zip(source, package):
+ subprocess.check_call(['zip', '-r9D', package, source, '-x', '\*/.mkdir.done'])
+
+def main(args):
+ if len(args) != 2:
+ print('Usage: make_zip.py <source> <package>',
+ file=sys.stderr)
+ return 1
+ else:
+ make_zip(args[0], args[1])
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
--- a/toolkit/mozapps/installer/upload-files.mk
+++ b/toolkit/mozapps/installer/upload-files.mk
@@ -109,32 +109,24 @@ ifeq ($(MOZ_PKG_FORMAT),BZ2)
endif
ifeq ($(MOZ_PKG_FORMAT),ZIP)
ifdef MOZ_EXTERNAL_SIGNING_FORMAT
# We can't use sha2signcode on zip files
MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out sha2signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT))
endif
PKG_SUFFIX = .zip
- INNER_MAKE_PACKAGE = $(ZIP) -r9D $(PACKAGE) $(MOZ_PKG_DIR) \
- -x \*/.mkdir.done
- INNER_UNMAKE_PACKAGE = $(UNZIP) $(UNPACKAGE)
+ INNER_MAKE_PACKAGE = $(call py_action,make_zip,'$(MOZ_PKG_DIR)' '$(PACKAGE)')
+ INNER_UNMAKE_PACKAGE = $(call py_action,make_unzip,'$(UNPACKAGE)')
endif
ifeq ($(MOZ_PKG_FORMAT),SFX7Z)
PKG_SUFFIX = .exe
- INNER_MAKE_PACKAGE = rm -f app.7z && \
- mv $(MOZ_PKG_DIR) core && \
- $(CYGWIN_WRAPPER) 7z a -r -t7z app.7z -mx -m0=BCJ2 -m1=LZMA:d25 \
- -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 && \
- mv core $(MOZ_PKG_DIR) && \
- cat $(SFX_HEADER) app.7z > $(PACKAGE) && \
- chmod 0755 $(PACKAGE)
- INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) core && \
- mv core $(MOZ_PKG_DIR)
+ INNER_MAKE_PACKAGE = $(call py_action,7z_exe_archive,'$(MOZ_PKG_DIR)' 'app.tag' '$(PACKAGE)')
+ INNER_UNMAKE_PACKAGE = $(call py_action,7z_exe_extract,'$(UNPACKAGE)' '$(MOZ_PKG_DIR)')
endif
#Create an RPM file
ifeq ($(MOZ_PKG_FORMAT),RPM)
PKG_SUFFIX = .rpm
MOZ_NUMERIC_APP_VERSION = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[^0-9.].*//' )
MOZ_RPM_RELEASE = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[0-9.]*//' )