releasetools: Include descriptor of `vbmeta_system.img` in `vbmeta.img`.

Chained vbmeta images should be included into the top-level vbmeta.img
as chained partitions. It's done in the path of `m`, but not `m dist`.

Bug: 118115607
Test: `m dist` a target that uses chained vbmeta.
    a) Check that the `vbmeta.img` in target-img.zip contains the image
       descriptor of `vbmeta_system.img` (`avbtool info_image`).
    b) `avbtool verify_image --image vbmeta.img \
            --expected_chain_partition \
                vbmeta_system:1:/path/to/vbmeta_system/pubkey`
    c) `avbtool verify_image --image vbmeta_system.img`
Change-Id: I064e583b247c44b9b2f19355838550bb5dbb8f26
This commit is contained in:
Tao Bao 2018-10-22 15:08:02 -07:00
parent 4c95ffa8ef
commit 7106420add
1 changed files with 8 additions and 3 deletions

View File

@ -405,6 +405,9 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions):
needed_partitions: Partitions whose descriptors should be included into the needed_partitions: Partitions whose descriptors should be included into the
generated VBMeta image. generated VBMeta image.
Returns:
Path to the created image.
Raises: Raises:
AssertionError: On invalid input args. AssertionError: On invalid input args.
""" """
@ -423,7 +426,8 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions):
for partition, path in partitions.items(): for partition, path in partitions.items():
if partition not in needed_partitions: if partition not in needed_partitions:
continue continue
assert partition in common.AVB_PARTITIONS, \ assert (partition in common.AVB_PARTITIONS or
partition.startswith('vbmeta_')), \
'Unknown partition: {}'.format(partition) 'Unknown partition: {}'.format(partition)
assert os.path.exists(path), \ assert os.path.exists(path), \
'Failed to find {} for {}'.format(path, partition) 'Failed to find {} for {}'.format(path, partition)
@ -458,6 +462,7 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions):
assert proc.returncode == 0, \ assert proc.returncode == 0, \
"avbtool make_vbmeta_image failed:\n{}".format(stdoutdata) "avbtool make_vbmeta_image failed:\n{}".format(stdoutdata)
img.Write() img.Write()
return img.name
def AddPartitionTable(output_zip): def AddPartitionTable(output_zip):
@ -836,7 +841,7 @@ def AddImagesToTargetFiles(filename):
vbmeta_system = OPTIONS.info_dict.get("avb_vbmeta_system", "").strip() vbmeta_system = OPTIONS.info_dict.get("avb_vbmeta_system", "").strip()
if vbmeta_system: if vbmeta_system:
banner("vbmeta_system") banner("vbmeta_system")
AddVBMeta( partitions["vbmeta_system"] = AddVBMeta(
output_zip, partitions, "vbmeta_system", vbmeta_system.split()) output_zip, partitions, "vbmeta_system", vbmeta_system.split())
vbmeta_partitions = [ vbmeta_partitions = [
item for item in vbmeta_partitions item for item in vbmeta_partitions
@ -846,7 +851,7 @@ def AddImagesToTargetFiles(filename):
vbmeta_vendor = OPTIONS.info_dict.get("avb_vbmeta_vendor", "").strip() vbmeta_vendor = OPTIONS.info_dict.get("avb_vbmeta_vendor", "").strip()
if vbmeta_vendor: if vbmeta_vendor:
banner("vbmeta_vendor") banner("vbmeta_vendor")
AddVBMeta( partitions["vbmeta_vendor"] = AddVBMeta(
output_zip, partitions, "vbmeta_vendor", vbmeta_vendor.split()) output_zip, partitions, "vbmeta_vendor", vbmeta_vendor.split())
vbmeta_partitions = [ vbmeta_partitions = [
item for item in vbmeta_partitions item for item in vbmeta_partitions