Merge "releasetools: Return the actual image size when building logical partitions."

This commit is contained in:
Tao Bao
2018-07-26 16:59:36 +00:00
committed by Gerrit Code Review

View File

@@ -660,14 +660,24 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
success, du = GetDiskUsage(origin_in) success, du = GetDiskUsage(origin_in)
du_str = ("%d bytes (%d MB)" % (du, du // BYTES_IN_MB) du_str = ("%d bytes (%d MB)" % (du, du // BYTES_IN_MB)
) if success else "unknown" ) if success else "unknown"
print("Out of space? The tree size of %s is %s." % ( print(
origin_in, du_str)) "Out of space? The tree size of {} is {}, with reserved space of {} "
print("The max is %d bytes (%d MB)." % ( "bytes ({} MB).".format(
int(prop_dict["partition_size"]), origin_in, du_str,
int(prop_dict["partition_size"]) // BYTES_IN_MB)) int(prop_dict.get("partition_reserved_size", 0)),
print("Reserved space is %d bytes (%d MB)." % ( int(prop_dict.get("partition_reserved_size", 0)) // BYTES_IN_MB))
int(prop_dict.get("partition_reserved_size", 0)), if "original_partition_size" in prop_dict:
int(prop_dict.get("partition_reserved_size", 0)) // BYTES_IN_MB)) print(
"The max size for filsystem files is {} bytes ({} MB), out of a "
"total image size of {} bytes ({} MB).".format(
int(prop_dict["partition_size"]),
int(prop_dict["partition_size"]) // BYTES_IN_MB,
int(prop_dict["original_partition_size"]),
int(prop_dict["original_partition_size"]) // BYTES_IN_MB))
else:
print("The max image size is {} bytes ({} MB).".format(
int(prop_dict["partition_size"]),
int(prop_dict["partition_size"]) // BYTES_IN_MB))
return False return False
# Check if there's enough headroom space available for ext4 image. # Check if there's enough headroom space available for ext4 image.
@@ -931,16 +941,22 @@ def GlobalDictFromImageProp(image_prop, mount_point):
d[dest_p] = image_prop[src_p] d[dest_p] = image_prop[src_p]
return True return True
return False return False
if "original_partition_size" in image_prop:
size_property = "original_partition_size"
else:
size_property = "partition_size"
if mount_point == "system": if mount_point == "system":
copy_prop("partition_size", "system_size") copy_prop(size_property, "system_size")
elif mount_point == "system_other": elif mount_point == "system_other":
copy_prop("partition_size", "system_size") copy_prop(size_property, "system_size")
elif mount_point == "vendor": elif mount_point == "vendor":
copy_prop("partition_size", "vendor_size") copy_prop(size_property, "vendor_size")
elif mount_point == "product": elif mount_point == "product":
copy_prop("partition_size", "product_size") copy_prop(size_property, "product_size")
elif mount_point == "product-services": elif mount_point == "product-services":
copy_prop("partition_size", "productservices_size") copy_prop(size_property, "productservices_size")
return d return d