Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2770)

Unified Diff: build/android/gyp/finalize_apk.py

Issue 13427020: [Android] Extract signing+zipaligning to python (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/ant/apk-package.xml ('k') | build/java_apk.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/finalize_apk.py
diff --git a/build/android/gyp/finalize_apk.py b/build/android/gyp/finalize_apk.py
new file mode 100755
index 0000000000000000000000000000000000000000..bd7981a3357f30b3150c03f375798a0a7124be3c
--- /dev/null
+++ b/build/android/gyp/finalize_apk.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Signs and zipaligns APK.
+
+"""
+
+import optparse
+import os
+import shutil
+import sys
+
+from util import build_utils
+
+def SignApk(keystore_path, unsigned_path, signed_path):
+ intermediate_path = unsigned_path + '.copy'
+ shutil.copy(unsigned_path, intermediate_path)
+ sign_cmd = [
+ 'jarsigner',
+ '-sigalg', 'MD5withRSA',
+ '-digestalg', 'SHA1',
+ '-keystore', keystore_path,
+ '-storepass', 'chromium',
+ intermediate_path,
+ 'chromiumdebugkey',
+ ]
+ build_utils.CheckCallDie(sign_cmd)
+ shutil.move(intermediate_path, signed_path)
+
+
+def AlignApk(android_sdk_root, unaligned_path, final_path):
+ align_cmd = [
+ os.path.join(android_sdk_root, 'tools', 'zipalign'),
+ '-f', '4', # 4 bytes
+ unaligned_path,
+ final_path,
+ ]
+ build_utils.CheckCallDie(align_cmd)
+
+
+def main(argv):
+ parser = optparse.OptionParser()
+
+ parser.add_option('--android-sdk-root', help='Android sdk root directory.')
+ parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.')
+ parser.add_option('--final-apk-path',
+ help='Path to output signed and aligned APK.')
+ parser.add_option('--keystore-path', help='Path to keystore for signing.')
+ parser.add_option('--stamp', help='Path to touch on success.')
+
+ # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
+ parser.add_option('--ignore', help='Ignored.')
+
+ options, _ = parser.parse_args()
+
+ signed_apk_path = options.unsigned_apk_path + '.signed.apk'
+ SignApk(options.keystore_path, options.unsigned_apk_path, signed_apk_path)
+ AlignApk(options.android_sdk_root, signed_apk_path, options.final_apk_path)
+
+ if options.stamp:
+ build_utils.Touch(options.stamp)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
+
+
« no previous file with comments | « build/android/ant/apk-package.xml ('k') | build/java_apk.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698