From babdafe97eb7dd7229c6b27f722066fd5a9721a9 Mon Sep 17 00:00:00 2001 From: David Iserovich Date: Thu, 10 Aug 2023 17:58:31 +0000 Subject: [PATCH] [config] Dist supports custom super image script Some boards need to supply a custom super image script, and this is supported via the BOARD_CUSTOM_BUILD_SUPER_IMAGE variable. However, this variable is not used by img_from_target_files.py. Change img_from_target_files.py to call the supplied script. Bug: None Change-Id: I6bca937534f58459d3419139ee7a37a10138ab8f --- core/Makefile | 1 + tools/releasetools/img_from_target_files.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 07d705e8d7..6f40063c9a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -7118,6 +7118,7 @@ $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARG PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \ $(IMG_FROM_TARGET_FILES) \ --additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \ + --build_super_image $(BUILD_SUPER_IMAGE) \ $(BUILT_TARGET_FILES_PACKAGE) $@ $(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),) diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py index fa53ad2fa7..5412b2a488 100755 --- a/tools/releasetools/img_from_target_files.py +++ b/tools/releasetools/img_from_target_files.py @@ -65,6 +65,7 @@ OPTIONS.retrofit_dap = None OPTIONS.build_super = None OPTIONS.sparse_userimages = None OPTIONS.use_fastboot_info = False +OPTIONS.build_super_image = None def LoadOptions(input_file): """Loads information from input_file to OPTIONS. @@ -174,7 +175,13 @@ def RebuildAndWriteSuperImages(input_file, output_file): input_tmp = common.UnzipTemp(input_file) super_file = common.MakeTempFile('super_', '.img') - BuildSuperImage(input_tmp, super_file) + + # Allow overriding the BUILD_SUPER_IMAGE binary + if OPTIONS.build_super_image: + command = [OPTIONS.build_super_image, input_tmp, super_file] + common.RunAndCheckOutput(command) + else: + BuildSuperImage(input_tmp, super_file) logger.info('Writing super.img to archive...') with zipfile.ZipFile( @@ -231,6 +238,8 @@ def main(argv): OPTIONS.bootable_only = True elif o == '--additional': OPTIONS.additional_entries.append(a) + elif o == '--build_super_image': + OPTIONS.build_super_image = a else: return False return True @@ -240,6 +249,7 @@ def main(argv): extra_long_opts=[ 'additional=', 'bootable_zip', + 'build_super_image=', ], extra_option_handler=option_handler) if len(args) != 2: