mtf: Use vendor otatools for checking rc-files on vendor and odm
host_init_verifier is getting stricter and stricter with every new
android release. However when merging older (previous android version)
vendor target files, these checks become too strict.
Use host_init_verifier from vendor otatools on vendor and odm to not
enforce new requirement on VFR/GRF'ed partitions (vendor and odm).
Bug: 398184724
Change-Id: I5c7a8fc86c7b8405758fba309eb780b3052e0051
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index e5f5f92..3fc08c6 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1410,7 +1410,22 @@
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 @@
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" %
diff --git a/tools/releasetools/merge/merge_compatibility_checks.py b/tools/releasetools/merge/merge_compatibility_checks.py
index 8c9993f..80b5caa 100644
--- a/tools/releasetools/merge/merge_compatibility_checks.py
+++ b/tools/releasetools/merge/merge_compatibility_checks.py
@@ -95,8 +95,19 @@
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 []
diff --git a/tools/releasetools/merge/merge_target_files.py b/tools/releasetools/merge/merge_target_files.py
index fdba927..de4d9a8 100755
--- a/tools/releasetools/merge/merge_target_files.py
+++ b/tools/releasetools/merge/merge_target_files.py
@@ -87,8 +87,8 @@
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 @@
'%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 @@
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 @@
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)