Merge "Allow vendors to add custom vbmeta partitions" am: b80d9d6c33 am: b63987d351

Original change: https://android-review.googlesource.com/c/platform/build/+/2380861

Change-Id: I4042684ef0171f8191b19a29b7695e988b31c552
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-01-14 02:38:57 +00:00 committed by Automerger Merge Worker
commit 5d0d291fb0
4 changed files with 77 additions and 10 deletions

View file

@ -4090,7 +4090,8 @@ endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
$(BOARD_AVB_VBMETA_SYSTEM) \
$(BOARD_AVB_VBMETA_VENDOR)
$(BOARD_AVB_VBMETA_VENDOR) \
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))))
# Not allowing the same partition to appear in multiple groups.
ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
@ -4396,6 +4397,11 @@ ifdef BOARD_AVB_VBMETA_VENDOR
$(eval $(call check-and-set-avb-args,vbmeta_vendor))
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval $(call check-and-set-avb-args,vbmeta_$(partition))))
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS += --padding_size 4096))
endif
ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
@ -4424,6 +4430,13 @@ BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
--rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
$(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)), \
$(if $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX),$(eval \
BOARD_AVB_MAKE_VBMETA_$(partition)_IMAGE_ARGS += \
--rollback_index $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX))))
endif
# $(1): the directory to extract public keys to
define extract-avb-chain-public-keys
$(if $(BOARD_AVB_BOOT_KEY_PATH),\
@ -4480,7 +4493,11 @@ define extract-avb-chain-public-keys
$(if $(BOARD_CUSTOMIMAGES_PARTITION_LIST),\
$(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
--output $(1)/$(partition).avbpubkey;))
--output $(1)/$(partition).avbpubkey;)) \
$(if $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH) \
--output $(1)/vbmeta_$(partition).avbpubkey;))
endef
# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
@ -4492,13 +4509,13 @@ endef
# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
# $(2): Output filename.
define build-chained-vbmeta-image
$(call pretty,"Target chained vbmeta image: $@")
$(hide) $(AVBTOOL) make_vbmeta_image \
$(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
$(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
$(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
--include_descriptors_from_image $(call images-for-partitions,$(image))) \
--output $@
$(call pretty,"Target chained vbmeta image: $@")
$(hide) $(AVBTOOL) make_vbmeta_image \
$(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
$(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
$(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
--include_descriptors_from_image $(call images-for-partitions,$(image))) \
--output $@
endef
ifdef BUILDING_SYSTEM_IMAGE
@ -4526,7 +4543,26 @@ $(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
define declare-custom-vbmeta-target
INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_$(call to-lower,$(1)).img
$$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET): \
$(AVBTOOL) \
$(call images-for-partitions,$(BOARD_AVB_VBMETA_$(call to-upper,$(1)))) \
$(BOARD_AVB_VBMETA_$(call to-upper,$(1))_KEY_PATH)
$$(call build-chained-vbmeta-image,vbmeta_$(call to-lower,$(1)))
$(call declare-1p-container,$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET),)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET)
endef
$(foreach partition,\
$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),\
$(eval $(call declare-custom-vbmeta-target,$(partition))))
endif
define build-vbmetaimage-target
@ -4566,8 +4602,10 @@ $(INSTALLED_VBMETAIMAGE_TARGET): \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
$(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
$(foreach partition,$(call to-upper,$( BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(INSTALLED_VBMETA_$(partition)IMAGE_TARGET)) \
$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
$(foreach partition,$(call to-upper,$( BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(BOARD_AVB_VBMETA_$(partition)_KEY_PATH)) \
$(BOARD_AVB_KEY_PATH)
$(build-vbmetaimage-target)
@ -5319,6 +5357,15 @@ ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
$(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
$(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
ifneq (,$(strip $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)))
$(hide) echo "avb_custom_vbmeta_images_partition_list=$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)" >> $@
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
echo "avb_vbmeta_$(partition)=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition)))" >> $@ ;\
echo "avb_vbmeta_$(partition)_args=$(BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS)" >> $@ ;\
echo "avb_vbmeta_$(partition)_key_path=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH)" >> $@ ;\
echo "avb_vbmeta_$(partition)_algorithm=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ALGORITHM)" >> $@ ;\
echo "avb_vbmeta_$(partition)_rollback_index_location=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@ ;)
endif # BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
endif # BOARD_AVB_ENABLE
ifdef BOARD_BPT_INPUT_FILES
$(hide) echo "board_bpt_enable=true" >> $@

View file

@ -1602,6 +1602,9 @@ vbmetasystemimage: $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
.PHONY: vbmetavendorimage
vbmetavendorimage: $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
.PHONY: vbmetacustomimages
vbmetacustomimages: $(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(INSTALLED_VBMETA_$(partition)IMAGE_TARGET))
# The droidcore-unbundled target depends on the subset of targets necessary to
# perform a full system build (either unbundled or not).
.PHONY: droidcore-unbundled

View file

@ -1132,6 +1132,21 @@ def AddImagesToTargetFiles(filename):
item for item in vbmeta_partitions
if item not in vbmeta_vendor.split()]
vbmeta_partitions.append("vbmeta_vendor")
custom_avb_partitions = OPTIONS.info_dict.get("avb_custom_vbmeta_images_partition_list", "").strip().split()
if custom_avb_partitions:
for avb_part in custom_avb_partitions:
partition_name = "vbmeta_" + avb_part
included_partitions = OPTIONS.info_dict.get("avb_vbmeta_{}".format(avb_part), "").strip().split()
assert included_partitions, "Custom vbmeta partition {0} missing avb_vbmeta_{0} prop".format(avb_part)
banner(partition_name)
logger.info("VBMeta partition {} needs {}".format(partition_name, included_partitions))
partitions[partition_name] = AddVBMeta(
output_zip, partitions, partition_name, included_partitions)
vbmeta_partitions = [
item for item in vbmeta_partitions
if item not in included_partitions]
vbmeta_partitions.append(partition_name)
if OPTIONS.info_dict.get("avb_building_vbmeta_image") == "true":
banner("vbmeta")

View file

@ -1503,12 +1503,14 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions):
custom_partitions = OPTIONS.info_dict.get(
"avb_custom_images_partition_list", "").strip().split()
custom_avb_partitions = ["vbmeta_" + part for part in OPTIONS.info_dict.get("avb_custom_vbmeta_images_partition_list", "").strip().split()]
for partition, path in partitions.items():
if partition not in needed_partitions:
continue
assert (partition in AVB_PARTITIONS or
partition in AVB_VBMETA_PARTITIONS or
partition in custom_avb_partitions or
partition in custom_partitions), \
'Unknown partition: {}'.format(partition)
assert os.path.exists(path), \