forked from openkylin/platform_build
Merge "Allow building recovery as boot."
am: 781b7b20d4
* commit '781b7b20d41cfe80472707aec46d0eac5473bfc5':
Allow building recovery as boot.
This commit is contained in:
commit
c27ad030b6
|
@ -518,6 +518,15 @@ endif
|
|||
|
||||
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
|
||||
|
||||
# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true.
|
||||
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
|
||||
ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
|
||||
$(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.)
|
||||
endif
|
||||
endif
|
||||
|
||||
# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
|
||||
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,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # TARGET_BOOTIMAGE_USE_EXT2 != true
|
||||
|
@ -564,6 +573,7 @@ bootimage-nodeps: $(MKBOOTIMG)
|
|||
$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
|
||||
|
||||
endif # TARGET_BOOTIMAGE_USE_EXT2
|
||||
endif # BOARD_USES_RECOVERY_AS_BOOT
|
||||
|
||||
else # TARGET_NO_KERNEL
|
||||
# HACK: The top-level targets depend on the bootimage. Not all targets
|
||||
|
@ -782,6 +792,8 @@ $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_
|
|||
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
|
||||
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1))
|
||||
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
|
||||
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
|
||||
$(hide) echo "recovery_as_boot=true" >> $(1))
|
||||
$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
|
||||
$(hide) echo "system_root_image=true" >> $(1);\
|
||||
echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
|
||||
|
@ -791,7 +803,8 @@ endef
|
|||
# -----------------------------------------------------------------
|
||||
# Recovery image
|
||||
|
||||
ifdef INSTALLED_RECOVERYIMAGE_TARGET
|
||||
# Recovery image exists if we are building recovery, or building recovery as boot.
|
||||
ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
|
||||
|
||||
INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
|
||||
$(ALL_DEFAULT_INSTALLED_MODULES))
|
||||
|
@ -841,12 +854,22 @@ else
|
|||
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
# Prior to A/B update, we used to have:
|
||||
# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
|
||||
# recovery-resource.dat is needed only if we carry a patch of the boot and
|
||||
# recovery images and invoke install-recovery.sh on the first boot post an
|
||||
# OTA update.
|
||||
#
|
||||
# We no longer need that if one of the following conditions holds:
|
||||
# a) We carry a full copy of the recovery image
|
||||
# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
|
||||
# b) We build a single image that contains boot and recovery both
|
||||
# (BOARD_USES_RECOVERY_AS_BOOT = true).
|
||||
|
||||
ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT)))
|
||||
# Named '.dat' so we don't attempt to use imgdiff for patching it.
|
||||
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat
|
||||
else
|
||||
# We carry a full copy of the recovery image. recovery-resource.dat is no
|
||||
# longer needed.
|
||||
RECOVERY_RESOURCE_ZIP :=
|
||||
endif
|
||||
|
||||
|
@ -930,10 +953,25 @@ define build-recoveryimage-target
|
|||
$(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1))
|
||||
$(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
|
||||
$(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
|
||||
$(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
|
||||
$(if $(filter true,BOARD_USES_RECOVERY_AS_BOOT), \
|
||||
$(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
|
||||
$(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
|
||||
@echo ----- Made recovery image: $(1) --------
|
||||
endef
|
||||
|
||||
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
|
||||
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
||||
$(INSTALLED_RAMDISK_TARGET) \
|
||||
$(INTERNAL_RECOVERYIMAGE_FILES) \
|
||||
$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
|
||||
$(INSTALLED_2NDBOOTLOADER_TARGET) \
|
||||
$(recovery_build_prop) $(recovery_resource_deps) \
|
||||
$(recovery_fstab) \
|
||||
$(RECOVERY_INSTALL_OTA_KEYS)
|
||||
$(call pretty,"Target boot image from recovery: $@")
|
||||
$(call build-recoveryimage-target, $@)
|
||||
endif
|
||||
|
||||
$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
||||
$(INSTALLED_RAMDISK_TARGET) \
|
||||
$(INSTALLED_BOOTIMAGE_TARGET) \
|
||||
|
@ -945,7 +983,7 @@ $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
|||
$(RECOVERY_INSTALL_OTA_KEYS)
|
||||
$(call build-recoveryimage-target, $@)
|
||||
|
||||
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
|
||||
ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT)))
|
||||
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
|
||||
$(hide) mkdir -p $(dir $@)
|
||||
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
|
||||
|
@ -1483,6 +1521,13 @@ ifneq ($(AB_OTA_UPDATER),true)
|
|||
$(BUILT_TARGET_FILES_PACKAGE): $(built_ota_tools)
|
||||
endif
|
||||
|
||||
# If we are using recovery as boot, output recovery files to BOOT/.
|
||||
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
|
||||
$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT
|
||||
else
|
||||
$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
|
||||
endif
|
||||
|
||||
# Depending on the various images guarantees that the underlying
|
||||
# directories are up-to-date.
|
||||
$(BUILT_TARGET_FILES_PACKAGE): \
|
||||
|
@ -1501,28 +1546,28 @@ $(BUILT_TARGET_FILES_PACKAGE): \
|
|||
@echo "Package target files: $@"
|
||||
$(hide) rm -rf $@ $(zip_root)
|
||||
$(hide) mkdir -p $(dir $@) $(zip_root)
|
||||
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
||||
ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
|
||||
@# Components of the recovery image
|
||||
$(hide) mkdir -p $(zip_root)/RECOVERY
|
||||
$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
|
||||
$(hide) $(call package_files-copy-root, \
|
||||
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)
|
||||
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
|
||||
ifdef INSTALLED_KERNEL_TARGET
|
||||
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel
|
||||
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
|
||||
endif
|
||||
ifdef INSTALLED_2NDBOOTLOADER_TARGET
|
||||
$(hide) $(ACP) \
|
||||
$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second
|
||||
$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
|
||||
endif
|
||||
ifdef BOARD_KERNEL_CMDLINE
|
||||
$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline
|
||||
$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
|
||||
endif
|
||||
ifdef BOARD_KERNEL_BASE
|
||||
$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/RECOVERY/base
|
||||
$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
|
||||
endif
|
||||
ifdef BOARD_KERNEL_PAGESIZE
|
||||
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/RECOVERY/pagesize
|
||||
endif
|
||||
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
|
||||
endif
|
||||
endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
|
||||
@# Components of the boot image
|
||||
$(hide) mkdir -p $(zip_root)/BOOT
|
||||
ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
|
||||
|
@ -1533,6 +1578,8 @@ else
|
|||
$(hide) $(call package_files-copy-root, \
|
||||
$(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)
|
||||
endif
|
||||
@# If we are using recovery as boot, this is already done when processing recovery.
|
||||
ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
|
||||
ifdef INSTALLED_KERNEL_TARGET
|
||||
$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
|
||||
endif
|
||||
|
@ -1549,6 +1596,7 @@ endif
|
|||
ifdef BOARD_KERNEL_PAGESIZE
|
||||
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
|
||||
endif
|
||||
endif # BOARD_USES_RECOVERY_AS_BOOT
|
||||
$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
|
||||
mkdir -p $(zip_root)/RADIO; \
|
||||
$(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
|
||||
|
@ -1587,6 +1635,9 @@ endif
|
|||
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
|
||||
$(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
|
||||
endif
|
||||
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),)
|
||||
$(hide) echo "recovery_as_boot=$(BOARD_USES_RECOVERY_AS_BOOT)" >> $(zip_root)/META/misc_info.txt
|
||||
endif
|
||||
ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
||||
$(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt
|
||||
endif
|
||||
|
@ -1639,6 +1690,7 @@ ifeq ($(AB_OTA_UPDATER),true)
|
|||
done
|
||||
@# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
|
||||
$(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
|
||||
$(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
|
||||
ifdef OSRELEASED_DIRECTORY
|
||||
$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
|
||||
$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
|
||||
|
@ -1656,9 +1708,8 @@ endif
|
|||
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
|
||||
ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
|
||||
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="ROOT/" } /^ROOT\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/root_filesystem_config.txt
|
||||
else
|
||||
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
|
||||
endif
|
||||
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
|
||||
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
|
||||
$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
|
||||
endif
|
||||
|
|
|
@ -494,8 +494,11 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir,
|
|||
info_dict = OPTIONS.info_dict
|
||||
|
||||
# With system_root_image == "true", we don't pack ramdisk into the boot image.
|
||||
has_ramdisk = (info_dict.get("system_root_image", None) != "true" or
|
||||
prebuilt_name != "boot.img")
|
||||
# Unless "recovery_as_boot" is specified, in which case we carry the ramdisk
|
||||
# for recovery.
|
||||
has_ramdisk = (info_dict.get("system_root_image") != "true" or
|
||||
prebuilt_name != "boot.img" or
|
||||
info_dict.get("recovery_as_boot") == "true")
|
||||
|
||||
fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
|
||||
data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir),
|
||||
|
|
|
@ -1703,7 +1703,9 @@ def main(argv):
|
|||
if OPTIONS.device_specific is not None:
|
||||
OPTIONS.device_specific = os.path.abspath(OPTIONS.device_specific)
|
||||
|
||||
if OPTIONS.info_dict.get("no_recovery") == "true":
|
||||
ab_update = OPTIONS.info_dict.get("ab_update") == "true"
|
||||
|
||||
if OPTIONS.info_dict.get("no_recovery") == "true" and not ab_update:
|
||||
raise common.ExternalError(
|
||||
"--- target build has specified no recovery ---")
|
||||
|
||||
|
@ -1725,8 +1727,9 @@ def main(argv):
|
|||
output_zip = zipfile.ZipFile(temp_zip_file, "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
# Non A/B OTAs rely on /cache partition to store temporary files.
|
||||
cache_size = OPTIONS.info_dict.get("cache_size", None)
|
||||
if cache_size is None:
|
||||
if cache_size is None and not ab_update:
|
||||
print "--- can't determine the cache partition size ---"
|
||||
OPTIONS.cache_size = cache_size
|
||||
|
||||
|
@ -1736,7 +1739,11 @@ def main(argv):
|
|||
|
||||
# Generate a full OTA.
|
||||
elif OPTIONS.incremental_source is None:
|
||||
WriteFullOTAPackage(input_zip, output_zip)
|
||||
if ab_update:
|
||||
# TODO: Pending for b/25715402.
|
||||
pass
|
||||
else:
|
||||
WriteFullOTAPackage(input_zip, output_zip)
|
||||
|
||||
# Generate an incremental OTA. It will fall back to generate a full OTA on
|
||||
# failure unless no_fallback_to_full is specified.
|
||||
|
|
Loading…
Reference in New Issue