Remove the hard-coded path of build_verity_metadata.py.
build_image.py used to invoke build_verity_metadata.py with a hard-coded
path of 'system/extras/verity/build_verity_metadata.py', which makes it
hard to run unittests from non-$(ANDROID_BUILD_TOP) directory.
This CL adds the dependency on the tool, so that it gets installed to
$(HOST_OUT_EXECUTABLES), then removes the hard-coded path.
Bug: 74544459
Bug: 76015688
Test: `m dist`
Test: python -m unittest test_validate_target_files
Change-Id: I0dcf4eb067a0db6f099cb589eb99a151a05c7f2b
diff --git a/core/Makefile b/core/Makefile
index 9f164d8..06573fb 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1063,7 +1063,7 @@
INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
-INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
+INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER)
ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC))
INTERNAL_USERIMAGES_DEPS += $(FEC)
endif
@@ -2329,7 +2329,6 @@
$(HOST_OUT_EXECUTABLES)/sload_f2fs \
$(HOST_OUT_EXECUTABLES)/simg2img \
$(HOST_OUT_EXECUTABLES)/e2fsck \
- $(HOST_OUT_EXECUTABLES)/build_verity_tree \
$(HOST_OUT_EXECUTABLES)/generate_verity_key \
$(HOST_OUT_EXECUTABLES)/verity_signer \
$(HOST_OUT_EXECUTABLES)/verity_verifier \
@@ -2342,7 +2341,9 @@
$(HOST_OUT_EXECUTABLES)/delta_generator \
$(AVBTOOL) \
$(BLK_ALLOC_TO_BASE_FS) \
- $(BROTLI)
+ $(BROTLI) \
+ $(BUILD_VERITY_METADATA) \
+ $(BUILD_VERITY_TREE)
ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
OTATOOLS += \
@@ -2388,7 +2389,6 @@
$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
OTATOOLS_DEPS := \
- system/extras/verity/build_verity_metadata.py \
system/extras/ext4_utils/mke2fs.conf \
external/avb/test/data/testkey_rsa4096.pem \
$(sort $(shell find system/update_engine/scripts -name \*.pyc -prune -o -type f -print)) \
diff --git a/core/config.mk b/core/config.mk
index e72b55a..be8c9a4 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -677,6 +677,7 @@
BUILD_IMAGE_SRCS := $(wildcard build/make/tools/releasetools/*.py)
APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
+BUILD_VERITY_METADATA := $(HOST_OUT_EXECUTABLES)/build_verity_metadata.py
BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
FUTILITY := $(HOST_OUT_EXECUTABLES)/futility-host
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 123ec7c..2e2e088 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -80,8 +80,7 @@
def GetVerityMetadataSize(partition_size):
- cmd = ["system/extras/verity/build_verity_metadata.py", "size",
- str(partition_size)]
+ cmd = ["build_verity_metadata.py", "size", str(partition_size)]
output, exit_code = RunCommand(cmd, False)
if exit_code != 0:
return False, 0
@@ -250,9 +249,8 @@
def BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt,
block_device, signer_path, key, signer_args,
verity_disable):
- cmd = ["system/extras/verity/build_verity_metadata.py", "build",
- str(image_size), verity_metadata_path, root_hash, salt, block_device,
- signer_path, key]
+ cmd = ["build_verity_metadata.py", "build", str(image_size),
+ verity_metadata_path, root_hash, salt, block_device, signer_path, key]
if signer_args:
cmd.append("--signer_args=\"%s\"" % (' '.join(signer_args),))
if verity_disable:
diff --git a/tools/releasetools/test_validate_target_files.py b/tools/releasetools/test_validate_target_files.py
index bae648f..d62ea95 100644
--- a/tools/releasetools/test_validate_target_files.py
+++ b/tools/releasetools/test_validate_target_files.py
@@ -14,21 +14,7 @@
# limitations under the License.
#
-"""Unittests for validate_target_files.py.
-
-Note: This file calls functions in build_image.py that hard-code the path in
-relative to ANDROID_BUILD_TOP (e.g.
-system/extras/verity/build_verity_metadata.py). So the test needs to be
-triggered under ANDROID_BUILD_TOP or the top-level OTA tools directory (i.e.
-the one after unzipping otatools.zip).
-
- (from ANDROID_BUILD_TOP)
- $ PYTHONPATH=build/make/tools/releasetools python -m unittest \\
- test_validate_target_files
-
- (from OTA tools directory)
- $ PYTHONPATH=releasetools python -m unittest test_validate_target_files
-"""
+"""Unittests for validate_target_files.py."""
from __future__ import print_function