diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index a1f8e31b8..eb041ecea 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -739,6 +739,18 @@ def ReplaceUpdatedFiles(zip_filename, files_list): common.ZipClose(output_zip) +def HasPartition(partition_name): + """Determines if the target files archive should build a given partition.""" + + return ((os.path.isdir( + os.path.join(OPTIONS.input_tmp, partition_name.upper())) and + OPTIONS.info_dict.get( + "building_{}_image".format(partition_name)) == "true") or + os.path.exists( + os.path.join(OPTIONS.input_tmp, "IMAGES", + "{}.img".format(partition_name)))) + + def AddImagesToTargetFiles(filename): """Creates and adds images (boot/recovery/system/...) to a target_files.zip. @@ -767,49 +779,16 @@ def AddImagesToTargetFiles(filename): has_boot = OPTIONS.info_dict.get("no_boot") != "true" has_vendor_boot = OPTIONS.info_dict.get("vendor_boot") == "true" - # {vendor,odm,product,system_ext,vendor_dlkm,odm_dlkm}.img - # are unlike system.img or - # system_other.img, because it could be built from source, or dropped into - # target_files.zip as a prebuilt blob. We consider either of them as - # {vendor,product,system_ext}.img being available, which could be - # used when generating vbmeta.img for AVB. - has_vendor = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) and - OPTIONS.info_dict.get("building_vendor_image") == "true") or - os.path.exists( - os.path.join(OPTIONS.input_tmp, "IMAGES", "vendor.img"))) - has_odm = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "ODM")) and - OPTIONS.info_dict.get("building_odm_image") == "true") or - os.path.exists( - os.path.join(OPTIONS.input_tmp, "IMAGES", "odm.img"))) - has_vendor_dlkm = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, - "VENDOR_DLKM")) and - OPTIONS.info_dict.get("building_vendor_dlkm_image") - == "true") or - os.path.exists( - os.path.join(OPTIONS.input_tmp, "IMAGES", - "vendor_dlkm.img"))) - has_odm_dlkm = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, - "ODM_DLKM")) and - OPTIONS.info_dict.get("building_odm_dlkm_image") - == "true") or - os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", - "odm_dlkm.img"))) - has_product = ((os.path.isdir(os.path.join(OPTIONS.input_tmp, "PRODUCT")) and - OPTIONS.info_dict.get("building_product_image") == "true") or - os.path.exists( - os.path.join(OPTIONS.input_tmp, "IMAGES", "product.img"))) - has_system_ext = ( - (os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_EXT")) and - OPTIONS.info_dict.get("building_system_ext_image") == "true") or - os.path.exists( - os.path.join(OPTIONS.input_tmp, "IMAGES", "system_ext.img"))) - has_system = ( - os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM")) and - OPTIONS.info_dict.get("building_system_image") == "true") - - has_system_other = ( - os.path.isdir(os.path.join(OPTIONS.input_tmp, "SYSTEM_OTHER")) and - OPTIONS.info_dict.get("building_system_other_image") == "true") + # {vendor,odm,product,system_ext,vendor_dlkm,odm_dlkm, system, system_other}.img + # can be built from source, or dropped into target_files.zip as a prebuilt blob. + has_vendor = HasPartition("vendor") + has_odm = HasPartition("odm") + has_vendor_dlkm = HasPartition("vendor_dlkm") + has_odm_dlkm = HasPartition("odm_dlkm") + has_product = HasPartition("product") + has_system_ext = HasPartition("system_ext") + has_system = HasPartition("system") + has_system_other = HasPartition("system_other") has_userdata = OPTIONS.info_dict.get("building_userdata_image") == "true" has_cache = OPTIONS.info_dict.get("building_cache_image") == "true" diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py index 45532f50d..bfd2f90c4 100755 --- a/tools/releasetools/merge_target_files.py +++ b/tools/releasetools/merge_target_files.py @@ -197,8 +197,6 @@ DEFAULT_VENDOR_ITEM_LIST = ( 'PREBUILT_IMAGES/*', 'RADIO/*', 'VENDOR/*', - 'VENDOR_DLKM/*', - 'ODM_DLKM/*', ) # VENDOR_EXTRACT_SPECIAL_ITEM_LIST is a list of items to extract from the