Chromium Code Reviews| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 sys.exit(process.returncode) | 190 sys.exit(process.returncode) |
| 191 for line in stderr.splitlines(): | 191 for line in stderr.splitlines(): |
| 192 if line.endswith(': replacing existing signature'): | 192 if line.endswith(': replacing existing signature'): |
| 193 # Ignore warning about replacing existing signature as this should only | 193 # Ignore warning about replacing existing signature as this should only |
| 194 # happen when re-signing system frameworks (and then it is expected). | 194 # happen when re-signing system frameworks (and then it is expected). |
| 195 continue | 195 continue |
| 196 sys.stderr.write(line) | 196 sys.stderr.write(line) |
| 197 sys.stderr.write('\n') | 197 sys.stderr.write('\n') |
| 198 | 198 |
| 199 | 199 |
| 200 def InstallSystemFrameworkOrLibrary(src_path, dst_path, args): | |
| 201 """Install framework or library from |src_path| to |dst_path| and | |
| 202 code-re-sign it.""" | |
| 203 if os.path.isdir(dst_path): | |
| 204 shutil.rmtree(dst_path) | |
|
justincohen
2016/09/26 15:14:02
Is this the same thing Xcode does with it's build
sdefresne
2016/09/26 15:20:43
No, it put he asan library into ${app}.app/Framewo
justincohen
2016/09/26 16:09:00
Acknowledged.
| |
| 205 elif os.path.isfile(dst_path): | |
| 206 os.unlink(dst_path) | |
| 207 | |
| 208 if os.path.isdir(src_path): | |
| 209 shutil.copytree(src_path, dst_path) | |
| 210 else: | |
| 211 shutil.copy(src_path, dst_path) | |
| 212 | |
| 213 CodeSignBundle(dst_path, args.identity, | |
| 214 ['--deep', '--preserve-metadata=identifier,entitlements']) | |
| 215 | |
| 216 | |
| 200 def InstallSystemFramework(framework_path, bundle_path, args): | 217 def InstallSystemFramework(framework_path, bundle_path, args): |
| 201 """Install framework from |framework_path| to |bundle| and code-re-sign it.""" | 218 """Install framework from |framework_path| to |bundle| and code-re-sign it.""" |
| 202 installed_framework_path = os.path.join( | 219 installed_framework_path = os.path.join( |
| 203 bundle_path, 'Frameworks', os.path.basename(framework_path)) | 220 bundle_path, 'Frameworks', os.path.basename(framework_path)) |
| 221 InstallSystemFrameworkOrLibrary( | |
| 222 framework_path, installed_framework_path, args) | |
| 204 | 223 |
| 205 if os.path.exists(installed_framework_path): | |
| 206 shutil.rmtree(installed_framework_path) | |
| 207 | 224 |
| 208 shutil.copytree(framework_path, installed_framework_path) | 225 def InstallSystemLibrary(library_path, bundle_path, args): |
| 209 CodeSignBundle(installed_framework_path, args.identity, | 226 """Install library from |library_path| to |bundle| and code-re-sign it.""" |
| 210 ['--deep', '--preserve-metadata=identifier,entitlements']) | 227 installed_library_path = os.path.join( |
| 228 bundle_path, os.path.basename(library_path)) | |
| 229 InstallSystemFrameworkOrLibrary( | |
| 230 library_path, installed_library_path, args) | |
| 211 | 231 |
| 212 | 232 |
| 213 def GenerateEntitlements(path, provisioning_profile, bundle_identifier): | 233 def GenerateEntitlements(path, provisioning_profile, bundle_identifier): |
| 214 """Generates an entitlements file. | 234 """Generates an entitlements file. |
| 215 | 235 |
| 216 Args: | 236 Args: |
| 217 path: path to the entitlements template file | 237 path: path to the entitlements template file |
| 218 provisioning_profile: ProvisioningProfile object to use, may be None | 238 provisioning_profile: ProvisioningProfile object to use, may be None |
| 219 bundle_identifier: identifier of the bundle to sign. | 239 bundle_identifier: identifier of the bundle to sign. |
| 220 """ | 240 """ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 parser.add_argument( | 277 parser.add_argument( |
| 258 'path', help='path to the iOS bundle to codesign') | 278 'path', help='path to the iOS bundle to codesign') |
| 259 parser.add_argument( | 279 parser.add_argument( |
| 260 '--identity', '-i', required=True, | 280 '--identity', '-i', required=True, |
| 261 help='identity to use to codesign') | 281 help='identity to use to codesign') |
| 262 parser.add_argument( | 282 parser.add_argument( |
| 263 '--binary', '-b', required=True, | 283 '--binary', '-b', required=True, |
| 264 help='path to the iOS bundle binary') | 284 help='path to the iOS bundle binary') |
| 265 parser.add_argument( | 285 parser.add_argument( |
| 266 '--framework', '-F', action='append', default=[], dest='frameworks', | 286 '--framework', '-F', action='append', default=[], dest='frameworks', |
| 267 help='install and resign system framework') | 287 help='install and re-sign system framework') |
| 288 parser.add_argument( | |
| 289 '--library', '-L', action='append', default=[], dest='libraries', | |
| 290 help='install and re-sign system libraries') | |
| 268 parser.add_argument( | 291 parser.add_argument( |
| 269 '--disable-code-signature', action='store_false', dest='sign', | 292 '--disable-code-signature', action='store_false', dest='sign', |
| 270 help='disable code signature') | 293 help='disable code signature') |
| 271 parser.add_argument( | 294 parser.add_argument( |
| 272 '--platform', '-t', required=True, | 295 '--platform', '-t', required=True, |
| 273 help='platform the signed bundle is targetting') | 296 help='platform the signed bundle is targetting') |
| 274 parser.set_defaults(sign=True) | 297 parser.set_defaults(sign=True) |
| 275 | 298 |
| 276 @staticmethod | 299 @staticmethod |
| 277 def _Execute(args): | 300 def _Execute(args): |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 291 | 314 |
| 292 # Delete existing code signature. | 315 # Delete existing code signature. |
| 293 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources') | 316 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources') |
| 294 if os.path.isfile(signature_file): | 317 if os.path.isfile(signature_file): |
| 295 os.unlink(signature_file) | 318 os.unlink(signature_file) |
| 296 | 319 |
| 297 # Install system frameworks if requested. | 320 # Install system frameworks if requested. |
| 298 for framework_path in args.frameworks: | 321 for framework_path in args.frameworks: |
| 299 InstallSystemFramework(framework_path, args.path, args) | 322 InstallSystemFramework(framework_path, args.path, args) |
| 300 | 323 |
| 324 # Install system libraries if requested. | |
| 325 for library_path in args.libraries: | |
| 326 InstallSystemLibrary(library_path, args.path, args) | |
| 327 | |
| 301 # Copy main binary into bundle. | 328 # Copy main binary into bundle. |
| 302 if os.path.isfile(bundle.binary_path): | 329 if os.path.isfile(bundle.binary_path): |
| 303 os.unlink(bundle.binary_path) | 330 os.unlink(bundle.binary_path) |
| 304 shutil.copy(args.binary, bundle.binary_path) | 331 shutil.copy(args.binary, bundle.binary_path) |
| 305 | 332 |
| 306 if not args.sign: | 333 if not args.sign: |
| 307 return | 334 return |
| 308 | 335 |
| 309 # Embeds entitlements into the code signature (if code signing identify has | 336 # Embeds entitlements into the code signature (if code signing identify has |
| 310 # been provided). | 337 # been provided). |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 382 |
| 356 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]: | 383 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]: |
| 357 action.Register(subparsers) | 384 action.Register(subparsers) |
| 358 | 385 |
| 359 args = parser.parse_args() | 386 args = parser.parse_args() |
| 360 args.func(args) | 387 args.func(args) |
| 361 | 388 |
| 362 | 389 |
| 363 if __name__ == '__main__': | 390 if __name__ == '__main__': |
| 364 sys.exit(Main()) | 391 sys.exit(Main()) |
| OLD | NEW |