| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 """Signs and zipaligns APK. | 6 """Signs and zipaligns APK. |
| 7 | 7 |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 def AlignApk(android_sdk_root, unaligned_path, final_path): | 32 def AlignApk(android_sdk_root, unaligned_path, final_path): |
| 33 align_cmd = [ | 33 align_cmd = [ |
| 34 os.path.join(android_sdk_root, 'tools', 'zipalign'), | 34 os.path.join(android_sdk_root, 'tools', 'zipalign'), |
| 35 '-f', '4', # 4 bytes | 35 '-f', '4', # 4 bytes |
| 36 unaligned_path, | 36 unaligned_path, |
| 37 final_path, | 37 final_path, |
| 38 ] | 38 ] |
| 39 build_utils.CheckOutput(align_cmd) | 39 build_utils.CheckOutput(align_cmd) |
| 40 | 40 |
| 41 | 41 |
| 42 def main(argv): | 42 def main(): |
| 43 parser = optparse.OptionParser() | 43 parser = optparse.OptionParser() |
| 44 | 44 |
| 45 parser.add_option('--android-sdk-root', help='Android sdk root directory.') | 45 parser.add_option('--android-sdk-root', help='Android sdk root directory.') |
| 46 parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.') | 46 parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.') |
| 47 parser.add_option('--final-apk-path', | 47 parser.add_option('--final-apk-path', |
| 48 help='Path to output signed and aligned APK.') | 48 help='Path to output signed and aligned APK.') |
| 49 parser.add_option('--keystore-path', help='Path to keystore for signing.') | 49 parser.add_option('--keystore-path', help='Path to keystore for signing.') |
| 50 parser.add_option('--stamp', help='Path to touch on success.') | 50 parser.add_option('--stamp', help='Path to touch on success.') |
| 51 | 51 |
| 52 options, _ = parser.parse_args() | 52 options, _ = parser.parse_args() |
| 53 | 53 |
| 54 with tempfile.NamedTemporaryFile() as intermediate_file: | 54 with tempfile.NamedTemporaryFile() as intermediate_file: |
| 55 signed_apk_path = intermediate_file.name | 55 signed_apk_path = intermediate_file.name |
| 56 SignApk(options.keystore_path, options.unsigned_apk_path, signed_apk_path) | 56 SignApk(options.keystore_path, options.unsigned_apk_path, signed_apk_path) |
| 57 AlignApk(options.android_sdk_root, signed_apk_path, options.final_apk_path) | 57 AlignApk(options.android_sdk_root, signed_apk_path, options.final_apk_path) |
| 58 | 58 |
| 59 if options.stamp: | 59 if options.stamp: |
| 60 build_utils.Touch(options.stamp) | 60 build_utils.Touch(options.stamp) |
| 61 | 61 |
| 62 | 62 |
| 63 if __name__ == '__main__': | 63 if __name__ == '__main__': |
| 64 sys.exit(main(sys.argv)) | 64 sys.exit(main()) |
| 65 | 65 |
| 66 | 66 |
| OLD | NEW |