OPTIONS.replace_verity_private_key = False
OPTIONS.verity_signer_path = None
+ def GetCareMap(which, imgname):
+ """Generate care_map of system (or vendor) partition"""
+
+ assert which in ("system", "vendor")
+ _, blk_device = common.GetTypeAndDevice("/" + which, OPTIONS.info_dict)
+
+ simg = sparse_img.SparseImage(imgname)
+ care_map_list = []
+ care_map_list.append(blk_device)
+ care_map_list.append(simg.care_map.to_string_raw())
+ return care_map_list
+
+
def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
"""Turn the contents of SYSTEM into a system image and store it in
- output_zip."""
+ output_zip. Returns the name of the system image file."""
prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img")
if os.path.exists(prebuilt_path):
recovery_image.AddToZip(output_zip)
banner("system")
- system_imgname = AddSystem(output_zip, recovery_img=recovery_image,
- boot_img=boot_image)
- vendor_imgname = None
+ system_img_path = AddSystem(
+ output_zip, recovery_img=recovery_image, boot_img=boot_image)
+ if OPTIONS.info_dict.get("board_bvb_enable", None) == "true":
+ # If we're using Brillo Verified Boot, we can now build boot.img
+ # given that we have system.img.
+ banner("boot")
+ boot_image = common.GetBootableImage(
+ "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT",
+ system_img_path=system_img_path)
+ if boot_image:
+ boot_image.AddToZip(output_zip)
++ vendor_img_path = None
if has_vendor:
banner("vendor")
- AddVendor(output_zip)
- vendor_imgname = AddVendor(output_zip)
++ vendor_img_path = AddVendor(output_zip)
if has_system_other:
banner("system_other")
AddSystemOther(output_zip)
if os.path.exists(ab_partitions):
with open(ab_partitions, 'r') as f:
lines = f.readlines()
+ # For devices using A/B update, generate care_map for system and vendor
+ # partitions (if present), then write this file to target_files package.
+ care_map_list = []
for line in lines:
- assert os.path.exists(system_imgname)
- care_map_list += GetCareMap("system", system_imgname)
+ if line.strip() == "system" and OPTIONS.info_dict.get(
+ "system_verity_block_device", None) is not None:
- assert os.path.exists(vendor_imgname)
- care_map_list += GetCareMap("vendor", vendor_imgname)
++ assert os.path.exists(system_img_path)
++ care_map_list += GetCareMap("system", system_img_path)
+ if line.strip() == "vendor" and OPTIONS.info_dict.get(
+ "vendor_verity_block_device", None) is not None:
++ assert os.path.exists(vendor_img_path)
++ care_map_list += GetCareMap("vendor", vendor_img_path)
+
img_name = line.strip() + ".img"
+ prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name)
+ if os.path.exists(prebuilt_path):
+ print "%s already exists, no need to overwrite..." % (img_name,)
+ continue
+
img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
+ img_vendor_dir = os.path.join(
+ OPTIONS.input_tmp, "VENDOR_IMAGES")
if os.path.exists(img_radio_path):
common.ZipWrite(output_zip, img_radio_path,
os.path.join("IMAGES", img_name))