Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
Søren Gjesse | cdae879 | 2018-12-12 09:02:43 +0100 | [diff] [blame] | 6 | import os |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 7 | import subprocess |
| 8 | import utils |
| 9 | |
| 10 | def sign(unsigned_apk, signed_apk, keystore): |
| 11 | print 'Signing (ignore the warnings)' |
| 12 | cmd = ['zip', '-d', unsigned_apk, 'META-INF/*'] |
| 13 | utils.PrintCmd(cmd) |
| 14 | subprocess.call(cmd) |
| 15 | cmd = [ |
| 16 | 'jarsigner', |
| 17 | '-sigalg', 'SHA1withRSA', |
| 18 | '-digestalg', 'SHA1', |
| 19 | '-keystore', keystore, |
| 20 | '-storepass', 'android', |
| 21 | '-signedjar', signed_apk, |
| 22 | unsigned_apk, |
| 23 | 'androiddebugkey' |
| 24 | ] |
| 25 | utils.PrintCmd(cmd) |
| 26 | subprocess.check_call(cmd) |
Søren Gjesse | cdae879 | 2018-12-12 09:02:43 +0100 | [diff] [blame] | 27 | |
| 28 | def sign_with_apksigner(build_tools_dir, unsigned_apk, signed_apk, keystore, password): |
| 29 | cmd = [ |
| 30 | os.path.join(build_tools_dir, 'apksigner'), |
| 31 | 'sign', |
| 32 | '-v', |
| 33 | '--ks', keystore, |
| 34 | '--ks-pass', 'pass:' + password, |
| 35 | '--min-sdk-version', '19', |
| 36 | '--out', signed_apk, |
| 37 | unsigned_apk |
| 38 | ] |
| 39 | utils.PrintCmd(cmd) |
| 40 | subprocess.check_call(cmd) |