Add the option to reserve headroom for partition
images. This is useful for device with low disk
space with different build variants.
This is a manual cherry-pick from aosp/master.
Bug: 37469715
Test: regular image builds successfully, errors occur
when the headroom size is greater than available
partition space.
Merged-In: I526cdd0f84981bbd16e3afcfe1cd7fc43dce98ef
Change-Id: I840d212bb46612074c43b39e94546901f60e4b4c
diff --git a/core/Makefile b/core/Makefile
index b6a704a..e346dff 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -961,6 +961,7 @@
$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1))
$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1))
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM)" >> $(1))
$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
diff --git a/core/product.mk b/core/product.mk
index 1e5a30e..7742cc3 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -131,6 +131,7 @@
VENDOR_EXCEPTION_PATHS \
PRODUCT_ART_USE_READ_BARRIER \
PRODUCT_IOT \
+ PRODUCT_SYSTEM_HEADROOM \
diff --git a/core/product_config.mk b/core/product_config.mk
index 57b7669..e069ff1 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -429,3 +429,7 @@
# Package list to apply enforcing RRO.
PRODUCT_ENFORCE_RRO_TARGETS := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_RRO_TARGETS))
+
+# Add reserved headroom to a system image.
+PRODUCT_SYSTEM_HEADROOM := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM))