diff --git a/core/Makefile b/core/Makefile index b2e936e090af79f1b39e4049d417ff32834e7cd8..ad42b51436c6588ff4119e362c365df635afb60a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -4180,6 +4180,9 @@ endif # BOARD_PREBUILT_DTBOIMAGE @# INSTALLED_RADIOIMAGE_TARGET. $(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \ echo $(part) >> $(zip_root)/META/pack_radioimages.txt;) + @# Any images specified will be added into ota.zip + $(hide) $(foreach part,$(BOARD_PACK_IMAGES), \ + echo $(part) >> $(zip_root)/META/pack_images.txt;) @# Run fs_config on all the system, vendor, boot ramdisk, @# and recovery ramdisk files in the zip, and save the output ifdef BUILDING_SYSTEM_IMAGE diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 5e1cbba39d5c0d93051165400e4448cb10a620d2..e78ed3ee44fc616d7c356d456a1b1b5ddc215ba7 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -920,6 +920,30 @@ def AddImagesToTargetFiles(filename): if os.path.exists(pack_radioimages_txt): with open(pack_radioimages_txt) as f: AddPackRadioImages(output_zip, f.readlines()) + # images that need to be packed into IMAGES/, and product-img.zip. + pack_images = os.path.join( + OPTIONS.input_tmp, "META", "pack_images.txt") + if os.path.exists(pack_images): + banner("images") + with open(pack_images, 'r') as f: + lines = f.readlines() + for line in lines: + img_inf = line.strip().split(":") + img_path = img_inf[0].strip() + print("img_path" +img_path) + img_name = os.path.basename(img_path) + _, ext = os.path.splitext(img_name) + if not ext: + img_name += ".img" + prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name) + if os.path.exists(prebuilt_path): + print("%s already exists, no need to overwrite..." % (img_name,)) + continue + if output_zip: + common.ZipWrite(output_zip, prebuilt_path, + os.path.join("IMAGES", img_name)) + else: + shutil.copy(img_path, prebuilt_path) if output_zip: common.ZipClose(output_zip) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index b9176cba2ffe0501df8feddc988531b0459a953f..8c0b7151cf24cfe01dc57d8b099dab94c643f0fd 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -715,6 +715,15 @@ def _WriteRecoveryImageToBoot(script, output_zip): # The "recovery.img" entry has been written into package earlier. script.WriteRawImage("/boot", "recovery.img") +def WriteImage(image, dest, script, output_zip): + img_path = os.path.join( + OPTIONS.input_tmp, "IMAGES", image) + common.ZipWrite( + output_zip, img_path, image) + logger.info( + "adding image: using %s", image) + script.WriteRawImage("/"+dest, image) + def HasRecoveryPatch(target_files_zip): namelist = [name for name in target_files_zip.namelist()] @@ -1112,6 +1121,17 @@ else if get_stage("%(bcb_dev)s") == "3/3" then if boot_img != None: script.WriteRawImage("/boot", "boot.img") + pack_images = os.path.join(OPTIONS.input_tmp, "META", "pack_images.txt") + if os.path.exists(pack_images): + with open(pack_images, 'r') as f: + lines = f.readlines() + for line in lines: + print(line) + img_inf = line.strip().split(":") + + WriteImage(os.path.basename(img_inf[0]), img_inf[1], script, output_zip) + + script.ShowProgress(0.1, 10) device_specific.FullOTA_InstallEnd()