Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67e43369 authored by Yifan Hong's avatar Yifan Hong
Browse files

Only assert-max-image-size for static partitions.

assert-max-image-size doesn't make sense for
dynamic partitions, as build_image.py always find the
right size for the output image. Hence:

- build_image.py no longer need to write generated_*_info.txt
  (which contains the size of the image).
- assert-max-image-size on the static BOARD_*IMAGE_PARTITION_SIZE. If
  a partition is dynamic, that variable isn't set, and
  assert-max-image-size becomes a no-op. If the partition is static,
  assert-max-image-size checks the static partition size as it used
  to be.
- Fix read-size-of-partitions to use the size of the partition by
  reading the image directly (instead of using generated_*_info.txt).

For devices without AVB, with DAP enabled, and does not have
RESERVED_SIZE for partitions, because of right sizing, the original
code always warns about approaching size limits. Since such checks
doesn't make sense for dynamic partitions, remove them.

Test: builds on device with dynamic partitions
Test: builds on cuttlefish with DAP enabled (without AVB), no
      more size limit warnings:
WARNING: out/target/product/vsoc_x86/vendor.img approaching size limit (X now; limit X)

Fixes: 122377935
Change-Id: I75e1b8322197cb18cf397d02aefd49d777bb6405
parent 7ad83b63
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -615,6 +615,8 @@ $(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts-tradefed.jar)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/security/avb/)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/security/avb/)


$(call add-clean-step, rm -rf $(PRODUCT_OUT)/super.img)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/super.img)

$(call add-clean-step, find $(PRODUCT_OUT) -type f -name "generated_*_image_info.txt" -print0 | xargs -0 rm -f)
# ************************************************
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# ************************************************
+17 −34
Original line number Original line Diff line number Diff line
@@ -2238,7 +2238,6 @@ define build-systemimage-target
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      build/make/tools/releasetools/build_image.py \
      build/make/tools/releasetools/build_image.py \
      $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
      $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
      $(systemimage_intermediates)/generated_system_image_info.txt \
      || ( mkdir -p $${DIST_DIR}; cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
      || ( mkdir -p $${DIST_DIR}; cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
           exit 1 )
           exit 1 )
endef
endef
@@ -2286,9 +2285,7 @@ endif # INSTALLED_BOOTIMAGE_TARGET
$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
	@echo "Install system fs image: $@"
	@echo "Install system fs image: $@"
	$(copy-file-to-target)
	$(copy-file-to-target)
	$(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),\
	$(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
	    $(call read-image-prop-dictionary,\
	        $(systemimage_intermediates)/generated_system_image_info.txt,system_size))


systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)


@@ -2297,9 +2294,7 @@ systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
	            | $(INTERNAL_USERIMAGES_DEPS)
	            | $(INTERNAL_USERIMAGES_DEPS)
	@echo "make $@: ignoring dependencies"
	@echo "make $@: ignoring dependencies"
	$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
	$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
	$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),\
	$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
	    $(call read-image-prop-dictionary,\
	        $(systemimage_intermediates)/generated_system_image_info.txt,system_size))


ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS)))
ifeq (true,$(WITH_DEXPREOPT))
ifeq (true,$(WITH_DEXPREOPT))
@@ -2665,11 +2660,8 @@ define build-systemotherimage-target
  $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
  $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      build/make/tools/releasetools/build_image.py \
      build/make/tools/releasetools/build_image.py \
      $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)\
      $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
      $(systemotherimage_intermediates)/generated_system_other_image_info.txt
  $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
  $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
    $(call read-image-prop-dictionary,\
      $(systemotherimage_intermediates)/generated_system_other_image_info.txt,system_other_size))
endef
endef


# We just build this directly to the install location.
# We just build this directly to the install location.
@@ -2808,11 +2800,8 @@ define build-vendorimage-target
    $(call build-image-kernel-modules,$(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_OUT_VENDOR),vendor/,$(call intermediates-dir-for,PACKAGING,depmod_vendor)))
    $(call build-image-kernel-modules,$(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_OUT_VENDOR),vendor/,$(call intermediates-dir-for,PACKAGING,depmod_vendor)))
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      build/make/tools/releasetools/build_image.py \
      build/make/tools/releasetools/build_image.py \
      $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT) \
      $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
      $(vendorimage_intermediates)/generated_vendor_image_info.txt
  $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
  $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),\
      $(call read-image-prop-dictionary,\
          $(vendorimage_intermediates)/generated_vendor_image_info.txt,vendor_size))
endef
endef


# We just build this directly to the install location.
# We just build this directly to the install location.
@@ -2866,11 +2855,8 @@ define build-productimage-target
  $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
  $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      ./build/tools/releasetools/build_image.py \
      ./build/tools/releasetools/build_image.py \
      $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT) \
      $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
      $(productimage_intermediates)/generated_product_image_info.txt
  $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
  $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),\
      $(call read-image-prop-dictionary,\
          $(productimage_intermediates)/generated_product_image_info.txt,product_size))
endef
endef


