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

Commit 246a5c06 authored by Iavor-Valentin Iftime's avatar Iavor-Valentin Iftime
Browse files

Rebuild and copy recovery patch files when using vendor_otatools

  Rebuild recovery and copy recovery patch/install files when building vendor images using vendor otatools. Fixes ota_from_target_files failure.

Bug: 220126689
Bug: 186097910

Test: sign_target_files_apks \
        --vendor_otatools=otatools_vendor_dir \
	--vendor_partitions=vendor,odm \
	merged-target_files.zip \
	signed-target_files.zip

Change-Id: I4a415417e0d7b1bcd548292ec8f3a12570ec65f0
parent 8842016b
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -1278,6 +1278,9 @@ def BuildVendorPartitions(output_zip_path):
  vendor_tempdir = common.UnzipTemp(output_zip_path, [
      "META/*",
      "SYSTEM/build.prop",
      "RECOVERY/*",
      "BOOT/*",
      "OTA/",
  ] + ["{}/*".format(p.upper()) for p in OPTIONS.vendor_partitions])

  # Disable various partitions that build based on misc_info fields.
@@ -1286,9 +1289,12 @@ def BuildVendorPartitions(output_zip_path):
  # otatools if necessary.
  vendor_misc_info_path = os.path.join(vendor_tempdir, "META/misc_info.txt")
  vendor_misc_info = common.LoadDictionaryFromFile(vendor_misc_info_path)
  # Ignore if not rebuilding recovery
  if not OPTIONS.rebuild_recovery:
    vendor_misc_info["no_boot"] = "true"  # boot
    vendor_misc_info["vendor_boot"] = "false"  # vendor_boot
    vendor_misc_info["no_recovery"] = "true"  # recovery

  vendor_misc_info["board_bpt_enable"] = "false"  # partition-table
  vendor_misc_info["has_dtbo"] = "false"  # dtbo
  vendor_misc_info["has_pvmfw"] = "false"  # pvmfw
@@ -1334,6 +1340,9 @@ def BuildVendorPartitions(output_zip_path):
      "--verbose",
      vendor_tempdir,
  ]
  if OPTIONS.rebuild_recovery:
    cmd.insert(4, "--rebuild_recovery")

  common.RunAndCheckOutput(cmd, verbose=True)

  logger.info("Writing vendor partitions to output archive.")
@@ -1345,6 +1354,12 @@ def BuildVendorPartitions(output_zip_path):
      map_file_path = "IMAGES/{}.map".format(p)
      common.ZipWrite(output_zip, os.path.join(vendor_tempdir, img_file_path), img_file_path)
      common.ZipWrite(output_zip, os.path.join(vendor_tempdir, map_file_path), map_file_path)
    # copy recovery patch & install.sh
    if OPTIONS.rebuild_recovery:
      recovery_patch_path = "VENDOR/recovery-from-boot.p"
      recovery_sh_path = "VENDOR/bin/install-recovery.sh"
      common.ZipWrite(output_zip, os.path.join(vendor_tempdir, recovery_patch_path), recovery_patch_path)
      common.ZipWrite(output_zip, os.path.join(vendor_tempdir, recovery_sh_path), recovery_sh_path)


def main(argv):