Skip to content

Commit

Permalink
Add BOARD_CUSTOM_BOOTIMG_MK support
Browse files Browse the repository at this point in the history
This is a combination of 2 commits.
This is the 1st commit message:

    Add BOARD_CUSTOM_BOOTIMG_MK support

    Simplified version of the previous implementation. Recovery's ramdisk
    is spun off from the main recovery target again to allow overriding
    just the image-generation step

    [mikeioannina]: Squash cm-13.0 changes and adapt to N

    Change-Id: I058d214f0cf2d05b7621b369ef1f8a983c3ac258

This is the commit message #2:

    build: Handle custom boot images properly

    When a pre-built image should be used, it should be stored in the
    target files zip so that it can be used with external signing
    processes.

    Original-Change-Id: I2661af9ac58af30bb9314b552775046d3abf44e0
    Change-Id: I10b3bd0bb33489b8ffb26d16d002f8dd6ff405ad

Change-Id: I058d214f0cf2d05b7621b369ef1f8a983c3ac258
  • Loading branch information
rmcc authored and mikeNG committed Dec 11, 2019
1 parent 9564ae3 commit bec5553
Showing 1 changed file with 41 additions and 8 deletions.
49 changes: 41 additions & 8 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)

else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
else ifndef BOARD_CUSTOM_BOOTIMG_MK
ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true

$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
$(call pretty,"Target boot image: $@")
Expand Down Expand Up @@ -1002,7 +1003,8 @@ bootimage-nodeps: $(MKBOOTIMG)
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))

endif # TARGET_BOOTIMAGE_USE_EXT2
endif # PRODUCT_SUPPORTS_VBOOT
endif # TARGET_BOOTIMAGE_USE_EXT2 / BOARD_CUSTOM_BOOTIMG_MK
endif # BOARD_USES_RECOVERY_AS_BOOT

else # TARGET_NO_KERNEL == "true"
Expand Down Expand Up @@ -1554,6 +1556,7 @@ IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(r

recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
recovery_uncompressed_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.cpio
recovery_resources_common := $(call include-path-for, recovery)/res

# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
Expand Down Expand Up @@ -1826,9 +1829,7 @@ $(RECOVERY_INSTALL_OTA_KEYS): $(SOONG_ZIP) $(OTA_PUBLIC_KEYS) $(extra_keys)

RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id

# $(1): output file
define build-recoveryimage-target
# Making recovery image
define build-recoveryramdisk
$(hide) mkdir -p $(TARGET_RECOVERY_OUT)
$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
# Copying baseline ramdisk...
Expand Down Expand Up @@ -1859,7 +1860,11 @@ define build-recoveryimage-target
$(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/security/otacerts.zip
$(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
$(BOARD_RECOVERY_IMAGE_PREPARE)
$(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
endef

RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
# $(1): output file
define build-recoveryimage-target
$(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
$(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
$(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1) --id > $(RECOVERYIMAGE_ID_FILE))
Expand Down Expand Up @@ -1917,6 +1922,8 @@ $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
$(BOARD_RECOVERY_KERNEL_MODULES) \
$(DEPMOD)
$(call pretty,"Target boot image from recovery: $@")
$(call build-recoveryramdisk)
$(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
$(call build-recoveryimage-target, $@)
endif # BOARD_USES_RECOVERY_AS_BOOT

Expand All @@ -1934,20 +1941,33 @@ ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
$(INSTALLED_RECOVERYIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
endif

$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
$(recovery_uncompressed_ramdisk): $(MKBOOTFS) $(ADBD) \
$(INTERNAL_ROOT_FILES) \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
$(recovery_initrc) $(recovery_sepolicy) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
$(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
$(recovery_resource_deps) \
$(recovery_fstab) \
$(RECOVERY_INSTALL_OTA_KEYS) \
$(BOARD_RECOVERY_KERNEL_MODULES) \
$(DEPMOD)
$(call build-recoveryramdisk)
@echo ----- Making uncompressed recovery ramdisk ------
$(hide) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) > $@

$(recovery_ramdisk): $(MINIGZIP) \
$(recovery_uncompressed_ramdisk)
@echo ----- Making compressed recovery ramdisk ------
$(hide) $(MINIGZIP) < $(recovery_uncompressed_ramdisk) > $@

ifndef BOARD_CUSTOM_BOOTIMG_MK
$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
@echo ----- Making recovery image ------
$(call build-recoveryimage-target, $@)
endif # BOARD_CUSTOM_BOOTIMG_MK

ifdef RECOVERY_RESOURCE_ZIP
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
Expand All @@ -1959,6 +1979,8 @@ endif
.PHONY: recoveryimage-nodeps
recoveryimage-nodeps:
@echo "make $@: ignoring dependencies"
$(call build-recoveryramdisk)
$(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))

else # INSTALLED_RECOVERYIMAGE_TARGET not defined
Expand All @@ -1976,6 +1998,11 @@ ifneq ($(BOARD_NAND_SPARE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
endif

ifdef BOARD_CUSTOM_BOOTIMG_MK
include $(BOARD_CUSTOM_BOOTIMG_MK)
endif


# -----------------------------------------------------------------
# the debug ramdisk, which is the original ramdisk plus additional
# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
Expand Down Expand Up @@ -3810,6 +3837,12 @@ endif # BOARD_USES_RECOVERY_AS_BOOT
$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
mkdir -p $(zip_root)/RADIO; \
cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
ifdef BOARD_CUSTOM_BOOTIMG
@# Prebuilt boot images
$(hide) mkdir -p $(zip_root)/BOOTABLE_IMAGES
$(hide) $(ACP) $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
$(hide) $(ACP) $(INSTALLED_RECOVERYIMAGE_TARGET) $(zip_root)/BOOTABLE_IMAGES/
endif
ifdef BUILDING_SYSTEM_IMAGE
@# Contents of the system image
$(hide) $(call package_files-copy-root, \
Expand Down

0 comments on commit bec5553

Please sign in to comment.