# We just build this directly to the install location.
# We just build this directly to the install location.
@@ -2921,11 +2907,8 @@ define build-product_servicesimage-target
  $(call generate-image-prop-dictionary, $(product_servicesimage_intermediates)/product_services_image_info.txt,product_services, skip_fsck=true)
  $(call generate-image-prop-dictionary, $(product_servicesimage_intermediates)/product_services_image_info.txt,product_services, skip_fsck=true)
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      ./build/tools/releasetools/build_image.py \
      ./build/tools/releasetools/build_image.py \
      $(TARGET_OUT_PRODUCT_SERVICES) $(product_servicesimage_intermediates)/product_services_image_info.txt $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(TARGET_OUT) \
      $(TARGET_OUT_PRODUCT_SERVICES) $(productservicesimage_intermediates)/productservices_image_info.txt $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(TARGET_OUT)
      $(product_servicesimage_intermediates)/generated_product_services_image_info.txt
  $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
  $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),\
      $(call read-image-prop-dictionary,\
          $(product_servicesimage_intermediates)/generated_product_services_image_info.txt,product_services_size))
endef
endef


# We just build this directly to the install location.
# We just build this directly to the install location.
@@ -2977,11 +2960,8 @@ define build-odmimage-target
    $(call build-image-kernel-modules,$(BOARD_ODM_KERNEL_MODULES),$(TARGET_OUT_ODM),odm/,$(call intermediates-dir-for,PACKAGING,depmod_odm)))
    $(call build-image-kernel-modules,$(BOARD_ODM_KERNEL_MODULES),$(TARGET_OUT_ODM),odm/,$(call intermediates-dir-for,PACKAGING,depmod_odm)))
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
      ./build/tools/releasetools/build_image.py \
      ./build/tools/releasetools/build_image.py \
      $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT) \
      $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
	  $(odmimage_intermediates)/generated_odm_image_info.txt
  $(hide) $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
  $(hide) $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),\
      $(call read-image-prop-dictionary,\
          $(odmimage_intermediates)/generated_odm_image_info.txt,odm_size))
endef
endef


# We just build this directly to the install location.
# We just build this directly to the install location.
@@ -3351,7 +3331,8 @@ ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
# (1): list of items like "system", "vendor", "product", "product_services"
# (1): list of items like "system", "vendor", "product", "product_services"
# return: map each item into a command ( wrapped in $$() ) that reads the size
# return: map each item into a command ( wrapped in $$() ) that reads the size
define read-size-of-partitions
define read-size-of-partitions
$(foreach p,$(1),$(call read-image-prop-dictionary,$($(p)image_intermediates)/generated_$(p)_image_info.txt,$(p)_size))
$(foreach image,$(call images-for-partitions,$(1)),$$( \
    build/make/tools/releasetools/sparse_img.py --get_partition_size $(image)))
endef
endef


# round result to BOARD_SUPER_PARTITION_ALIGNMENT
# round result to BOARD_SUPER_PARTITION_ALIGNMENT
@@ -3375,7 +3356,9 @@ droid_targets: check-all-partition-sizes
.PHONY: check-all-partition-sizes check-all-partition-sizes-nodeps
.PHONY: check-all-partition-sizes check-all-partition-sizes-nodeps


# Add image dependencies so that generated_*_image_info.txt are written before checking.
# Add image dependencies so that generated_*_image_info.txt are written before checking.
check-all-partition-sizes: $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))
check-all-partition-sizes: \
    build/make/tools/releasetools/sparse_img.py \
    $(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST))


ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
# Check sum(super partition block devices) == super partition
# Check sum(super partition block devices) == super partition
+2 −14
Original line number Original line Diff line number Diff line
@@ -18,10 +18,8 @@
Builds output_image from the given input_directory, properties_file,
Builds output_image from the given input_directory, properties_file,
and writes the image to target_output_directory.
and writes the image to target_output_directory.


If argument generated_prop_file exists, write additional properties to the file.

Usage:  build_image.py input_directory properties_file output_image \\
Usage:  build_image.py input_directory properties_file output_image \\
            target_output_directory [generated_prop_file]
            target_output_directory
"""
"""


from __future__ import print_function
from __future__ import print_function
@@ -735,13 +733,8 @@ def GlobalDictFromImageProp(image_prop, mount_point):
  return d
  return d




def SaveGlobalDict(filename, glob_dict):
  with open(filename, "w") as f:
    f.writelines(["%s=%s" % (key, value) for (key, value) in glob_dict.items()])


def main(argv):
def main(argv):
  if len(argv) < 4 or len(argv) > 5:
  if len(argv) != 4:
    print(__doc__)
    print(__doc__)
    sys.exit(1)
    sys.exit(1)


@@ -751,7 +744,6 @@ def main(argv):
  glob_dict_file = argv[1]
  glob_dict_file = argv[1]
  out_file = argv[2]
  out_file = argv[2]
  target_out = argv[3]
  target_out = argv[3]
  prop_file_out = argv[4] if len(argv) >= 5 else None


  glob_dict = LoadGlobalDict(glob_dict_file)
  glob_dict = LoadGlobalDict(glob_dict_file)
  if "mount_point" in glob_dict:
  if "mount_point" in glob_dict:
@@ -791,10 +783,6 @@ def main(argv):
    logger.error("Failed to build %s from %s", out_file, in_dir)
    logger.error("Failed to build %s from %s", out_file, in_dir)
    raise
    raise


  if prop_file_out:
    glob_dict_out = GlobalDictFromImageProp(image_properties, mount_point)
    SaveGlobalDict(prop_file_out, glob_dict_out)



if __name__ == '__main__':
if __name__ == '__main__':
  try:
  try: