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

Commit cd9e2fcf authored by Christian Oder's avatar Christian Oder Committed by Nolen Johnson
Browse files

build: Allow building disabled vbmeta images in signing process

If we sign builds out of tree there's no way to create a disabled vbmeta.img

Tests: Set
BOARD_AVB_ENABLE := false
BOARD_BUILD_DISABLED_VBMETAIMAGE := true
for taimen and follow https://source.android.com/devices/tech/ota/sign_builds
Result: signing will no longer fail due to missing vbmeta.img

Change-Id: If93182d0339d5fbc310373059716a56114d68d89
parent 9b627eb4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2600,6 +2600,9 @@ ifdef BOARD_AVB_BOOT_KEY_PATH
	$(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $(zip_root)/META/misc_info.txt
endif # BOARD_AVB_BOOT_KEY_PATH
endif # BOARD_AVB_ENABLE
ifeq ($(BOARD_BUILD_DISABLED_VBMETAIMAGE),true)
	$(hide) echo "avb_disabled_vbmeta=true" >> $(zip_root)/META/misc_info.txt
endif # BOARD_BUILD_DISABLED_VBMETAIMAGE
ifdef BOARD_BPT_INPUT_FILES
	$(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
+21 −0
Original line number Diff line number Diff line
@@ -418,6 +418,23 @@ def AddVBMeta(output_zip, boot_img_path, system_img_path, vendor_img_path,
  assert p.returncode == 0, "avbtool make_vbmeta_image failed"
  img.Write()

def AddDisabledVBMeta(output_zip):
  """Creates a disabled VBMeta image and store it in output_zip.

  Args:
    output_zip: The output zip file, which needs to be already open.
  """
  img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "vbmeta.img")
  if os.path.exists(img.input_name):
    print("vbmeta.img already exists; not rebuilding...")
    return img.input_name
  avbtool = os.getenv('AVBTOOL') or OPTIONS.info_dict["avb_avbtool"]
  cmd = [avbtool, "make_vbmeta_image", "--flag", "2", "--padding_size", "4096", "--output", img.name]

  p = common.Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  p.communicate()
  assert p.returncode == 0, "avbtool make_vbmeta_image failed"
  img.Write()

def AddPartitionTable(output_zip, prefix="IMAGES/"):
  """Create a partition table image and store it in output_zip."""
@@ -640,6 +657,10 @@ def AddImagesToTargetFiles(filename):
    AddVBMeta(output_zip, boot_contents.name, system_img_path,
              vendor_img_path, dtbo_img_path)

  if OPTIONS.info_dict.get("avb_disabled_vbmeta") == "true":
    banner("vbmeta")
    AddDisabledVBMeta(output_zip)

  # For devices using A/B update, copy over images from RADIO/ and/or
  # VENDOR_IMAGES/ to IMAGES/ and make sure we have all the needed
  # images ready under IMAGES/. All images should have '.img' as extension.
+1 −0
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
      "verity_signer_cmd",
      "verity_fec",
      "avb_enable",
      "avb_disabled_vbmeta",
      "avb_avbtool",
      "avb_salt",
  )