From 477cf2b029f18570771e7ca8508f04e58b0bfe56 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 16 Apr 2014 18:49:56 -0700 Subject: [PATCH] verity: switch to C++ version of build_verity_tree The C++ version avoids the need to unsparse the image to generate the verity image, and is much faster for images with large regions of don't care (treated as zeroes). Change-Id: I8396b08a5fdb93f27d8c71c9c1ac23cb75cf1f7f --- core/Makefile | 2 +- core/config.mk | 1 + tools/releasetools/build_image.py | 14 ++++---------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/core/Makefile b/core/Makefile index d0667e201..8cbe2d1ff 100644 --- a/core/Makefile +++ b/core/Makefile @@ -643,7 +643,7 @@ endif INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS))) ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) -INTERNAL_USERIMAGES_DEPS += $(APPEND2SIMG) $(VERITY_SIGNER) +INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER) endif SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts diff --git a/core/config.mk b/core/config.mk index b809d942a..f79082e5f 100644 --- a/core/config.mk +++ b/core/config.mk @@ -377,6 +377,7 @@ LINT := prebuilts/sdk/tools/lint RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer +BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree # ACP is always for the build OS, not for the host OS ACP := $(BUILD_OUT_EXECUTABLES)/acp$(BUILD_EXECUTABLE_SUFFIX) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index d80e7a62d..d3f71442a 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -43,7 +43,7 @@ def RunCommand(cmd): return p.returncode def GetVerityTreeSize(partition_size): - cmd = "system/extras/verity/build_verity_tree.py -s %d" + cmd = "build_verity_tree -s %d" cmd %= partition_size status, output = commands.getstatusoutput(cmd) if status: @@ -77,9 +77,8 @@ def AdjustPartitionSizeForVerity(partition_size): return 0 return partition_size - verity_tree_size - verity_metadata_size -def BuildVerityTree(unsparse_image_path, verity_image_path, partition_size, prop_dict): - cmd = ("system/extras/verity/build_verity_tree.py %s %s %d" % - (unsparse_image_path, verity_image_path, partition_size)) +def BuildVerityTree(sparse_image_path, verity_image_path, prop_dict): + cmd = ("build_verity_tree %s %s" % (sparse_image_path, verity_image_path)) print cmd status, output = commands.getstatusoutput(cmd) if status: @@ -166,7 +165,6 @@ def MakeVerityEnabledImage(out_file, prop_dict): """ # get properties image_size = prop_dict["partition_size"] - part_size = int(prop_dict["original_partition_size"]) block_dev = prop_dict["verity_block_device"] signer_key = prop_dict["verity_key"] signer_path = prop_dict["verity_signer_cmd"] @@ -180,13 +178,9 @@ def MakeVerityEnabledImage(out_file, prop_dict): # get partial image paths verity_image_path = os.path.join(tempdir_name, "verity.img") verity_metadata_path = os.path.join(tempdir_name, "verity_metadata.img") - success, unsparse_image_path = UnsparseImage(out_file) - if not success: - shutil.rmtree(tempdir_name) - return False # build the verity tree and get the root hash and salt - if not BuildVerityTree(unsparse_image_path, verity_image_path, part_size, prop_dict): + if not BuildVerityTree(out_file, verity_image_path, prop_dict): shutil.rmtree(tempdir_name) return False -- 2.11.0