blob: aaae1e42484a8421640c16903faca4da8f5eb48f [file] [log] [blame]
Rico Wind0ed24cc2018-03-23 07:16:35 +01001#!/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 Gjessecdae8792018-12-12 09:02:43 +01006import os
Rico Wind0ed24cc2018-03-23 07:16:35 +01007import subprocess
8import utils
9
10def 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 Gjessecdae8792018-12-12 09:02:43 +010027
28def 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)