From 7106420adddd19921bd12361121c4aaa5ff1a218 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 22 Oct 2018 15:08:02 -0700 Subject: [PATCH] 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 --- tools/releasetools/add_img_to_target_files.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 1e8677c93..ddc50be8b 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -405,6 +405,9 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions): needed_partitions: Partitions whose descriptors should be included into the generated VBMeta image. + Returns: + Path to the created image. + Raises: AssertionError: On invalid input args. """ @@ -423,7 +426,8 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions): for partition, path in partitions.items(): if partition not in needed_partitions: continue - assert partition in common.AVB_PARTITIONS, \ + assert (partition in common.AVB_PARTITIONS or + partition.startswith('vbmeta_')), \ 'Unknown partition: {}'.format(partition) assert os.path.exists(path), \ 'Failed to find {} for {}'.format(path, partition) @@ -458,6 +462,7 @@ def AddVBMeta(output_zip, partitions, name, needed_partitions): assert proc.returncode == 0, \ "avbtool make_vbmeta_image failed:\n{}".format(stdoutdata) img.Write() + return img.name def AddPartitionTable(output_zip): @@ -836,7 +841,7 @@ def AddImagesToTargetFiles(filename): vbmeta_system = OPTIONS.info_dict.get("avb_vbmeta_system", "").strip() if vbmeta_system: banner("vbmeta_system") - AddVBMeta( + partitions["vbmeta_system"] = AddVBMeta( output_zip, partitions, "vbmeta_system", vbmeta_system.split()) 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() if vbmeta_vendor: banner("vbmeta_vendor") - AddVBMeta( + partitions["vbmeta_vendor"] = AddVBMeta( output_zip, partitions, "vbmeta_vendor", vbmeta_vendor.split()) vbmeta_partitions = [ item for item in vbmeta_partitions