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

Side by Side Diff: build/config/ios/codesign.py

Issue 2397433002: Fix codesign.py script when ios_enable_code_signing is set to false. (Closed)
Patch Set: Fix ProvisioningProfile.Install comment. Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bundle_identifier: the identifier of the bundle that needs to be signed. 90 bundle_identifier: the identifier of the bundle that needs to be signed.
91 91
92 Returns: 92 Returns:
93 True if the mobile provisioning profile can be used to sign a bundle 93 True if the mobile provisioning profile can be used to sign a bundle
94 with the corresponding bundle_identifier, False otherwise. 94 with the corresponding bundle_identifier, False otherwise.
95 """ 95 """
96 return fnmatch.fnmatch( 96 return fnmatch.fnmatch(
97 '%s.%s' % (self.team_identifier, bundle_identifier), 97 '%s.%s' % (self.team_identifier, bundle_identifier),
98 self.application_identifier_pattern) 98 self.application_identifier_pattern)
99 99
100 def Install(self, bundle): 100 def Install(self, installation_path):
101 """Copies mobile provisioning profile info the bundle.""" 101 """Copies mobile provisioning profile info to |installation_path|."""
102 installation_path = os.path.join(bundle.path, 'embedded.mobileprovision')
103 shutil.copy2(self.path, installation_path) 102 shutil.copy2(self.path, installation_path)
104 103
105 104
106 class Entitlements(object): 105 class Entitlements(object):
107 """Wraps an Entitlement plist file.""" 106 """Wraps an Entitlement plist file."""
108 107
109 def __init__(self, entitlements_path): 108 def __init__(self, entitlements_path):
110 """Initializes Entitlements object from entitlement file.""" 109 """Initializes Entitlements object from entitlement file."""
111 self._path = entitlements_path 110 self._path = entitlements_path
112 self._data = LoadPlistFile(self._path) 111 self._data = LoadPlistFile(self._path)
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 parser.add_argument( 256 parser.add_argument(
258 '--identity', '-i', required=True, 257 '--identity', '-i', required=True,
259 help='identity to use to codesign') 258 help='identity to use to codesign')
260 parser.add_argument( 259 parser.add_argument(
261 '--binary', '-b', required=True, 260 '--binary', '-b', required=True,
262 help='path to the iOS bundle binary') 261 help='path to the iOS bundle binary')
263 parser.add_argument( 262 parser.add_argument(
264 '--framework', '-F', action='append', default=[], dest='frameworks', 263 '--framework', '-F', action='append', default=[], dest='frameworks',
265 help='install and resign system framework') 264 help='install and resign system framework')
266 parser.add_argument( 265 parser.add_argument(
267 '--disable-code-signature', action='store_false', dest='sign', 266 '--disable-code-signature', action='store_true', dest='no_signature',
268 help='disable code signature') 267 help='disable code signature')
269 parser.add_argument( 268 parser.add_argument(
270 '--platform', '-t', required=True, 269 '--platform', '-t', required=True,
271 help='platform the signed bundle is targetting') 270 help='platform the signed bundle is targetting')
272 parser.set_defaults(sign=True) 271 parser.set_defaults(no_signature=False)
273 272
274 @staticmethod 273 @staticmethod
275 def _Execute(args): 274 def _Execute(args):
276 if not args.identity: 275 if not args.identity:
277 args.identity = '-' 276 args.identity = '-'
278 277
279 bundle = Bundle(args.path) 278 bundle = Bundle(args.path)
280 279
281 # Find mobile provisioning profile and embeds it into the bundle (if a code 280 # Delete existing embedded mobile provisioning.
282 # signing identify has been provided, fails if no valid mobile provisioning 281 embedded_provisioning_profile = os.path.join(
283 # is found). 282 bundle.path, 'embedded.mobileprovision')
284 provisioning_profile_required = args.identity != '-' 283 if os.path.isfile(embedded_provisioning_profile):
285 provisioning_profile = FindProvisioningProfile( 284 os.unlink(embedded_provisioning_profile)
286 bundle.identifier, provisioning_profile_required)
287 if provisioning_profile and args.platform != 'iphonesimulator':
288 provisioning_profile.Install(bundle)
289 285
290 # Delete existing code signature. 286 # Delete existing code signature.
291 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources') 287 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources')
292 if os.path.isfile(signature_file): 288 if os.path.isfile(signature_file):
293 os.unlink(signature_file) 289 shutil.rmtree(os.path.dirname(signature_file))
294 290
295 # Install system frameworks if requested. 291 # Install system frameworks if requested.
296 for framework_path in args.frameworks: 292 for framework_path in args.frameworks:
297 InstallSystemFramework(framework_path, args.path, args) 293 InstallSystemFramework(framework_path, args.path, args)
298 294
299 # Copy main binary into bundle. 295 # Copy main binary into bundle.
300 if os.path.isfile(bundle.binary_path): 296 if os.path.isfile(bundle.binary_path):
301 os.unlink(bundle.binary_path) 297 os.unlink(bundle.binary_path)
302 shutil.copy(args.binary, bundle.binary_path) 298 shutil.copy(args.binary, bundle.binary_path)
303 299
304 if not args.sign: 300 if args.no_signature:
305 return 301 return
306 302
307 # Embeds entitlements into the code signature (if code signing identify has
308 # been provided).
309 codesign_extra_args = [] 303 codesign_extra_args = []
304
305 # Find mobile provisioning profile and embeds it into the bundle (if a code
306 # signing identify has been provided, fails if no valid mobile provisioning
307 # is found).
308 provisioning_profile_required = args.identity != '-'
309 provisioning_profile = FindProvisioningProfile(
310 bundle.identifier, provisioning_profile_required)
310 if provisioning_profile and args.platform != 'iphonesimulator': 311 if provisioning_profile and args.platform != 'iphonesimulator':
312 provisioning_profile.Install(embedded_provisioning_profile)
313
311 temporary_entitlements_file = tempfile.NamedTemporaryFile(suffix='.xcent') 314 temporary_entitlements_file = tempfile.NamedTemporaryFile(suffix='.xcent')
312 codesign_extra_args.extend( 315 codesign_extra_args.extend(
313 ['--entitlements', temporary_entitlements_file.name]) 316 ['--entitlements', temporary_entitlements_file.name])
314 317
315 entitlements = GenerateEntitlements( 318 entitlements = GenerateEntitlements(
316 args.entitlements_path, provisioning_profile, bundle.identifier) 319 args.entitlements_path, provisioning_profile, bundle.identifier)
317 entitlements.WriteTo(temporary_entitlements_file.name) 320 entitlements.WriteTo(temporary_entitlements_file.name)
318 321
319 CodeSignBundle(bundle.path, args.identity, codesign_extra_args) 322 CodeSignBundle(bundle.path, args.identity, codesign_extra_args)
320 323
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 403
401 for action in actions: 404 for action in actions:
402 action.Register(subparsers) 405 action.Register(subparsers)
403 406
404 args = parser.parse_args() 407 args = parser.parse_args()
405 args.func(args) 408 args.func(args)
406 409
407 410
408 if __name__ == '__main__': 411 if __name__ == '__main__':
409 sys.exit(Main()) 412 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698