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

Commit 8d8ae41b authored by Alexandre Roux's avatar Alexandre Roux
Browse files

build option to pack prebuilt boot.img

parent 141f3cb0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -4160,6 +4160,14 @@ endif # BOARD_PREBUILT_DTBOIMAGE
	@# INSTALLED_RADIOIMAGE_TARGET.
	$(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
	    echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)



	@# The boot image in BOARD_PACK_BOOTIMAGE will be additionally copied from RADIO/ into
	@# IMAGES/, which then will be added into <product>-img.zip.
	$(hide) $(foreach part,$(BOARD_PACK_BOOTIMAGE), \
	    echo $(part) >> $(zip_root)/META/pack_bootimage.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
+33 −10
Original line number Diff line number Diff line
@@ -781,8 +781,15 @@ def AddImagesToTargetFiles(filename):

  banner("boot")
  # common.GetBootableImage() returns the image directly if present.
  pack_bootimage_txt = os.path.join(
      OPTIONS.input_tmp, "META", "pack_bootimage.txt")
  if os.path.exists(pack_bootimage_txt):
    with open(pack_bootimage_txt) as f:
      AddPackBootImage(output_zip, f.readlines())
  else:
    boot_image = common.GetBootableImage(
        "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
    print("OPTIONS.input_tmp "+OPTIONS.input_tmp)
    # 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")
@@ -790,7 +797,6 @@ def AddImagesToTargetFiles(filename):
        boot_image.WriteToDir(OPTIONS.input_tmp)
        if output_zip:
          boot_image.AddToZip(output_zip)

  recovery_image = None
  if has_recovery:
    banner("recovery")
@@ -924,6 +930,23 @@ def AddImagesToTargetFiles(filename):
                          OPTIONS.replace_updated_files_list)


def AddPackBootImage(output_zip, images):
  image = images[0]
  img_name = image.strip()
  _, ext = os.path.splitext(img_name)
  if not ext:
    img_name += ".img"
  img_boot_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img")
  shutil.copy(img_name, img_boot_path)
  prebuilt_path = os.path.join(OPTIONS.input_tmp, "BOOT", "boot.img")
  assert os.path.exists(img_boot_path), \
      "Failed to find %s at %s" % (img_name, img_boot_path)
  if output_zip:
    common.ZipWrite(output_zip, img_boot_path, "IMAGES/" + img_name)
  else:
    shutil.copy(img_boot_path, prebuilt_path)


def main(argv):
  def option_handler(o, a):
    if o in ("-a", "--add_missing"):