Merge "Handles capex in signing script"

This commit is contained in:
Treehugger Robot
2021-06-12 11:40:08 +00:00
committed by Gerrit Code Review

View File

@@ -217,6 +217,18 @@ for partition in common.AVB_PARTITIONS:
raise RuntimeError("Missing {} in AVB_FOOTER_ARGS".format(partition)) raise RuntimeError("Missing {} in AVB_FOOTER_ARGS".format(partition))
def IsApexFile(filename):
return filename.endswith(".apex") or filename.endswith(".capex")
def GetApexFilename(filename):
name = os.path.basename(filename)
# Replace the suffix for compressed apex
if name.endswith(".capex"):
return name.replace(".capex", ".apex")
return name
def GetApkCerts(certmap): def GetApkCerts(certmap):
# apply the key remapping to the contents of the file # apply the key remapping to the contents of the file
for apk, cert in certmap.items(): for apk, cert in certmap.items():
@@ -356,8 +368,8 @@ def CheckApkAndApexKeysAvailable(input_tf_zip, known_keys,
unknown_files = [] unknown_files = []
for info in input_tf_zip.infolist(): for info in input_tf_zip.infolist():
# Handle APEXes on all partitions # Handle APEXes on all partitions
if info.filename.endswith('.apex'): if IsApexFile(info.filename):
name = os.path.basename(info.filename) name = GetApexFilename(info.filename)
if name not in known_keys: if name not in known_keys:
unknown_files.append(name) unknown_files.append(name)
continue continue
@@ -388,10 +400,11 @@ def CheckApkAndApexKeysAvailable(input_tf_zip, known_keys,
invalid_apexes = [] invalid_apexes = []
for info in input_tf_zip.infolist(): for info in input_tf_zip.infolist():
if not info.filename.endswith('.apex'): if not IsApexFile(info.filename):
continue continue
name = os.path.basename(info.filename) name = GetApexFilename(info.filename)
(payload_key, container_key) = apex_keys[name] (payload_key, container_key) = apex_keys[name]
if ((payload_key in common.SPECIAL_CERT_STRINGS and if ((payload_key in common.SPECIAL_CERT_STRINGS and
container_key not in common.SPECIAL_CERT_STRINGS) or container_key not in common.SPECIAL_CERT_STRINGS) or
@@ -541,8 +554,9 @@ def ProcessTargetFiles(input_tf_zip, output_tf_zip, misc_info,
common.ZipWriteStr(output_tf_zip, out_info, data) common.ZipWriteStr(output_tf_zip, out_info, data)
# Sign bundled APEX files on all partitions # Sign bundled APEX files on all partitions
elif filename.endswith(".apex"): elif IsApexFile(filename):
name = os.path.basename(filename) name = GetApexFilename(filename)
payload_key, container_key = apex_keys[name] payload_key, container_key = apex_keys[name]
# We've asserted not having a case with only one of them PRESIGNED. # We've asserted not having a case with only one of them PRESIGNED.