OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 5 import argparse |
6 import fnmatch | 6 import fnmatch |
7 import glob | 7 import glob |
8 import os | 8 import os |
9 import plistlib | 9 import plistlib |
10 import shutil | 10 import shutil |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 else: | 225 else: |
226 app_identifier_prefix = '*.' | 226 app_identifier_prefix = '*.' |
227 entitlements.ExpandVariables({ | 227 entitlements.ExpandVariables({ |
228 'CFBundleIdentifier': bundle_identifier, | 228 'CFBundleIdentifier': bundle_identifier, |
229 'AppIdentifierPrefix': app_identifier_prefix, | 229 'AppIdentifierPrefix': app_identifier_prefix, |
230 }) | 230 }) |
231 return entitlements | 231 return entitlements |
232 | 232 |
233 | 233 |
234 class Action(object): | 234 class Action(object): |
235 | 235 |
justincohen
2016/09/27 18:08:23
nit empty line?
sdefresne
2016/09/28 14:01:46
Done.
| |
236 """Class implementing one action supported by the script.""" | 236 """Class implementing one action supported by the script.""" |
237 | 237 |
238 @classmethod | 238 @classmethod |
239 def Register(cls, subparsers): | 239 def Register(cls, subparsers): |
240 parser = subparsers.add_parser(cls.name, help=cls.help) | 240 parser = subparsers.add_parser(cls.name, help=cls.help) |
241 parser.set_defaults(func=cls._Execute) | 241 parser.set_defaults(func=cls._Execute) |
242 cls._Register(parser) | 242 cls._Register(parser) |
243 | 243 |
244 | 244 |
245 class CodeSignBundleAction(Action): | 245 class CodeSignBundleAction(Action): |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 codesign_extra_args.extend( | 314 codesign_extra_args.extend( |
315 ['--entitlements', temporary_entitlements_file.name]) | 315 ['--entitlements', temporary_entitlements_file.name]) |
316 | 316 |
317 entitlements = GenerateEntitlements( | 317 entitlements = GenerateEntitlements( |
318 args.entitlements_path, provisioning_profile, bundle.identifier) | 318 args.entitlements_path, provisioning_profile, bundle.identifier) |
319 entitlements.WriteTo(temporary_entitlements_file.name) | 319 entitlements.WriteTo(temporary_entitlements_file.name) |
320 | 320 |
321 CodeSignBundle(bundle.path, args.identity, codesign_extra_args) | 321 CodeSignBundle(bundle.path, args.identity, codesign_extra_args) |
322 | 322 |
323 | 323 |
324 class CodeSignFileAction(Action): | |
325 | |
justincohen
2016/09/27 18:08:23
nit empty line
sdefresne
2016/09/28 14:01:46
Done.
| |
326 """Class implementing code signature for a single file.""" | |
327 | |
328 name = 'code-sign-file' | |
329 help = 'code-sign a single file' | |
330 | |
331 @staticmethod | |
332 def _Register(parser): | |
333 parser.add_argument( | |
334 'path', help='path to the file to codesign') | |
335 parser.add_argument( | |
336 '--identity', '-i', required=True, | |
337 help='identity to use to codesign') | |
338 parser.add_argument( | |
339 '--output', '-o', | |
340 help='if specified copy the file to that location before signing it') | |
341 parser.set_defaults(sign=True) | |
342 | |
343 @staticmethod | |
344 def _Execute(args): | |
345 if not args.identity: | |
346 args.identity = '-' | |
347 | |
348 install_path = args.path | |
349 if args.output: | |
350 | |
351 if os.path.isfile(args.output): | |
352 os.unlink(args.output) | |
353 elif os.path.isdir(args.output): | |
354 shutil.rmtree(args.output) | |
355 | |
356 if os.path.isfile(args.path): | |
357 shutil.copy(args.path, args.output) | |
358 elif os.path.isdir(args.path): | |
359 shutil.copytree(args.path, args.output) | |
360 | |
361 install_path = args.output | |
362 | |
363 CodeSignBundle(install_path, args.identity, | |
364 ['--deep', '--preserve-metadata=identifier,entitlements']) | |
365 | |
366 | |
324 class GenerateEntitlementsAction(Action): | 367 class GenerateEntitlementsAction(Action): |
325 | 368 |
justincohen
2016/09/27 18:08:23
nit empty line
sdefresne
2016/09/28 14:01:46
Done.
| |
326 """Class implementing the generate-entitlements action.""" | 369 """Class implementing the generate-entitlements action.""" |
327 | 370 |
328 name = 'generate-entitlements' | 371 name = 'generate-entitlements' |
329 help = 'generate entitlements file' | 372 help = 'generate entitlements file' |
330 | 373 |
331 @staticmethod | 374 @staticmethod |
332 def _Register(parser): | 375 def _Register(parser): |
333 parser.add_argument( | 376 parser.add_argument( |
334 '--entitlements', '-e', dest='entitlements_path', | 377 '--entitlements', '-e', dest='entitlements_path', |
335 help='path to the entitlements file to use') | 378 help='path to the entitlements file to use') |
(...skipping 10 matching lines...) Expand all Loading... | |
346 provisioning_profile = FindProvisioningProfile(bundle_identifier, False) | 389 provisioning_profile = FindProvisioningProfile(bundle_identifier, False) |
347 entitlements = GenerateEntitlements( | 390 entitlements = GenerateEntitlements( |
348 args.entitlements_path, provisioning_profile, bundle_identifier) | 391 args.entitlements_path, provisioning_profile, bundle_identifier) |
349 entitlements.WriteTo(args.path) | 392 entitlements.WriteTo(args.path) |
350 | 393 |
351 | 394 |
352 def Main(): | 395 def Main(): |
353 parser = argparse.ArgumentParser('codesign iOS bundles') | 396 parser = argparse.ArgumentParser('codesign iOS bundles') |
354 subparsers = parser.add_subparsers() | 397 subparsers = parser.add_subparsers() |
355 | 398 |
356 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]: | 399 actions = [ |
400 CodeSignBundleAction, | |
401 CodeSignFileAction, | |
402 GenerateEntitlementsAction, | |
403 ] | |
404 | |
405 for action in actions: | |
357 action.Register(subparsers) | 406 action.Register(subparsers) |
358 | 407 |
359 args = parser.parse_args() | 408 args = parser.parse_args() |
360 args.func(args) | 409 args.func(args) |
361 | 410 |
362 | 411 |
363 if __name__ == '__main__': | 412 if __name__ == '__main__': |
364 sys.exit(Main()) | 413 sys.exit(Main()) |
OLD | NEW |