Consider prebuilt vendor.img as having vendor partition.
vendor.img could be built from the source - in which case we have
unpacked files under VENDOR/ - or dropped in as a prebuilt binary blob.
We should consider either of them as target having a vendor partition.
Because we need to add its AVB hashtree info into vbmeta.img if target
is using AVB. Otherwise libfs_mgr would refuse to mount this
"AVB-enabled" vendor.img.
For targets not using AVB, this change is no-op.
Bug: 65462819
Test: Having vendor.img as prebuilt, `make dist`. Check that the
generated vbmeta.img contains the info from vendor.img.
Test: Build, flash and boot the above image.zip.
Change-Id: Iaeb30e2059cb33fb39f23e5ffd28f338d00ccbfc
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 1ce22e7..52d3918 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -505,7 +505,13 @@
print("target_files appears to already contain images.")
sys.exit(1)
- has_vendor = os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR"))
+ # vendor.img is unlike system.img or system_other.img. Because it could be
+ # built from source, or dropped into target_files.zip as a prebuilt blob. We
+ # consider either of them as vendor.img being available, which could be used
+ # when generating vbmeta.img for AVB.
+ has_vendor = (os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR")) or
+ os.path.exists(os.path.join(OPTIONS.input_tmp, "IMAGES",
+ "vendor.img")))
has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp,
"SYSTEM_OTHER"))