OLD | NEW |
---|---|
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import argparse | |
6 import os | |
5 import subprocess | 7 import subprocess |
6 import sys | 8 import sys |
7 import re | 9 import re |
8 | 10 |
9 def ListIdentities(): | 11 def ListIdentities(): |
10 return subprocess.check_output([ | 12 return subprocess.check_output([ |
11 '/usr/bin/env', | 13 '/usr/bin/env', |
sdefresne
2016/10/26 15:33:07
I think you can remove the '/usr/bin/env' here.
justincohen
2016/10/27 13:36:39
Done.
| |
12 'xcrun', | 14 'xcrun', |
13 'security', | 15 'security', |
14 'find-identity', | 16 'find-identity', |
15 '-v', | 17 '-v', |
16 '-p', | 18 '-p', |
17 'codesigning', | 19 'codesigning', |
18 ]).strip() | 20 ]).strip() |
19 | 21 |
20 | 22 |
21 def FindValidIdentity(): | 23 def FindValidIdentity(): |
22 lines = ListIdentities().splitlines() | 24 lines = ListIdentities().splitlines() |
23 # Look for something like "2) XYZ "iPhone Developer: Name (ABC)"" | 25 # Look for something like "2) XYZ "iPhone Developer: Name (ABC)"" |
24 exp = re.compile('[0-9]+\) ([A-F0-9]+) "([^"]*)"') | 26 exp = re.compile('[0-9]+\) ([A-F0-9]+) "([^"]*)"') |
25 for line in lines: | 27 for line in lines: |
26 res = exp.match(line) | 28 res = exp.match(line) |
27 if res is None: | 29 if res is None: |
28 continue | 30 continue |
29 if "iPhone Developer" in res.group(2): | 31 if "iPhone Developer" in res.group(2): |
30 return res.group(1) | 32 return res.group(1) |
31 return "" | 33 return "" |
32 | 34 |
33 | 35 |
34 if __name__ == '__main__': | 36 if __name__ == '__main__': |
37 parser = argparse.ArgumentParser('codesign iOS bundles') | |
38 parser.add_argument('--developer_dir', required=False, | |
39 help='Path to Xcode.') | |
40 args = parser.parse_args() | |
41 if args.developer_dir: | |
42 os.environ['DEVELOPER_DIR'] = args.developer_dir | |
43 | |
35 print FindValidIdentity() | 44 print FindValidIdentity() |
OLD | NEW |