Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 29323540: Issue 2751 - Move signing options to config.py (Closed)
Patch Set: Created Aug. 13, 2015, 7:11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | config.py.sample » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import glob 3 import glob
4 import json 4 import json
5 import os 5 import os
6 import shutil 6 import shutil
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 10
11 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 11 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
12 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py") 12 ENSURE_DEPENDENCIES_PATH = os.path.join(BASE_DIR, "ensure_dependencies.py")
13 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts", 13 MULTI_L10N_PATH = os.path.join(BASE_DIR, "mozharness", "scripts",
14 "multil10n.py") 14 "multil10n.py")
15 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser", 15 DIST_PATH = os.path.join(BASE_DIR, "adblockbrowser",
16 "obj-arm-linux-androideabi", "dist") 16 "obj-arm-linux-androideabi", "dist")
17 17
18 def print_usage(): 18 def print_usage():
19 print >>sys.stderr, "Usage: %s devbuild|release KEY_STORE KEY_NAME" % \ 19 print >>sys.stderr, "Usage: %s devbuild|release" % \
20 os.path.basename(sys.argv[0]) 20 os.path.basename(sys.argv[0])
21 21
22 def check_mozconfig(path, mode): 22 def check_mozconfig(path, mode):
23 if not os.path.exists(path): 23 if not os.path.exists(path):
24 raise Exception("'%s' doesn't exist, please create it." % path) 24 raise Exception("'%s' doesn't exist, please create it." % path)
25 25
26 with open(path) as file: 26 with open(path) as file:
27 contents = file.read() 27 contents = file.read()
28 28
29 # This check can be removed once https://issues.adblockplus.org/ticket/2490 is 29 # This check can be removed once https://issues.adblockplus.org/ticket/2490 is
(...skipping 11 matching lines...) Expand all
41 raise Exception("'%s' seems to set --disable-updater, please don't." % path) 41 raise Exception("'%s' seems to set --disable-updater, please don't." % path)
42 elif not updater_disabled and mode == "release": 42 elif not updater_disabled and mode == "release":
43 raise Exception( 43 raise Exception(
44 "'%s' doesn't seem to set --disable-updater, please do." % path) 44 "'%s' doesn't seem to set --disable-updater, please do." % path)
45 45
46 def find_mozconfig(mode): 46 def find_mozconfig(mode):
47 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + mode) 47 mozconfig_path = os.path.join(BASE_DIR, "mozconfig-" + mode)
48 check_mozconfig(mozconfig_path, mode) 48 check_mozconfig(mozconfig_path, mode)
49 return mozconfig_path 49 return mozconfig_path
50 50
51 def build(mode): 51 def build(mode, sdk_path, ndk_path):
52 mozharness_environment = os.environ.copy() 52 mozharness_environment = os.environ.copy()
53 mozharness_environment["MOZCONFIG"] = find_mozconfig(mode) 53 mozharness_environment["MOZCONFIG"] = find_mozconfig(mode)
54 import config 54 mozharness_environment["ANDROID_SDK_PATH"] = sdk_path
55 mozharness_environment["ANDROID_SDK_PATH"] = config.ANDROID_SDK_PATH 55 mozharness_environment["ANDROID_NDK_PATH"] = ndk_path
56 mozharness_environment["ANDROID_NDK_PATH"] = config.ANDROID_NDK_PATH
57 56
58 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"], 57 subprocess.check_call([MULTI_L10N_PATH, "--cfg", "adblockbrowser-cfg.py"],
59 env=mozharness_environment) 58 env=mozharness_environment)
60 59
61 [manifest_path] = glob.glob(os.path.join( 60 [manifest_path] = glob.glob(os.path.join(
62 DIST_PATH, "fennec-*.multi.android-arm.json")) 61 DIST_PATH, "fennec-*.multi.android-arm.json"))
63 with open(manifest_path) as manifest_file: 62 with open(manifest_path) as manifest_file:
64 manifest = json.load(manifest_file) 63 manifest = json.load(manifest_file)
65 64
66 apk_path = os.path.join(DIST_PATH, "gecko-unsigned-unaligned.apk") 65 apk_path = os.path.join(DIST_PATH, "gecko-unsigned-unaligned.apk")
(...skipping 12 matching lines...) Expand all
79 try: 78 try:
80 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA", 79 subprocess.check_call(["jarsigner", "-verbose", "-sigalg", "SHA1withRSA",
81 "-digestalg", "SHA1", "-keystore", key_store, 80 "-digestalg", "SHA1", "-keystore", key_store,
82 temp_apk_path, key_name]) 81 temp_apk_path, key_name])
83 os.remove(apk_path) 82 os.remove(apk_path)
84 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path]) 83 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path])
85 finally: 84 finally:
86 os.remove(temp_apk_path) 85 os.remove(temp_apk_path)
87 86
88 if __name__ == "__main__": 87 if __name__ == "__main__":
89 if len(sys.argv) < 4: 88 if len(sys.argv) < 2:
90 print_usage() 89 print_usage()
91 sys.exit(1) 90 sys.exit(1)
92 91
93 mode, key_store, key_name = sys.argv[1:] 92 mode = sys.argv[1]
94 if mode not in ("devbuild", "release"): 93 if mode not in ("devbuild", "release"):
95 print_usage() 94 print_usage()
96 sys.exit(2) 95 sys.exit(2)
97 96
98 subprocess.check_call([ENSURE_DEPENDENCIES_PATH]) 97 subprocess.check_call([ENSURE_DEPENDENCIES_PATH])
99 apk_path = build(mode) 98 import config
100 sign(apk_path, key_store, key_name) 99 apk_path = build(mode, config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH)
100 sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME)
OLDNEW
« no previous file with comments | « no previous file | config.py.sample » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld