| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79   parser.add_option('--key-passwd', help='Keystore password') | 79   parser.add_option('--key-passwd', help='Keystore password') | 
| 80   parser.add_option('--key-name', help='Keystore name') | 80   parser.add_option('--key-name', help='Keystore name') | 
| 81   parser.add_option('--stamp', help='Path to touch on success.') | 81   parser.add_option('--stamp', help='Path to touch on success.') | 
| 82   parser.add_option('--load-library-from-zip', type='int', | 82   parser.add_option('--load-library-from-zip', type='int', | 
| 83       help='If non-zero, build the APK such that the library can be loaded ' + | 83       help='If non-zero, build the APK such that the library can be loaded ' + | 
| 84            'directly from the zip file using the crazy linker. The library ' + | 84            'directly from the zip file using the crazy linker. The library ' + | 
| 85            'will be renamed, uncompressed and page aligned.') | 85            'will be renamed, uncompressed and page aligned.') | 
| 86 | 86 | 
| 87   options, _ = parser.parse_args() | 87   options, _ = parser.parse_args() | 
| 88 | 88 | 
|  | 89   FinalizeApk(options) | 
|  | 90 | 
|  | 91   if options.depfile: | 
|  | 92     build_utils.WriteDepfile( | 
|  | 93         options.depfile, build_utils.GetPythonDependencies()) | 
|  | 94 | 
|  | 95   if options.stamp: | 
|  | 96     build_utils.Touch(options.stamp) | 
|  | 97 | 
|  | 98 | 
|  | 99 def FinalizeApk(options): | 
| 89   with tempfile.NamedTemporaryFile() as signed_apk_path_tmp, \ | 100   with tempfile.NamedTemporaryFile() as signed_apk_path_tmp, \ | 
| 90       tempfile.NamedTemporaryFile() as apk_to_sign_tmp: | 101       tempfile.NamedTemporaryFile() as apk_to_sign_tmp: | 
| 91 | 102 | 
| 92     if options.load_library_from_zip: | 103     if options.load_library_from_zip: | 
| 93       # We alter the name of the library so that the Android Package Manager | 104       # We alter the name of the library so that the Android Package Manager | 
| 94       # does not extract it into a separate file. This must be done before | 105       # does not extract it into a separate file. This must be done before | 
| 95       # signing, as the filename is part of the signed manifest. At the same | 106       # signing, as the filename is part of the signed manifest. At the same | 
| 96       # time we uncompress the library, which is necessary so that it can be | 107       # time we uncompress the library, which is necessary so that it can be | 
| 97       # loaded directly from the APK. | 108       # loaded directly from the APK. | 
| 98       # Move the library to a page boundary by adding a page alignment file. | 109       # Move the library to a page boundary by adding a page alignment file. | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 109     if options.load_library_from_zip: | 120     if options.load_library_from_zip: | 
| 110       # Reorder the contents of the APK. This re-establishes the canonical | 121       # Reorder the contents of the APK. This re-establishes the canonical | 
| 111       # order which means the library will be back at its page aligned location. | 122       # order which means the library will be back at its page aligned location. | 
| 112       # This step also aligns uncompressed items to 4 bytes. | 123       # This step also aligns uncompressed items to 4 bytes. | 
| 113       ReorderAndAlignApk( | 124       ReorderAndAlignApk( | 
| 114           options.rezip_apk_jar_path, signed_apk_path, options.final_apk_path) | 125           options.rezip_apk_jar_path, signed_apk_path, options.final_apk_path) | 
| 115     else: | 126     else: | 
| 116       # Align uncompressed items to 4 bytes | 127       # Align uncompressed items to 4 bytes | 
| 117       AlignApk(options.zipalign_path, signed_apk_path, options.final_apk_path) | 128       AlignApk(options.zipalign_path, signed_apk_path, options.final_apk_path) | 
| 118 | 129 | 
| 119   if options.depfile: |  | 
| 120     build_utils.WriteDepfile( |  | 
| 121         options.depfile, build_utils.GetPythonDependencies()) |  | 
| 122 |  | 
| 123   if options.stamp: |  | 
| 124     build_utils.Touch(options.stamp) |  | 
| 125 |  | 
| 126 | 130 | 
| 127 if __name__ == '__main__': | 131 if __name__ == '__main__': | 
| 128   sys.exit(main()) | 132   sys.exit(main()) | 
| OLD | NEW | 
|---|