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

Commit f362e3eb authored by Kelvin Zhang's avatar Kelvin Zhang Committed by Automerger Merge Worker
Browse files

Merge "Move non-AB OTA generation code to a separate file" am: 2f657188 am: 0164370f

Original change: https://android-review.googlesource.com/c/platform/build/+/1378776

Change-Id: Id00fb7101345f504a3583849013a6ca492bb14b4
parents 138b2d0d 0164370f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -93,7 +93,9 @@ python_defaults {
    srcs: [
        "edify_generator.py",
        "ota_from_target_files.py",
        "non_ab_ota.py",
        "target_files_diff.py",
        "ota_utils.py",
    ],
    libs: [
        "releasetools_check_target_files_vintf",
+46 −0
Original line number Diff line number Diff line
@@ -220,6 +220,52 @@ def CheckVintf(inp, info_dict=None):

  raise ValueError('{} is not a valid directory or zip file'.format(inp))

def CheckVintfIfTrebleEnabled(target_files, target_info):
  """Checks compatibility info of the input target files.

  Metadata used for compatibility verification is retrieved from target_zip.

  Compatibility should only be checked for devices that have enabled
  Treble support.

  Args:
    target_files: Path to zip file containing the source files to be included
        for OTA. Can also be the path to extracted directory.
    target_info: The BuildInfo instance that holds the target build info.
  """

  # Will only proceed if the target has enabled the Treble support (as well as
  # having a /vendor partition).
  if not HasTrebleEnabled(target_files, target_info):
    return

  # Skip adding the compatibility package as a workaround for b/114240221. The
  # compatibility will always fail on devices without qualified kernels.
  if OPTIONS.skip_compatibility_check:
    return

  if not CheckVintf(target_files, target_info):
    raise RuntimeError("VINTF compatibility check failed")

def HasTrebleEnabled(target_files, target_info):
  def HasVendorPartition(target_files):
    if os.path.isdir(target_files):
      return os.path.isdir(os.path.join(target_files, "VENDOR"))
    if zipfile.is_zipfile(target_files):
      return HasPartition(zipfile.ZipFile(target_files), "vendor")
    raise ValueError("Unknown target_files argument")

  return (HasVendorPartition(target_files) and
          target_info.GetBuildProp("ro.treble.enabled") == "true")


def HasPartition(target_files_zip, partition):
  try:
    target_files_zip.getinfo(partition.upper() + "/")
    return True
  except KeyError:
    return False


def main(argv):
  args = common.ParseOptions(argv, __doc__)
Loading