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

Commit 5553b570 authored by Andrew Scull's avatar Andrew Scull Committed by Gerrit Code Review
Browse files

Merge "Add pvmfw partition to target files"

parents 0a4788c3 e077cf76
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -350,6 +350,41 @@ def AddDtbo(output_zip):
  img.Write()
  return img.name

def AddPvmfw(output_zip):
  """Adds the pvmfw image.

  Uses the image under IMAGES/ if it already exists. Otherwise looks for the
  image under PREBUILT_IMAGES/, signs it as needed, and returns the image name.
  """
  img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "pvmfw.img")
  if os.path.exists(img.name):
    logger.info("pvmfw.img already exists; no need to rebuild...")
    return img.name

  pvmfw_prebuilt_path = os.path.join(
      OPTIONS.input_tmp, "PREBUILT_IMAGES", "pvmfw.img")
  assert os.path.exists(pvmfw_prebuilt_path)
  shutil.copy(pvmfw_prebuilt_path, img.name)

  # AVB-sign the image as needed.
  if OPTIONS.info_dict.get("avb_enable") == "true":
    # Signing requires +w
    os.chmod(img.name, os.stat(img.name).st_mode | stat.S_IWUSR)

    avbtool = OPTIONS.info_dict["avb_avbtool"]
    part_size = OPTIONS.info_dict["pvmfw_size"]
    # The AVB hash footer will be replaced if already present.
    cmd = [avbtool, "add_hash_footer", "--image", img.name,
           "--partition_size", str(part_size), "--partition_name", "pvmfw"]
    common.AppendAVBSigningArgs(cmd, "pvmfw")
    args = OPTIONS.info_dict.get("avb_pvmfw_add_hash_footer_args")
    if args and args.strip():
      cmd.extend(shlex.split(args))
    common.RunAndCheckOutput(cmd)

  img.Write()
  return img.name

def AddCustomImages(output_zip, partition_name):
  """Adds and signs custom images in IMAGES/.

@@ -948,6 +983,10 @@ def AddImagesToTargetFiles(filename):
    banner("dtbo")
    partitions['dtbo'] = AddDtbo(output_zip)

  if OPTIONS.info_dict.get("has_pvmfw") == "true":
    banner("pvmfw")
    partitions['pvmfw'] = AddPvmfw(output_zip)

  # Custom images.
  custom_partitions = OPTIONS.info_dict.get(
      "avb_custom_images_partition_list", "").strip().split()
+3 −3
Original line number Diff line number Diff line
@@ -110,9 +110,9 @@ SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL")
# The partitions allowed to be signed by AVB (Android Verified Boot 2.0). Note
# that system_other is not in the list because we don't want to include its
# descriptor into vbmeta.img.
AVB_PARTITIONS = ('boot', 'dtbo', 'odm', 'product', 'recovery', 'system',
                  'system_ext', 'vendor', 'vendor_boot', 'vendor_dlkm',
                  'odm_dlkm')
AVB_PARTITIONS = ('boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery',
                  'system', 'system_ext', 'vendor', 'vendor_boot',
                  'vendor_dlkm', 'odm_dlkm')

# Chained VBMeta partitions.
AVB_VBMETA_PARTITIONS = ('vbmeta_system', 'vbmeta_vendor')