From 203191b5be3591643ba7871c8f8cc66ea8f38f6f Mon Sep 17 00:00:00 2001 From: Chris Gross Date: Sat, 30 May 2020 02:39:12 +0000 Subject: [PATCH] Use BUILD_*_IMAGE flags in add_img_to_target_files. Modify add_img_to_target_files.py to use the BUILDING_*_IMAGE flags when deciding whether to create and add a given image to a target files archive. To do this, the BUILDING_*_IMAGE flags are now dumped to misc_info.txt. The origin of this change was to use the BUILDING_USERDATA_IMAGE and BUILDING_CACHE_IMAGE flags in add_img_to_target_files.py so that we could reliably turn off the generation of the userdata and cache images. The other image flags were added for symmetry. Bug: 130307439 Test: m -j out/target/product/bonito/misc_info.txt Test: m -j droid dist Change-Id: I32d5a8d6c9ebb5f329d856030084d698ee8d271d --- core/Makefile | 13 ++++++ tools/releasetools/add_img_to_target_files.py | 43 +++++++++++-------- tools/releasetools/merge_target_files.py | 3 ++ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/core/Makefile b/core/Makefile index 7a3757cc0..4c25c49c6 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1176,6 +1176,10 @@ $(if $(filter $(2),system),\ $(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1)) $(if $(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_reserved_size=$(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1)) $(hide) echo "system_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_system_image=$(BUILDING_SYSTEM_IMAGE)" >> $(1) +) +$(if $(filter $(2),system_other),\ + $(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1) ) $(if $(filter $(2),userdata),\ $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1183,11 +1187,13 @@ $(if $(filter $(2),userdata),\ $(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1)) $(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1)) $(hide) echo "userdata_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_userdata_image=$(BUILDING_USERDATA_IMAGE)" >> $(1) ) $(if $(filter $(2),cache),\ $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) $(hide) echo "cache_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_cache_image=$(BUILDING_CACHE_IMAGE)" >> $(1) ) $(if $(filter $(2),vendor),\ $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1202,6 +1208,7 @@ $(if $(filter $(2),vendor),\ $(if $(PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1)) $(if $(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "vendor_reserved_size=$(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE)" >> $(1)) $(hide) echo "vendor_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_vendor_image=$(BUILDING_VENDOR_IMAGE)" >> $(1) ) $(if $(filter $(2),product),\ $(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1216,6 +1223,7 @@ $(if $(filter $(2),product),\ $(if $(PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "product_base_fs_file=$(PRODUCT_PRODUCT_BASE_FS_PATH)" >> $(1)) $(if $(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "product_reserved_size=$(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1)) $(hide) echo "product_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_product_image=$(BUILDING_PRODUCT_IMAGE)" >> $(1) ) $(if $(filter $(2),system_ext),\ $(if $(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_ext_fs_type=$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1229,6 +1237,7 @@ $(if $(filter $(2),system_ext),\ $(if $(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_ext_squashfs_disable_4k_align=$(BOARD_SYSTEM_EXTIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1)) $(if $(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "system_ext_reserved_size=$(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE)" >> $(1)) $(hide) echo "system_ext_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_system_ext_image=$(BUILDING_SYSTEM_EXT_IMAGE)" >> $(1) ) $(if $(filter $(2),odm),\ $(if $(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "odm_fs_type=$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1243,6 +1252,7 @@ $(if $(filter $(2),odm),\ $(if $(PRODUCT_ODM_BASE_FS_PATH),$(hide) echo "odm_base_fs_file=$(PRODUCT_ODM_BASE_FS_PATH)" >> $(1)) $(if $(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "odm_reserved_size=$(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE)" >> $(1)) $(hide) echo "odm_selinux_fc=$(SELINUX_FC)" >> $(1) + $(hide) echo "building_odm_image=$(BUILDING_ODM_IMAGE)" >> $(1) ) $(if $(filter $(2),oem),\ $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1)) @@ -1337,6 +1347,9 @@ endif ifdef BUILDING_SYSTEM_IMAGE PROP_DICTIONARY_IMAGES += system endif +ifdef BUILDING_SYSTEM_OTHER_IMAGE + PROP_DICTIONARY_IMAGES += system_other +endif ifdef BUILDING_USERDATA_IMAGE PROP_DICTIONARY_IMAGES += userdata endif diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 490b44a6f..45a2a2ebb 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -741,23 +741,32 @@ def AddImagesToTargetFiles(filename): # 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")) 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")) or - os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES", - "odm.img"))) - has_product = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "PRODUCT")) 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")) 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")) - has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp, - "SYSTEM_OTHER")) + 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_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") + has_userdata = OPTIONS.info_dict.get("building_userdata_image") == "true" + has_cache = OPTIONS.info_dict.get("building_cache_image") == "true" # Set up the output destination. It writes to the given directory for dir # mode; otherwise appends to the given ZIP. diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py index d9d385405..ed42b20d2 100755 --- a/tools/releasetools/merge_target_files.py +++ b/tools/releasetools/merge_target_files.py @@ -175,6 +175,9 @@ DEFAULT_FRAMEWORK_MISC_INFO_KEYS = ( 'ab_update', 'default_system_dev_certificate', 'system_size', + 'building_system_image', + 'building_system_ext_image', + 'building_product_image', ) # DEFAULT_VENDOR_ITEM_LIST is a list of items to extract from the partial