Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09498488 authored by Alexandre Roux's avatar Alexandre Roux
Browse files

new option to flash any raw image from ota zip :

BOARD_PACK_IMAGES := image:target
for example
BOARD_PACK_IMAGES := recovery.img:recovery
parent 63d65e4c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+24 −0
Original line number Diff line number Diff line
@@ -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)
+20 −0
Original line number Diff line number Diff line
@@ -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()