From: Tianjie Xu Date: Mon, 11 Jul 2016 18:42:53 +0000 (-0700) Subject: resolve merge conflicts of 333df6c to nyc-mr1-dev-plus-aosp X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=737afb98c9c1be26ef7d8052696673bb657948b8;p=android-x86%2Fbuild.git resolve merge conflicts of 333df6c to nyc-mr1-dev-plus-aosp Change-Id: Ibe66a7c78073a9c3e9f139bd6b00a0afab075190 --- 737afb98c9c1be26ef7d8052696673bb657948b8 diff --cc tools/releasetools/add_img_to_target_files.py index 03bb0b106,6acc69dbd..aeb73d410 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@@ -48,9 -47,22 +49,22 @@@ OPTIONS.replace_verity_public_key = Fal 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): @@@ -391,20 -347,12 +407,21 @@@ def AddImagesToTargetFiles(filename) 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) @@@ -424,16 -367,21 +441,28 @@@ 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: + if line.strip() == "system" and OPTIONS.info_dict.get( + "system_verity_block_device", None) is not None: - assert os.path.exists(system_imgname) - care_map_list += GetCareMap("system", system_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_imgname) - care_map_list += GetCareMap("vendor", vendor_imgname) ++ 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))