Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b74a0045 authored by Yifan Hong's avatar Yifan Hong Committed by Automerger Merge Worker
Browse files

Merge "Avoid repeated building of erofs image" am: 1ab1c2ff

Original change: https://android-review.googlesource.com/c/platform/build/+/1821096

Change-Id: Ibe47f2192262300122e8d6b767a2879af3d317ed
parents 98fd5d25 1ab1c2ff
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -451,18 +451,19 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
  verity_image_builder = verity_utils.CreateVerityImageBuilder(prop_dict)

  disable_sparse = "disable_sparse" in prop_dict

  mkfs_output = 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.
    # 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)
      mkfs_output = BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config)
      if "erofs_sparse_flag" in prop_dict and not disable_sparse:
        image_path = UnsparseImage(out_file, replace=False)
        size = GetDiskUsage(image_path)
        os.remove(image_path)
      else:
        size = GetDiskUsage(out_file)
      os.remove(out_file)
    else:
      size = GetDiskUsage(in_dir)
    logger.info(
@@ -550,6 +551,7 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
    max_image_size = verity_image_builder.CalculateMaxImageSize()
    prop_dict["image_size"] = str(max_image_size)

  if not mkfs_output:
    mkfs_output = BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config)

  # Check if there's enough headroom space available for ext4 image.