Skip to content

Commit 9b9cc95

Browse files
jabashqueArmSM
authored andcommitted
build_image: get squashfs partition size from image size
Just like erofs, we should used the compressed image's size to calculate partition size, not the input directory's size. Change-Id: I46d6dfa59cd7e8a02c349f026b1fd10be3fec587
1 parent 6a2c4c2 commit 9b9cc95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/releasetools/build_image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,15 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
554554
"partition_size" not in prop_dict):
555555
# If partition_size is not defined, use output of `du' + reserved_size.
556556
# For compressed file system, it's better to use the compressed size to avoid wasting space.
557-
if fs_type.startswith("erofs"):
557+
if fs_type.startswith("erofs") or fs_type.startswith("squash"):
558558
mkfs_output = BuildImageMkfs(
559559
in_dir, prop_dict, out_file, target_out, fs_config)
560-
if "erofs_sparse_flag" in prop_dict and not disable_sparse:
560+
sparse_flag = False
561+
if fs_type.startswith("erofs") and "erofs_sparse_flag" in prop_dict:
562+
sparse_flag = True
563+
if fs_type.startswith("squash") and "squashfs_sparse_flag" in prop_dict:
564+
sparse_flag = True
565+
if sparse_flag and not disable_sparse:
561566
image_path = UnsparseImage(out_file, replace=False)
562567
size = GetDiskUsage(image_path)
563568
os.remove(image_path)

0 commit comments

Comments
 (0)