From 76c3b8c8c0b7858f4b224f26e871e16de261f6c3 Mon Sep 17 00:00:00 2001 From: Phie Date: Thu, 12 Nov 2020 13:49:19 +0100 Subject: [PATCH 1/3] adding TARGET_NO_BOOTIMAGE option to be able to avoid adding a boot image --- core/Makefile | 3 +++ tools/releasetools/add_img_to_target_files.py | 22 +++++++++++-------- tools/releasetools/common.py | 3 ++- tools/releasetools/ota_from_target_files.py | 13 ++++++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/core/Makefile b/core/Makefile index e2e9ba3aea..bc639472b6 100644 --- a/core/Makefile +++ b/core/Makefile @@ -3980,6 +3980,9 @@ endif $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt +ifeq (true,$(filter true, $(TARGET_NO_BOOTIMAGE))) + $(hide) echo "no_boot=true" >> $(zip_root)/META/misc_info.txt +endif ifdef BOARD_FLASH_BLOCK_SIZE $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt endif diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 96b7f0b04d..5e1cbba39d 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -733,6 +733,8 @@ def AddImagesToTargetFiles(filename): has_recovery = OPTIONS.info_dict.get("no_recovery") != "true" + has_boot = OPTIONS.info_dict.get("no_boot") != "true" + # {vendor,odm,product,product_services}.img are unlike system.img or # system_other.img. Because it could be built from source, or dropped into # target_files.zip as a prebuilt blob. We consider either of them as @@ -781,15 +783,17 @@ def AddImagesToTargetFiles(filename): banner("boot") # common.GetBootableImage() returns the image directly if present. - boot_image = common.GetBootableImage( - "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") - # boot.img may be unavailable in some targets (e.g. aosp_arm64). - if boot_image: - partitions['boot'] = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") - if not os.path.exists(partitions['boot']): - boot_image.WriteToDir(OPTIONS.input_tmp) - if output_zip: - boot_image.AddToZip(output_zip) + boot_image = None + if(has_boot): + boot_image = common.GetBootableImage( + "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") + # boot.img may be unavailable in some targets (e.g. aosp_arm64). + if boot_image: + partitions['boot'] = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") + if not os.path.exists(partitions['boot']): + boot_image.WriteToDir(OPTIONS.input_tmp) + if output_zip: + boot_image.AddToZip(output_zip) recovery_image = None if has_recovery: diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index b2afaf1535..7a72a8df48 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -779,7 +779,8 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, if info_dict is None: info_dict = OPTIONS.info_dict - + if info_dict["no_boot"] == "true" and prebuilt_name == "boot.img": + return None # With system_root_image == "true", we don't pack ramdisk into the boot image. # Unless "recovery_as_boot" is specified, in which case we carry the ramdisk # for recovery. diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 0cff60f1a1..4c275d769b 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -992,8 +992,8 @@ def WriteFullOTAPackage(input_zip, output_file): input_tmp=OPTIONS.input_tmp, metadata=metadata, info_dict=OPTIONS.info_dict) - - assert HasRecoveryPatch(input_zip) + if target_info["no_boot"] != "true" + assert HasRecoveryPatch(input_zip) # Assertions (e.g. downgrade check, device properties check). #ts = target_info.GetBuildProp("ro.build.date.utc") @@ -1100,16 +1100,17 @@ else if get_stage("%(bcb_dev)s") == "3/3" then boot_img = common.GetBootableImage( "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") - common.CheckSize(boot_img.data, "boot.img", target_info) - common.ZipWriteStr(output_zip, "boot.img", boot_img.data) + if boot_img != None: + common.CheckSize(boot_img.data, "boot.img", target_info) + common.ZipWriteStr(output_zip, "boot.img", boot_img.data) device_specific.FullOTA_PostValidate() if OPTIONS.backuptool: script.ShowProgress(0.02, 10) script.RunBackup("restore", sysmount, target_info.get('use_dynamic_partitions') == "true") - - script.WriteRawImage("/boot", "boot.img") + if boot_img != None: + script.WriteRawImage("/boot", "boot.img") script.ShowProgress(0.1, 10) device_specific.FullOTA_InstallEnd() -- GitLab From 39ac39e2de51a968ce8eec8b6263dae71227a969 Mon Sep 17 00:00:00 2001 From: Alexandre Roux D'Anzi Date: Thu, 12 Nov 2020 15:07:42 +0100 Subject: [PATCH 2/3] adding no_boot=false when boot image is needed --- core/Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/Makefile b/core/Makefile index bc639472b6..3fee8da580 100644 --- a/core/Makefile +++ b/core/Makefile @@ -3980,9 +3980,7 @@ endif $(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt -ifeq (true,$(filter true, $(TARGET_NO_BOOTIMAGE))) - $(hide) echo "no_boot=true" >> $(zip_root)/META/misc_info.txt -endif + ifdef BOARD_FLASH_BLOCK_SIZE $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt endif @@ -3992,6 +3990,12 @@ endif ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),) $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt endif +ifeq ($(TARGET_NO_BOOTIMAGE),true) + $(hide) echo "no_boot=true" >> $(zip_root)/META/misc_info.txt +else + $(hide) echo "no_boot=false" >> $(zip_root)/META/misc_info.txt +endif + ifdef BOARD_INCLUDE_RECOVERY_DTBO $(hide) echo "include_recovery_dtbo=true" >> $(zip_root)/META/misc_info.txt endif -- GitLab From 94b87c428f6ad4cf34d6b3bb9c2e98d3dc96b11e Mon Sep 17 00:00:00 2001 From: Alexandre Roux D'Anzi Date: Thu, 12 Nov 2020 15:38:31 +0100 Subject: [PATCH 3/3] fix python error --- tools/releasetools/ota_from_target_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 4c275d769b..b9176cba2f 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -992,7 +992,7 @@ def WriteFullOTAPackage(input_zip, output_file): input_tmp=OPTIONS.input_tmp, metadata=metadata, info_dict=OPTIONS.info_dict) - if target_info["no_boot"] != "true" + if target_info["no_boot"] != "true": assert HasRecoveryPatch(input_zip) # Assertions (e.g. downgrade check, device properties check). -- GitLab