Index: build_release.py |
=================================================================== |
deleted file mode 100755 |
--- a/build_release.py |
+++ /dev/null |
@@ -1,95 +0,0 @@ |
-#!/usr/bin/env python |
- |
-import glob |
-import json |
-import os |
-import shutil |
-import subprocess |
-import sys |
-import tempfile |
- |
-BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
-ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py") |
-MACH_PATH = os.path.join(BASE_DIR, "mach") |
-DIST_PATH = os.path.join(BASE_DIR, "obj-arm-linux-androideabi", "dist") |
- |
-def print_usage(): |
- print >>sys.stderr, "Usage: %s devbuild|release KEY_STORE KEY_NAME" % \ |
- os.path.basename(sys.argv[0]) |
- |
-def check_mozconfig(path, mode): |
- if not os.path.exists(path): |
- raise Exception("'%s' doesn't exist, please create it." % path) |
- |
- with open(path) as file: |
- contents = file.read() |
- |
- # This check can be removed once https://issues.adblockplus.org/ticket/2490 is |
- # done. |
- if "--disable-crashreporter" not in contents: |
- raise Exception( |
- "'%s' doesn't seem to set --disable-crashreporter, please do." % path) |
- |
- if "export MOZILLA_OFFICIAL=1" not in contents: |
- raise Exception( |
- "'%s' doesn't seem to export MOZILLA_OFFICIAL=1, please do." % path) |
- |
- updater_disabled = "--disable-updater" in contents |
- if updater_disabled and mode == "devbuild": |
- raise Exception("'%s' seems to set --disable-updater, please don't." % path) |
- elif not updater_disabled and mode == "release": |
- raise Exception( |
- "'%s' doesn't seem to set --disable-updater, please do." % path) |
- |
-def find_mozconfig(mode): |
- mozconfig_path = os.path.join(BASE_DIR, ".mozconfig-" + mode) |
- check_mozconfig(mozconfig_path, mode) |
- return mozconfig_path |
- |
-def build(mode): |
- mach_environment = os.environ.copy() |
- mach_environment["MOZCONFIG"] = find_mozconfig(mode) |
- subprocess.check_call([MACH_PATH, "clobber"], env=mach_environment) |
- subprocess.check_call([MACH_PATH, "build"], env=mach_environment) |
- subprocess.check_call([MACH_PATH, "package"], env=mach_environment) |
- |
- [manifest_path] = glob.glob(os.path.join( |
- DIST_PATH, "fennec-*.en-US.android-arm.json")) |
- with open(manifest_path) as manifest_file: |
- manifest = json.load(manifest_file) |
- |
- apk_path = os.path.join(DIST_PATH, "gecko-unsigned-unaligned.apk") |
- if mode == "release": |
- target_apk_name = "adblockbrowser-%s-arm.apk" % manifest["moz_app_version"] |
- else: |
- target_apk_name = "adblockbrowser-%s.%s-arm.apk" % ( |
- manifest["moz_app_version"], manifest["buildid"]) |
- target_apk_path = os.path.join(DIST_PATH, target_apk_name) |
- shutil.copyfile(apk_path, target_apk_path) |
- return target_apk_path |
- |
-def sign(apk_path, key_store, key_name): |
- temp_apk_path = tempfile.NamedTemporaryFile().name |
- shutil.copyfile(apk_path, temp_apk_path) |
- try: |
- subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA", |
- "-digestalg", "SHA1", "-keystore", key_store, |
- temp_apk_path, key_name]) |
- os.remove(apk_path) |
- subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path]) |
- finally: |
- os.remove(temp_apk_path) |
- |
-if __name__ == "__main__": |
- if len(sys.argv) < 4: |
- print_usage() |
- sys.exit(1) |
- |
- mode, key_store, key_name = sys.argv[1:] |
- if mode not in ("devbuild", "release"): |
- print_usage() |
- sys.exit(2) |
- |
- subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) |
- apk_path = build(mode) |
- sign(apk_path, key_store, key_name) |