Merge changes I1deda85d,I43d7b2c6

* changes:
  calculation partition size use compressed image size
  add erofs to non partition spanning fs
This commit is contained in:
Treehugger Robot 2020-12-09 06:50:56 +00:00 committed by Gerrit Code Review
commit 70c61bc6e9
1 changed files with 11 additions and 2 deletions

View File

@ -417,7 +417,7 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
fs_type = prop_dict.get("fs_type", "")
fs_spans_partition = True
if fs_type.startswith("squash"):
if fs_type.startswith("squash") or fs_type.startswith("erofs"):
fs_spans_partition = False
# Get a builder for creating an image that's to be verified by Verified Boot,
@ -427,7 +427,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 ...