Rename care map in pb format to care_map.pb
The new suffix distinguishes the new care_map from the ones in plain
text format; and thus the old update_verifier won't report an error
upon parsing failures.
Bug: 115740187
Test: Generate OTA files for Pixels
Change-Id: Ia782afd8cbb0f4bb8c363edaa00e92ab302d5d1b
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index eaba4df..e75adf5 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -1167,7 +1167,8 @@
'payload_properties.txt',
)
self.optional = (
- # care_map.txt is available only if dm-verity is enabled.
+ # care_map is available only if dm-verity is enabled.
+ 'care_map.pb',
'care_map.txt',
# compatibility.zip is available only if target supports Treble.
'compatibility.zip',
@@ -1786,13 +1787,16 @@
target_zip = zipfile.ZipFile(target_file, "r")
if (target_info.get("verity") == "true" or
target_info.get("avb_enable") == "true"):
- care_map_path = "META/care_map.txt"
- namelist = target_zip.namelist()
- if care_map_path in namelist:
- care_map_data = target_zip.read(care_map_path)
- # In order to support streaming, care_map.txt needs to be packed as
+ care_map_list = [x for x in ["care_map.pb", "care_map.txt"] if
+ "META/" + x in target_zip.namelist()]
+
+ # Adds care_map if either the protobuf format or the plain text one exists.
+ if care_map_list:
+ care_map_name = care_map_list[0]
+ care_map_data = target_zip.read("META/" + care_map_name)
+ # In order to support streaming, care_map needs to be packed as
# ZIP_STORED.
- common.ZipWriteStr(output_zip, "care_map.txt", care_map_data,
+ common.ZipWriteStr(output_zip, care_map_name, care_map_data,
compress_type=zipfile.ZIP_STORED)
else:
print("Warning: cannot find care map file in target_file package")