Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 """Signs and zipaligns APK. | |
| 7 | |
| 8 """ | |
| 9 | |
| 10 import optparse | |
| 11 import os | |
| 12 import shutil | |
| 13 import sys | |
| 14 | |
| 15 from util import build_utils | |
| 16 | |
| 17 def SignApk(keystore_path, unsigned_path, signed_path): | |
| 18 intermediate_path = unsigned_path + '.copy' | |
|
shashi
2013/04/08 22:39:04
why the extra copy? Can we run it on unsigned path
cjhopman
2013/04/09 01:58:19
unsigned_path is an input to this action and we sh
| |
| 19 shutil.copy(unsigned_path, intermediate_path) | |
| 20 sign_cmd = [ | |
| 21 'jarsigner', | |
| 22 '-sigalg', 'MD5withRSA', | |
| 23 '-digestalg', 'SHA1', | |
| 24 '-keystore', keystore_path, | |
| 25 '-storepass', 'chromium', | |
| 26 intermediate_path, | |
| 27 'chromiumdebugkey', | |
| 28 ] | |
| 29 build_utils.CheckCallDie(sign_cmd) | |
| 30 shutil.move(intermediate_path, signed_path) | |
| 31 | |
| 32 | |
| 33 def AlignApk(android_sdk_root, unaligned_path, final_path): | |
| 34 align_cmd = [ | |
| 35 os.path.join(android_sdk_root, 'tools', 'zipalign'), | |
| 36 '-f', '4', | |
|
shashi
2013/04/08 22:39:04
Why is it 4? (32 bit?) a clarifying comment will m
cjhopman
2013/04/09 01:58:19
Done.
| |
| 37 unaligned_path, | |
| 38 final_path, | |
|
shashi
2013/04/08 22:39:04
Do we need a verbosity option here for debugging?
cjhopman
2013/04/09 01:58:19
This is already more verbose than in ant (i.e. it'
| |
| 39 ] | |
| 40 build_utils.CheckCallDie(align_cmd) | |
| 41 | |
| 42 | |
| 43 def main(argv): | |
| 44 parser = optparse.OptionParser() | |
| 45 | |
| 46 parser.add_option('--android-sdk-root', help='Android sdk root directory.') | |
| 47 parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.') | |
| 48 parser.add_option('--final-apk-path', | |
| 49 help='Path to output signed and aligned APK.') | |
| 50 parser.add_option('--keystore-path', help='Path to keystore for signing.') | |
| 51 parser.add_option('--stamp', help='Path to touch on success.') | |
| 52 | |
| 53 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | |
| 54 parser.add_option('--ignore', help='Ignored.') | |
| 55 | |
| 56 options, _ = parser.parse_args() | |
| 57 | |
| 58 signed_apk_path = options.unsigned_apk_path + '.signed.apk' | |
| 59 SignApk(options.keystore_path, options.unsigned_apk_path, signed_apk_path) | |
| 60 AlignApk(options.android_sdk_root, signed_apk_path, options.final_apk_path) | |
| 61 | |
| 62 if options.stamp: | |
| 63 build_utils.Touch(options.stamp) | |
| 64 | |
| 65 | |
| 66 if __name__ == '__main__': | |
| 67 sys.exit(main(sys.argv)) | |
| 68 | |
| 69 | |
| OLD | NEW |