Merge "build_image: Remove mkerofsimage.sh." am: 060505fb4a am: c836e2e090 am: 0a132b5e2f

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

Change-Id: Ie7406b2257a96d04587b6117d038f058c76e785b
This commit is contained in:
David Anderson 2022-03-09 11:20:29 +00:00 committed by Automerger Merge Worker
commit d15d508196
4 changed files with 54 additions and 28 deletions

View file

@ -1691,7 +1691,7 @@ ifneq ($(filter \
$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \ $(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \ $(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
,erofs),) ,erofs),)
INTERNAL_USERIMAGES_DEPS += $(MKEROFSUSERIMG) INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
BOARD_EROFS_COMPRESSOR ?= "lz4hc,9" BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
endif endif
@ -4657,7 +4657,6 @@ INTERNAL_OTATOOLS_MODULES := \
mke2fs \ mke2fs \
mke2fs.conf \ mke2fs.conf \
mkfs.erofs \ mkfs.erofs \
mkerofsimage.sh \
mkf2fsuserimg.sh \ mkf2fsuserimg.sh \
mksquashfs \ mksquashfs \
mksquashfsimage.sh \ mksquashfsimage.sh \

View file

@ -598,7 +598,6 @@ FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs
MKE2FS_CONF := system/extras/ext4_utils/mke2fs.conf MKE2FS_CONF := system/extras/ext4_utils/mke2fs.conf
MKEROFS := $(HOST_OUT_EXECUTABLES)/mkfs.erofs MKEROFS := $(HOST_OUT_EXECUTABLES)/mkfs.erofs
MKEROFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkerofsimage.sh
MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX) SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)

View file

