Support relative key path in VerifiedBootVersion2VerityImageBuilder

Otatools archive can be unpacked to an arbitrary directory together
with bundled external/avb/test/data keys. Calling add_img_to_target_files
from a different directory fails to build an image which has
avb_{}_key_path pointing to the bundled key since add_hash_footer
can't find the key file.

Fix this by applying the same logic as in common.AppendAVBSigningArgs.

Steps to reproduce:
$ . build/envsetup.sh && lunch aosp_cf_arm64_phone-userdebug && make dist
$ cd out/dist && rm -rf otatools && unzip otatools.zip -d otatools
$ zip -d aosp_cf_arm64_phone-*target_files*.zip IMAGES/system_other.img
$ otatools/bin/add_img_to_target_files -a -v -p otatools \
    aosp_cf_arm64_phone-target_files-*.zip

Bug: 218531463
Test: manual, see "steps to reproduce" above
Change-Id: Id3f7cf2678e998ef1beda2b6741944c6455c2404
diff --git a/tools/releasetools/verity_utils.py b/tools/releasetools/verity_utils.py
index a08ddbe..d55ad88 100644
--- a/tools/releasetools/verity_utils.py
+++ b/tools/releasetools/verity_utils.py
@@ -379,6 +379,11 @@
     self.avbtool = avbtool
     self.algorithm = algorithm
     self.key_path = key_path
+    if key_path and not os.path.exists(key_path) and OPTIONS.search_path:
+      new_key_path = os.path.join(OPTIONS.search_path, key_path)
+      if os.path.exists(new_key_path):
+        self.key_path = new_key_path
+
     self.salt = salt
     self.signing_args = signing_args
     self.image_size = None