skia2/gn/codesign_ios.py
Eric Boren a726978ae7 Revert "[python3] More Recipes -> Python 3 fixes"
This reverts commit 12e786730f.

Reason for revert: missing CIPD package on armv6l

Original change's description:
> [python3] More Recipes -> Python 3 fixes
>
> - Set environment variables to force usage of Python 3 in more places
> - Fix more compatibility issues
> - Mark recipes as only supporting Python 3
> - Includes a roll of the infra code
>
> Change-Id: I24e3827a6402c454bdc9467d28864d360632f9e6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/470303
> Reviewed-by: Ravi Mistry <rmistry@google.com>
> Commit-Queue: Eric Boren <borenet@google.com>

Change-Id: If7b6fcb7838ac053af2c5eb45a7a1ac4aed340a5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/472736
Auto-Submit: Eric Boren <borenet@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-11-17 14:57:10 +00:00

81 lines
2.7 KiB
Python
Executable File

#!/usr/bin/env python2.7
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import glob
import os
import os.path
import re
import shutil
import subprocess
import sys
import tempfile
# Arguments to the script:
# pkg path to application directory, e.g. out/Debug/dm.app
# executable and plist should already be in this directory
# identstr search string (regex fragment) for code signing identity
# profile path or name of provisioning profile
pkg,identstr,profile = sys.argv[1:]
# Find the signing identity.
identity = None
for line in subprocess.check_output(['security', 'find-identity']).split('\n'):
m = re.match(r'''.*\) (.*) "''' + identstr + '"', line)
if m:
identity = m.group(1)
if identity is None:
print("Signing identity matching '" + identstr + "' not found.")
print("Please verify by running 'security find-identity' or checking your keychain.")
sys.exit(1)
# Find the mobile provisioning profile.
mobileprovision = None
if os.path.isfile(profile):
mobileprovision = profile
else:
for p in glob.glob(os.path.join(os.environ['HOME'], 'Library', 'MobileDevice',
'Provisioning Profiles',
'*.mobileprovision')):
if re.search(r'''<key>Name</key>
\t<string>''' + profile + r'''</string>''', open(p).read(), re.MULTILINE):
mobileprovision = p
if mobileprovision is None:
print("Provisioning profile matching '" + profile + "' not found.")
print("Please verify that the correct profile is installed in '${HOME}/Library/MobileDevice/Provisioning Profiles' or specify the path directly.")
sys.exit(1)
# The .mobileprovision just gets copied into the package.
shutil.copy(mobileprovision,
os.path.join(pkg, 'embedded.mobileprovision'))
# Extract the appliciation identitifer prefix from the .mobileprovision.
m = re.search(r'''<key>ApplicationIdentifierPrefix</key>
\t<array>
\t<string>(.*)</string>''', open(mobileprovision).read(), re.MULTILINE)
prefix = m.group(1)
app, _ = os.path.splitext(os.path.basename(pkg))
# Write a minimal entitlements file, then codesign.
with tempfile.NamedTemporaryFile() as f:
f.write('''
<plist version="1.0">
<dict>
<key>application-identifier</key> <string>{prefix}.com.google.{app}</string>
<key>get-task-allow</key> <true/>
</dict>
</plist>
'''.format(prefix=prefix, app=app))
f.flush()
subprocess.check_call(['codesign',
'--force',
'--sign', identity,
'--entitlements', f.name,
'--timestamp=none',
pkg])