@ -56,7 +56,9 @@ python_defaults {
required: [ required: [
"blk_alloc_to_base_fs", "blk_alloc_to_base_fs",
"e2fsck", "e2fsck",
"mkerofsimage.sh", "fsck.erofs",
"img2simg",
"mkfs.erofs",
"mkuserimg_mke2fs", "mkuserimg_mke2fs",
"simg2img", "simg2img",
"tune2fs", "tune2fs",

View file

@ -268,18 +268,19 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
""" """
build_command = [] build_command = []
fs_type = prop_dict.get("fs_type", "") fs_type = prop_dict.get("fs_type", "")
run_e2fsck = False run_fsck = None
needs_projid = prop_dict.get("needs_projid", 0) needs_projid = prop_dict.get("needs_projid", 0)
needs_casefold = prop_dict.get("needs_casefold", 0) needs_casefold = prop_dict.get("needs_casefold", 0)
needs_compress = prop_dict.get("needs_compress", 0) needs_compress = prop_dict.get("needs_compress", 0)
disable_sparse = "disable_sparse" in prop_dict disable_sparse = "disable_sparse" in prop_dict
manual_sparse = False
if fs_type.startswith("ext"): if fs_type.startswith("ext"):
build_command = [prop_dict["ext_mkuserimg"]] build_command = [prop_dict["ext_mkuserimg"]]
if "extfs_sparse_flag" in prop_dict and not disable_sparse: if "extfs_sparse_flag" in prop_dict and not disable_sparse:
build_command.append(prop_dict["extfs_sparse_flag"]) build_command.append(prop_dict["extfs_sparse_flag"])
run_e2fsck = True run_e2fsck = RunE2fsck
build_command.extend([in_dir, out_file, fs_type, build_command.extend([in_dir, out_file, fs_type,
prop_dict["mount_point"]]) prop_dict["mount_point"]])
build_command.append(prop_dict["image_size"]) build_command.append(prop_dict["image_size"])
@ -320,17 +321,8 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
if "selinux_fc" in prop_dict: if "selinux_fc" in prop_dict:
build_command.append(prop_dict["selinux_fc"]) build_command.append(prop_dict["selinux_fc"])
elif fs_type.startswith("erofs"): elif fs_type.startswith("erofs"):
build_command = ["mkerofsimage.sh"] build_command = ["mkfs.erofs"]
build_command.extend([in_dir, out_file])
if "erofs_sparse_flag" in prop_dict and not disable_sparse:
build_command.extend([prop_dict["erofs_sparse_flag"]])
build_command.extend(["-m", prop_dict["mount_point"]])
if target_out:
build_command.extend(["-d", target_out])
if fs_config:
build_command.extend(["-C", fs_config])
if "selinux_fc" in prop_dict:
build_command.extend(["-c", prop_dict["selinux_fc"]])
compressor = None compressor = None
if "erofs_default_compressor" in prop_dict: if "erofs_default_compressor" in prop_dict:
compressor = prop_dict["erofs_default_compressor"] compressor = prop_dict["erofs_default_compressor"]
@ -338,16 +330,30 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
compressor = prop_dict["erofs_compressor"] compressor = prop_dict["erofs_compressor"]
if compressor: if compressor:
build_command.extend(["-z", compressor]) build_command.extend(["-z", compressor])
build_command.extend(["--mount-point", prop_dict["mount_point"]])
if target_out:
build_command.extend(["--product-out", target_out])
if fs_config:
build_command.extend(["--fs-config-file", fs_config])
if "selinux_fc" in prop_dict:
build_command.extend(["--file-contexts", prop_dict["selinux_fc"]])
if "timestamp" in prop_dict: if "timestamp" in prop_dict:
build_command.extend(["-T", str(prop_dict["timestamp"])]) build_command.extend(["-T", str(prop_dict["timestamp"])])
if "uuid" in prop_dict: if "uuid" in prop_dict:
build_command.extend(["-U", prop_dict["uuid"]]) build_command.extend(["-U", prop_dict["uuid"]])
if "block_list" in prop_dict: if "block_list" in prop_dict:
build_command.extend(["-B", prop_dict["block_list"]]) build_command.extend(["--block-list-file", prop_dict["block_list"]])
if "erofs_pcluster_size" in prop_dict: if "erofs_pcluster_size" in prop_dict:
build_command.extend(["-P", prop_dict["erofs_pcluster_size"]]) build_command.extend(["-C", prop_dict["erofs_pcluster_size"]])
if "erofs_share_dup_blocks" in prop_dict: if "erofs_share_dup_blocks" in prop_dict:
build_command.extend(["-k", "4096"]) build_command.extend(["--chunksize", "4096"])
build_command.extend([out_file, in_dir])
if "erofs_sparse_flag" in prop_dict and not disable_sparse:
manual_sparse = True
run_fsck = RunErofsFsck
elif fs_type.startswith("squash"): elif fs_type.startswith("squash"):
build_command = ["mksquashfsimage.sh"] build_command = ["mksquashfsimage.sh"]
build_command.extend([in_dir, out_file]) build_command.extend([in_dir, out_file])
@ -436,7 +442,19 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
int(prop_dict["partition_size"]) // BYTES_IN_MB)) int(prop_dict["partition_size"]) // BYTES_IN_MB))
raise raise
if run_e2fsck and prop_dict.get("skip_fsck") != "true": if run_fsck and prop_dict.get("skip_fsck") != "true":
run_fsck(out_file)
if manual_sparse:
temp_file = out_file + ".sparse"
img2simg_argv = ["img2simg", out_file, temp_file]
common.RunAndCheckOutput(img2simg_argv)
os.rename(temp_file, out_file)
return mkfs_output
def RunE2fsck(out_file):
unsparse_image = UnsparseImage(out_file, replace=False) unsparse_image = UnsparseImage(out_file, replace=False)
# Run e2fsck on the inflated image file # Run e2fsck on the inflated image file
@ -446,7 +464,15 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
finally: finally:
os.remove(unsparse_image) os.remove(unsparse_image)
return mkfs_output
def RunErofsFsck(out_file):
fsck_command = ["fsck.erofs", "--extract", out_file]
try:
common.RunAndCheckOutput(fsck_command)
except:
print("Check failed for EROFS image {}".format(out_file))
raise
def BuildImage(in_dir, prop_dict, out_file, target_out=None): def BuildImage(in_dir, prop_dict, out_file, target_out=None):
"""Builds an image for the files under in_dir and writes it to out_file. """Builds an image for the files under in_dir and writes it to out_file.