Skip to content

Commit

Permalink
Simplify, remove debuggability
Browse files Browse the repository at this point in the history
  • Loading branch information
kastiglione committed Jul 15, 2019
1 parent 24fff17 commit 0680f17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
10 changes: 10 additions & 0 deletions apple/internal/rule_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,16 @@ _RULE_TYPE_DESCRIPTORS = {
requires_provisioning_profile = False,
skip_signing = True,
),
apple_product_type.bundle: _describe_rule_type(
allowed_device_families = ["iphone", "ipad"],
bundle_extension = ".bundle",
has_infoplist = True,
product_type = apple_product_type.bundle,
requires_bundle_id = True,
requires_provisioning_profile = False,
requires_signing_for_device = False,
skip_signing = True,
),
# ios_ui_test
apple_product_type.ui_test_bundle: _describe_rule_type(
allowed_device_families = ["iphone", "ipad"],
Expand Down
29 changes: 7 additions & 22 deletions tools/codesigningtool/codesigningtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def _find_codesign_identities(identity=None):
output = output.strip()
pattern = "(?P<hash>[A-F0-9]{40})"
if identity:
pattern += r'\s+"(?P<full_name>.*?{}.*?)"'.format(re.escape(identity))
name_requirement = re.escape(identity)
pattern += r'\s+".*?{}.*?"'.format(name_requirement)
regex = re.compile(pattern)
for line in output.splitlines():
# CSSMERR_TP_CERT_REVOKED comes from Security.framework/cssmerr.h
Expand All @@ -127,18 +128,18 @@ def _find_codesign_identities(identity=None):
m = regex.search(line)
if m:
groups = m.groupdict()
id = (groups["hash"], groups.get("full_name"))
id = groups["hash"]
ids.append(id)
return ids


def _find_codesign_identity(mobileprovision):
"""Finds a valid identity on the system given a mobileprovision file."""
mpf = _parse_mobileprovision_file(mobileprovision)
ids_codesign = dict(_find_codesign_identities())
ids_codesign = set(_find_codesign_identities())
for id_mpf in _get_identities_from_provisioning_profile(mpf):
if id_mpf in ids_codesign:
return (id_mpf, ids_codesign[id_mpf])
return id_mpf


def _filter_codesign_output(codesign_output):
Expand All @@ -149,21 +150,6 @@ def _filter_codesign_output(codesign_output):
filtered_lines.append(line)
return "\n".join(filtered_lines)

def _sign_flags(identity):
"""Produce codesign --sign flags for an identity"""
if isinstance(identity, tuple):
hash_id, name_id = identity
# Include both name and hash of the signing identity. The name is for
# debuggability, and the hash avoids a codesign error when given an
# ambiguous name. The name goes first, the hash overrides the name.
flags = []
if name_id:
flags.extend(["--sign", name_id])
flags.extend(["--sign", hash_id])
return flags
else:
return ["--sign", identity]

def main(argv):
parser = argparse.ArgumentParser(description="codesign wrapper")
parser.add_argument(
Expand All @@ -190,9 +176,8 @@ def main(argv):
print("ERROR: Unable to find an identity on the system matching the "\
"ones in %s" % args.mobileprovision, file=sys.stderr)
return 1
sign_args = _sign_flags(identity)
stdout, stderr = _check_output([args.codesign, "-v"] + sign_args
+ codesign_args)
stdout, stderr = _check_output([args.codesign, "-v", "--sign", identity] +
codesign_args,)
if stdout:
filtered_stdout = _filter_codesign_output(stdout)
if filtered_stdout:
Expand Down

0 comments on commit 0680f17

Please sign in to comment.