Make output of MakeVbmeta consistent
The order of items in `partitions` map is non-deterministic. To make
sure that builds are hermetic, sort the map before use.
Test: th
Bug: 332550989
Change-Id: I76c7037ef9f03904899339813819fcf985a7c893
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index a2c0949..b39a82c 100644
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -1055,20 +1055,6 @@
for call in add_partition_calls:
add_partition(*call)
else:
- # When calling avbtool make_vbmeta_image, it uses the `partitions`
- # dictionary to include the options for --include_descriptors_from_image.
- # The vbmeta image is different if the order of the
- # --include_descriptors_from_image changes. As the images are generated
- # parallelly and entries are added on completion of image creation,
- # this `partitions` dict might be indeterministic as the order of
- # completion of image creation cannot be predicted.
- # To address this issue, add keys to the dict `partitions` with null values
- # in the order they are listed in the variable `add_partition_calls`, and
- # then the values are updated by `add_partition` keeping the order of the
- # items. This ensures generated vbmeta.img is the same for the same input.
- for call in add_partition_calls:
- if call[1]:
- partitions[call[0]] = None
with ThreadPoolExecutor(max_workers=len(add_partition_calls)) as executor:
for future in [executor.submit(add_partition, *call) for call in add_partition_calls]:
future.result()
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 264c2d8..9771992 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1524,7 +1524,7 @@
AVB_ARG_NAME_CHAIN_PARTITION: []
}
- for partition, path in partitions.items():
+ for partition, path in sorted(partitions.items()):
avb_partition_arg = GetAvbPartitionArg(partition, path, info_dict)
if not avb_partition_arg:
continue
@@ -1612,7 +1612,7 @@
"avb_custom_vbmeta_images_partition_list", "").strip().split()]
avb_partitions = {}
- for partition, path in partitions.items():
+ for partition, path in sorted(partitions.items()):
if partition not in needed_partitions:
continue
assert (partition in AVB_PARTITIONS or