Resolve conflict AVB rollback index location
Add an `--avb-resolve-rollback-index-location-conflict`
option in merge_target_files. When this option is set,
the merge tool will resolve conflicting index locations
by assigning the smallest unused index location.
This is to support merging system and vendor target files
from two different targets. In this case, the two target
files may have conflict rollback index location because
they were built independently.
Test: atest releasetools_test
Test: validate_target_files *-target_files-*.zip
Test: merge_target_files &&
add_img_to_target_files &&
img_from_target_files &&
flash device
Bug: 300604688
Change-Id: Ibd18ef2a9f3784157fe17966f5364c3c81c9bd9f
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 31f8736..fc4ab68 100644
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -42,6 +42,10 @@
--is_signing
Skip building & adding the images for "userdata" and "cache" if we
are signing the target files.
+
+ --avb-resolve-rollback-index-location-conflict
+ If provided, resolve the conflict AVB rollback index location when
+ necessary.
"""
from __future__ import print_function
@@ -81,6 +85,7 @@
OPTIONS.rebuild_recovery = False
OPTIONS.replace_updated_files_list = []
OPTIONS.is_signing = False
+OPTIONS.avb_resolve_rollback_index_location_conflict = False
def ParseAvbFooter(img_path) -> avbtool.AvbFooter:
@@ -682,7 +687,8 @@
logger.info("%s.img already exists; not rebuilding...", name)
return img.name
- common.BuildVBMeta(img.name, partitions, name, needed_partitions)
+ common.BuildVBMeta(img.name, partitions, name, needed_partitions,
+ OPTIONS.avb_resolve_rollback_index_location_conflict)
img.Write()
return img.name
@@ -1224,6 +1230,8 @@
" please switch to AVB")
elif o == "--is_signing":
OPTIONS.is_signing = True
+ elif o == "--avb_resolve_rollback_index_location_conflict":
+ OPTIONS.avb_resolve_rollback_index_location_conflict = True
else:
return False
return True
@@ -1233,7 +1241,8 @@
extra_long_opts=["add_missing", "rebuild_recovery",
"replace_verity_public_key=",
"replace_verity_private_key=",
- "is_signing"],
+ "is_signing",
+ "avb_resolve_rollback_index_location_conflict"],
extra_option_handler=option_handler)
if len(args) != 1: