generalize -t option to add and remove tags in fingerprints
To support devphone and holiday builds we need more control over the build fingerprint tags; generalize the -t option so we can arbitrarily add and remove tags.
This commit is contained in:
@@ -54,10 +54,13 @@ Usage: sign_target_files_apks [flags] input_target_files output_target_files
|
|||||||
zip (in the META/otakeys.txt file). Key remapping (-k and -d)
|
zip (in the META/otakeys.txt file). Key remapping (-k and -d)
|
||||||
is performed on this key.
|
is performed on this key.
|
||||||
|
|
||||||
-t (--extra_tag) <tag>
|
-t (--tag_changes) <+tag>,<-tag>,...
|
||||||
A string which is added to the set of tags in the last component
|
Comma-separated list of changes to make to the set of tags (in
|
||||||
of the build fingerprint. Option may be repeated to give
|
the last component of the build fingerprint). Prefix each with
|
||||||
multiple extra tags.
|
'+' or '-' to indicate whether that tag should be added or
|
||||||
|
removed. Changes are processed in the order they appear.
|
||||||
|
Default value is "-test-keys,+ota-rel-keys,+release-keys".
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@@ -81,7 +84,7 @@ OPTIONS = common.OPTIONS
|
|||||||
OPTIONS.extra_apks = {}
|
OPTIONS.extra_apks = {}
|
||||||
OPTIONS.key_map = {}
|
OPTIONS.key_map = {}
|
||||||
OPTIONS.replace_ota_keys = False
|
OPTIONS.replace_ota_keys = False
|
||||||
OPTIONS.extra_tags = []
|
OPTIONS.tag_changes = ("-test-keys", "+ota-rel-keys", "+release-keys")
|
||||||
|
|
||||||
def GetApkCerts(tf_zip):
|
def GetApkCerts(tf_zip):
|
||||||
certmap = {}
|
certmap = {}
|
||||||
@@ -173,23 +176,21 @@ def RewriteProps(data):
|
|||||||
if key == "ro.build.fingerprint":
|
if key == "ro.build.fingerprint":
|
||||||
pieces = line.split("/")
|
pieces = line.split("/")
|
||||||
tags = set(pieces[-1].split(","))
|
tags = set(pieces[-1].split(","))
|
||||||
if "test-keys" in tags:
|
for ch in OPTIONS.tag_changes:
|
||||||
tags.remove("test-keys")
|
if ch[0] == "-":
|
||||||
tags.add("release-keys")
|
tags.discard(ch[1:])
|
||||||
# TODO: from donut onwards, only add ota-rel-keys if -o is given.
|
elif ch[0] == "+":
|
||||||
tags.add("ota-rel-keys")
|
tags.add(ch[1:])
|
||||||
tags.update(OPTIONS.extra_tags)
|
|
||||||
line = "/".join(pieces[:-1] + [",".join(sorted(tags))])
|
line = "/".join(pieces[:-1] + [",".join(sorted(tags))])
|
||||||
elif key == "ro.build.description":
|
elif key == "ro.build.description":
|
||||||
pieces = line.split(" ")
|
pieces = line.split(" ")
|
||||||
assert len(pieces) == 5
|
assert len(pieces) == 5
|
||||||
tags = set(pieces[-1].split(","))
|
tags = set(pieces[-1].split(","))
|
||||||
if "test-keys" in tags:
|
for ch in OPTIONS.tag_changes:
|
||||||
tags.remove("test-keys")
|
if ch[0] == "-":
|
||||||
tags.add("release-keys")
|
tags.discard(ch[1:])
|
||||||
# TODO: from donut onwards, only add ota-rel-keys if -o is given.
|
elif ch[0] == "+":
|
||||||
tags.add("ota-rel-keys")
|
tags.add(ch[1:])
|
||||||
tags.update(OPTIONS.extra_tags)
|
|
||||||
line = " ".join(pieces[:-1] + [",".join(sorted(tags))])
|
line = " ".join(pieces[:-1] + [",".join(sorted(tags))])
|
||||||
if line != original_line:
|
if line != original_line:
|
||||||
print " replace: ", original_line
|
print " replace: ", original_line
|
||||||
@@ -259,8 +260,14 @@ def main(argv):
|
|||||||
OPTIONS.key_map[s] = d
|
OPTIONS.key_map[s] = d
|
||||||
elif o in ("-o", "--replace_ota_keys"):
|
elif o in ("-o", "--replace_ota_keys"):
|
||||||
OPTIONS.replace_ota_keys = True
|
OPTIONS.replace_ota_keys = True
|
||||||
elif o in ("-t", "--extra_tags"):
|
elif o in ("-t", "--tag_changes"):
|
||||||
OPTIONS.extra_tags.append(a)
|
new = []
|
||||||
|
for i in a.split(","):
|
||||||
|
i = i.strip()
|
||||||
|
if not i or i[0] not in "-+":
|
||||||
|
raise ValueError("Bad tag change '%s'" % (i,))
|
||||||
|
new.append(i[0] + i[1:].strip())
|
||||||
|
OPTIONS.tag_changes = tuple(new)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -272,7 +279,7 @@ def main(argv):
|
|||||||
"default_key_mappings=",
|
"default_key_mappings=",
|
||||||
"key_mapping=",
|
"key_mapping=",
|
||||||
"replace_ota_keys",
|
"replace_ota_keys",
|
||||||
"extra_tag="],
|
"tag_changes="],
|
||||||
extra_option_handler=option_handler)
|
extra_option_handler=option_handler)
|
||||||
|
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
|
Reference in New Issue
Block a user