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

Commit 402213cd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "mtf: Use vendor otatools for checking rc-files on vendor and odm" into main

parents 04e08480 19ffcb2b
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -1410,7 +1410,22 @@ def SharedUidPartitionViolations(uid_dict, partition_groups):
  return errors


def RunHostInitVerifier(product_out, partition_map):
def RunVendoredHostInitVerifier(product_out, partition_map):
  """Runs vendor host_init_verifier on the init rc files within selected partitions.

  host_init_verifier searches the etc/init path within each selected partition.

  Args:
    product_out: PRODUCT_OUT directory, containing partition directories.
    partition_map: A map of partition name -> relative path within product_out.
  """
  return RunHostInitVerifier(
      product_out,
      partition_map,
      tool=os.path.join(OPTIONS.vendor_otatools, 'bin', 'host_init_verifier'))


def RunHostInitVerifier(product_out, partition_map, tool="host_init_verifier"):
  """Runs host_init_verifier on the init rc files within partitions.

  host_init_verifier searches the etc/init path within each partition.
@@ -1418,9 +1433,10 @@ def RunHostInitVerifier(product_out, partition_map):
  Args:
    product_out: PRODUCT_OUT directory, containing partition directories.
    partition_map: A map of partition name -> relative path within product_out.
    tool: Full path to host_init_verifier or binary name
  """
  allowed_partitions = ("system", "system_ext", "product", "vendor", "odm")
  cmd = ["host_init_verifier"]
  cmd = [tool]
  for partition, path in partition_map.items():
    if partition not in allowed_partitions:
      raise ExternalError("Unable to call host_init_verifier for partition %s" %
+12 −1
Original line number Diff line number Diff line
@@ -95,8 +95,19 @@ def CheckShareduidViolation(target_files_dir, partition_map):
def CheckInitRcFiles(target_files_dir, partition_map):
  """Check for any init.rc issues using host_init_verifier."""
  try:
    vendor_partitions = set()
    if OPTIONS.vendor_otatools:
      vendor_partitions = {"vendor", "odm"}
      common.RunVendoredHostInitVerifier(
          product_out=target_files_dir,
          partition_map={p: partition_map[p] for p in vendor_partitions})

    common.RunHostInitVerifier(
        product_out=target_files_dir, partition_map=partition_map)
        product_out=target_files_dir,
        partition_map={
            p: partition_map[p]
            for p in partition_map.keys() - vendor_partitions
        })
  except RuntimeError as err:
    return [str(err)]
  return []
+10 −7
Original line number Diff line number Diff line
@@ -87,8 +87,8 @@ Usage: merge_target_files [args]
      If provided, rebuilds odm.img or vendor.img to include merged sepolicy
      files. If odm is present then odm is preferred.

  --vendor-otatools otatools.zip
      If provided, use this otatools.zip when recompiling the odm or vendor
  --vendor-otatools otatools.zip or directory
      If provided, use these otatools when recompiling the odm or vendor
      image to include sepolicy.

  --keep-tmp
@@ -312,12 +312,9 @@ def rebuild_image_with_sepolicy(target_files_dir):
      '%s recompilation will be performed using the vendor otatools.zip',
      partition_img)

  # Unzip the vendor build's otatools.zip and target-files archive.
  vendor_otatools_dir = common.MakeTempDir(
      prefix='merge_target_files_vendor_otatools_')
  # Unzip the vendor build's target-files archive.
  vendor_target_files_dir = common.MakeTempDir(
      prefix='merge_target_files_vendor_target_files_')
  common.UnzipToDir(OPTIONS.vendor_otatools, vendor_otatools_dir)
  merge_utils.CollectTargetFiles(
      input_zipfile_or_dir=OPTIONS.vendor_target_files,
      output_dir=vendor_target_files_dir,
@@ -335,7 +332,7 @@ def rebuild_image_with_sepolicy(target_files_dir):
  remove_file_if_exists(
      os.path.join(vendor_target_files_dir, 'IMAGES', partition_img))
  rebuild_partition_command = [
      os.path.join(vendor_otatools_dir, 'bin', 'add_img_to_target_files'),
      os.path.join(OPTIONS.vendor_otatools, 'bin', 'add_img_to_target_files'),
      '--verbose',
      '--add_missing',
  ]
@@ -669,6 +666,12 @@ def main():
  if OPTIONS.output_item_list:
    OPTIONS.output_item_list = common.LoadListFromFile(OPTIONS.output_item_list)

  if OPTIONS.vendor_otatools and zipfile.is_zipfile(OPTIONS.vendor_otatools):
    vendor_otatools_dir = common.MakeTempDir(
        prefix='merge_target_files_vendor_otatools_')
    common.UnzipToDir(OPTIONS.vendor_otatools, vendor_otatools_dir)
    OPTIONS.vendor_otatools = vendor_otatools_dir

  if not merge_utils.ValidateConfigLists():
    sys.exit(1)