diff options
author | Huang Jianan <huangjianan@oppo.com> | 2020-12-04 16:58:24 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-09-27 21:17:05 +0800 |
commit | be590a54563dc741a9d407c8b8921bff26105a71 (patch) | |
tree | 30afeb70328e2272fe83579749ffd50d78a72dc7 | |
parent | 2688eda1171027051b7db69b8e338d2fa64dd2c4 (diff) |
[master] releasetools: calculation partition size use compressed image size
If dynamic partitioning is enabled and the partition size is not set,
du will be used to calculate the partition size.
For compressed file systems, it's better to use the compressed size
to avoid wasting space.
Bug: 174816929
Test: erofs image size is smaller than the original file
Change-Id: I1deda85d312c19620680531223fffcfb815e5fd4
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
-rwxr-xr-x | tools/releasetools/build_image.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index d33472c12c..086d80ffec 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -424,7 +424,16 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None): if (prop_dict.get("use_dynamic_partition_size") == "true" and "partition_size" not in prop_dict): # If partition_size is not defined, use output of `du' + reserved_size. - size = GetDiskUsage(in_dir) + # For compressed file system, it's better to use the compressed size to avoid wasting space. + if fs_type.startswith("erofs"): + tmp_dict = prop_dict.copy() + if "erofs_sparse_flag" in tmp_dict: + tmp_dict.pop("erofs_sparse_flag") + BuildImageMkfs(in_dir, tmp_dict, out_file, target_out, fs_config) + size = GetDiskUsage(out_file) + os.remove(out_file) + else: + size = GetDiskUsage(in_dir) logger.info( "The tree size of %s is %d MB.", in_dir, size // BYTES_IN_MB) # If not specified, give us 16MB margin for GetDiskUsage error ... |