From 9a072cc0b0238aa94756cd46fff4a0c7c7ba0b69 Mon Sep 17 00:00:00 2001 From: Adrien Schildknecht Date: Fri, 18 Nov 2016 17:06:29 -0800 Subject: [PATCH] Add support for creating ext4 images with mke2fs We are investigating replacing make_ext4fs with the upstream tool mke2fs. To mitigate the trouble that may arise if the new tool behave differently compared to the old one, there will be a transition period. Devices that want to use the new way of creating ext4 images can set the variable "TARGET_USES_MKE2FS" to true in their BoardConfig.mk By default, the build system will choose the old tool 'make_ext4fs'. Test: m otapackage with TARGET_USES_MKE2FS={,false,true} Change-Id: I282bcb9efe335a86c53986283090ca947d65c7f8 --- core/Makefile | 5 +++-- core/config.mk | 7 ++++++- tools/releasetools/build_image.py | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index dc760b55e..9bfb4eac8 100644 --- a/core/Makefile +++ b/core/Makefile @@ -835,6 +835,7 @@ INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS) # $(1): the path of the output dictionary file # $(2): additional "key=value" pairs to append to the dictionary file. define generate-userimage-prop-dictionary +$(hide) echo "ext_mkuserimg=$(MKEXTUSERIMG)" >> $(1) $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) @@ -1655,8 +1656,8 @@ OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \ - $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ - $(HOST_OUT_EXECUTABLES)/make_ext4fs \ + $(MAKE_EXT4FS) \ + $(MKEXTUSERIMG) \ $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \ $(HOST_OUT_EXECUTABLES)/mksquashfs \ $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \ diff --git a/core/config.mk b/core/config.mk index 2fcf1fe13..6ebd36810 100644 --- a/core/config.mk +++ b/core/config.mk @@ -583,9 +583,14 @@ AVBTOOL := $(BOARD_CUSTOM_AVBTOOL) endif APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX) FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX) +ifeq ($(TARGET_USES_MKE2FS),true) +MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/mke2fs$(HOST_EXECUTABLE_SUFFIX) +MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh +else MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX) -BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX) MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh +endif +BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX) MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX) MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX) diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index 6bf42d19d..c5be3dfb3 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -437,7 +437,7 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None): prop_dict["original_partition_size"] = str(partition_size) if fs_type.startswith("ext"): - build_command = ["mkuserimg.sh"] + build_command = [prop_dict["ext_mkuserimg"]] if "extfs_sparse_flag" in prop_dict: build_command.append(prop_dict["extfs_sparse_flag"]) run_fsck = True @@ -606,6 +606,7 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): "squashfs_sparse_flag", "selinux_fc", "skip_fsck", + "ext_mkuserimg", "verity", "verity_key", "verity_signer_cmd",