summaryrefslogtreecommitdiffstats
path: root/tools/releasetools
diff options
context:
space:
mode:
authorMohamad Ayyash <mkayyash@google.com>2015-04-02 18:18:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-02 18:18:21 +0000
commit6ddc3600659d4517c416ce3b06e4ccee14042030 (patch)
treec411386c94bdde0168c206ff418a8ac451d66079 /tools/releasetools
parent0064c51efee452daae110eac99b1321c00652c17 (diff)
parentdd063528edea7b47071dee451ae52341239192fd (diff)
downloadbuild-6ddc3600659d4517c416ce3b06e4ccee14042030.zip
build-6ddc3600659d4517c416ce3b06e4ccee14042030.tar.gz
build-6ddc3600659d4517c416ce3b06e4ccee14042030.tar.bz2
Merge "build_image.py: Verity support for flashing non partition spanning fs"
Diffstat (limited to 'tools/releasetools')
-rwxr-xr-xtools/releasetools/build_image.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 4e78acb..9f8a8ec 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -231,11 +231,14 @@ def BuildImage(in_dir, prop_dict, out_file):
fs_type = prop_dict.get("fs_type", "")
run_fsck = False
+ fs_spans_partition = True
+ if fs_type.startswith("squash"):
+ fs_spans_partition = False
+
is_verity_partition = "verity_block_device" in prop_dict
verity_supported = prop_dict.get("verity") == "true"
- # adjust the partition size to make room for the hashes if this is to be
- # verified
- if verity_supported and is_verity_partition:
+ # adjust the partition size to make room for the hashes if this is to be verified
+ if verity_supported and is_verity_partition and fs_spans_partition:
partition_size = int(prop_dict.get("partition_size"))
adjusted_size = AdjustPartitionSizeForVerity(partition_size)
if not adjusted_size:
@@ -301,6 +304,20 @@ def BuildImage(in_dir, prop_dict, out_file):
if exit_code != 0:
return False
+ if not fs_spans_partition:
+ mount_point = prop_dict.get("mount_point")
+ partition_size = int(prop_dict.get("partition_size"))
+ image_size = os.stat(out_file).st_size
+ if image_size > partition_size:
+ print "Error: %s image size of %d is larger than partition size of %d" % (mount_point, image_size, partition_size)
+ return False
+ if verity_supported and is_verity_partition:
+ if 2 * image_size - AdjustPartitionSizeForVerity(image_size) > partition_size:
+ print "Error: No more room on %s to fit verity data" % mount_point
+ return False
+ prop_dict["original_partition_size"] = prop_dict["partition_size"]
+ prop_dict["partition_size"] = str(image_size)
+
# create the verified image if this is to be verified
if verity_supported and is_verity_partition:
if not MakeVerityEnabledImage(out_file, prop_dict):