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

Side by Side Diff: build.py

Issue 29420572: Issue 5129 - [build] Signing fails if zipalign is not in PATH (Closed)
Patch Set: Created April 24, 2017, 11:24 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 | no next file » | 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 re 6 import re
7 import shutil 7 import shutil
8 import string 8 import string
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 manifest["moz_app_version"], manifest["buildid"], architecture) 95 manifest["moz_app_version"], manifest["buildid"], architecture)
96 target_apk_path = os.path.join(dist_path, target_apk_name) 96 target_apk_path = os.path.join(dist_path, target_apk_name)
97 shutil.copyfile(apk_path, target_apk_path) 97 shutil.copyfile(apk_path, target_apk_path)
98 98
99 target_manifest_path = re.sub(r".apk$", ".json", target_apk_path) 99 target_manifest_path = re.sub(r".apk$", ".json", target_apk_path)
100 shutil.copyfile(manifest_path, target_manifest_path) 100 shutil.copyfile(manifest_path, target_manifest_path)
101 101
102 return target_apk_path 102 return target_apk_path
103 103
104 104
105 def _sign(apk_path, key_store, key_name): 105 def _sign(apk_path, key_store, key_name, sdk_path):
106 sys.path.append(os.path.join(_ABB_PATH, "python", "mozboot", "mozboot"))
107 from android import ANDROID_BUILD_TOOLS_VERSION
108 zipalign_path = os.path.join(sdk_path, "build-tools",
109 ANDROID_BUILD_TOOLS_VERSION, "zipalign")
106 temp_apk_path = tempfile.NamedTemporaryFile().name 110 temp_apk_path = tempfile.NamedTemporaryFile().name
107 shutil.copyfile(apk_path, temp_apk_path) 111 shutil.copyfile(apk_path, temp_apk_path)
108 try: 112 try:
109 subprocess.check_call(["jarsigner", "-verbose", 113 subprocess.check_call(["jarsigner", "-verbose",
110 "-sigalg", "SHA1withRSA", 114 "-sigalg", "SHA1withRSA",
111 "-digestalg", "SHA1", 115 "-digestalg", "SHA1",
112 "-keystore", key_store, 116 "-keystore", key_store,
113 temp_apk_path, key_name]) 117 temp_apk_path, key_name])
114 os.remove(apk_path) 118 os.remove(apk_path)
115 subprocess.check_call(["zipalign", "-v", "4", temp_apk_path, apk_path]) 119 subprocess.check_call([zipalign_path, "-v", "4", temp_apk_path,
120 apk_path])
116 finally: 121 finally:
117 os.remove(temp_apk_path) 122 os.remove(temp_apk_path)
118 123
119 if __name__ == "__main__": 124 if __name__ == "__main__":
120 if len(sys.argv) < 2: 125 if len(sys.argv) < 2:
121 print_usage() 126 print_usage()
122 sys.exit(1) 127 sys.exit(1)
123 128
124 mode = sys.argv[1] 129 mode = sys.argv[1]
125 do_build = mode in (_CMD_BUILD, _CMD_BUILD_SIGN) 130 do_build = mode in (_CMD_BUILD, _CMD_BUILD_SIGN)
(...skipping 27 matching lines...) Expand all
153 architecture = config.ARCHITECTURE 158 architecture = config.ARCHITECTURE
154 if architecture not in _ARCHS: 159 if architecture not in _ARCHS:
155 print >>sys.stderr, error_msg % ( 160 print >>sys.stderr, error_msg % (
156 "architecture", "architectures", _ARCHS ) 161 "architecture", "architectures", _ARCHS )
157 sys.exit(6) 162 sys.exit(6)
158 163
159 if do_build: 164 if do_build:
160 apk_path = _build(architecture, distribution_mode, build_mode, 165 apk_path = _build(architecture, distribution_mode, build_mode,
161 config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH) 166 config.ANDROID_SDK_PATH, config.ANDROID_NDK_PATH)
162 if do_sign: 167 if do_sign:
163 _sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME) 168 _sign(apk_path, config.ANDROID_KEYSTORE_PATH, config.ANDROID_KEY_NAME,
169 config.ANDROID_SDK_PATH)
164 else: 170 else:
165 print apk_path 171 print apk_path
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld