forked from openkylin/platform_build
am 065521be: Backport ext4 support from master [DO NOT MERGE]
Merge commit '065521be4fd6965058fbd599bb43fe13101fee7c' into gingerbread-plus-aosp * commit '065521be4fd6965058fbd599bb43fe13101fee7c': Backport ext4 support from master [DO NOT MERGE]
This commit is contained in:
commit
d3b973d897
|
@ -545,11 +545,38 @@ otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip
|
||||||
# Targets for user images
|
# Targets for user images
|
||||||
# #################################################################
|
# #################################################################
|
||||||
|
|
||||||
|
INTERNAL_USERIMAGES_EXT_VARIANT :=
|
||||||
ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
|
ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
|
||||||
include external/genext2fs/Config.mk
|
INTERNAL_USERIMAGES_USE_EXT := true
|
||||||
INTERNAL_MKUSERFS := $(MKEXT2IMG)
|
INTERNAL_USERIMAGES_EXT_VARIANT := ext2
|
||||||
else
|
else
|
||||||
INTERNAL_MKUSERFS := $(MKYAFFS2)
|
ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
|
||||||
|
INTERNAL_USERIMAGES_USE_EXT := true
|
||||||
|
INTERNAL_USERIMAGES_EXT_VARIANT := ext3
|
||||||
|
else
|
||||||
|
ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
|
||||||
|
INTERNAL_USERIMAGES_USE_EXT := true
|
||||||
|
INTERNAL_USERIMAGES_EXT_VARIANT := ext4
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
|
||||||
|
INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MAKE_EXT4FS)
|
||||||
|
INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
|
||||||
|
|
||||||
|
# $(1): src directory
|
||||||
|
# $(2): output file
|
||||||
|
# $(3): label
|
||||||
|
# $(4): ext variant (ext2, ext3, ext4)
|
||||||
|
# $(5): size of the partition
|
||||||
|
define build-userimage-ext-target
|
||||||
|
@mkdir -p $(dir $(2))
|
||||||
|
$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
|
||||||
|
$(MKEXT2USERIMG) $(1) $(2) $(4) $(3) $(5)
|
||||||
|
endef
|
||||||
|
else
|
||||||
|
INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
@ -664,15 +691,15 @@ INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
|
||||||
$(ALL_GENERATED_SOURCES) \
|
$(ALL_GENERATED_SOURCES) \
|
||||||
$(ALL_DEFAULT_INSTALLED_MODULES))
|
$(ALL_DEFAULT_INSTALLED_MODULES))
|
||||||
|
|
||||||
ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
|
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
|
||||||
## generate an ext2 image
|
## generate an ext2 image
|
||||||
# $(1): output file
|
# $(1): output file
|
||||||
define build-systemimage-target
|
define build-systemimage-target
|
||||||
@echo "Target system fs image: $(1)"
|
@echo "Target system fs image: $(1)"
|
||||||
$(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,)
|
$(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
else # TARGET_USERIMAGES_USE_EXT2 != true
|
else # INTERNAL_USERIMAGES_USE_EXT != true
|
||||||
|
|
||||||
## generate a yaffs2 image
|
## generate a yaffs2 image
|
||||||
# $(1): output file
|
# $(1): output file
|
||||||
|
@ -681,9 +708,9 @@ define build-systemimage-target
|
||||||
@mkdir -p $(dir $(1))
|
@mkdir -p $(dir $(1))
|
||||||
$(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
|
$(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT) $(1)
|
||||||
endef
|
endef
|
||||||
endif # TARGET_USERIMAGES_USE_EXT2
|
endif # INTERNAL_USERIMAGES_USE_EXT
|
||||||
|
|
||||||
$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS)
|
$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
|
||||||
$(call build-systemimage-target,$@)
|
$(call build-systemimage-target,$@)
|
||||||
|
|
||||||
# The installed image, which may be optimized or unoptimized.
|
# The installed image, which may be optimized or unoptimized.
|
||||||
|
@ -730,7 +757,7 @@ systemimage: $(INSTALLED_SYSTEMIMAGE)
|
||||||
|
|
||||||
.PHONY: systemimage-nodeps snod
|
.PHONY: systemimage-nodeps snod
|
||||||
systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
|
systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
|
||||||
| $(INTERNAL_MKUSERFS)
|
| $(INTERNAL_USERIMAGES_DEPS)
|
||||||
@echo "make $@: ignoring dependencies"
|
@echo "make $@: ignoring dependencies"
|
||||||
$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
|
$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE))
|
||||||
$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
|
$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
|
||||||
|
@ -796,16 +823,16 @@ boottarball-nodeps btnod: $(FS_GET_STATS) \
|
||||||
INTERNAL_USERDATAIMAGE_FILES := \
|
INTERNAL_USERDATAIMAGE_FILES := \
|
||||||
$(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
|
$(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
|
||||||
|
|
||||||
ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
|
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
|
||||||
## Generate an ext2 image
|
## Generate an ext image
|
||||||
define build-userdataimage-target
|
define build-userdataimage-target
|
||||||
$(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
|
$(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
|
||||||
@mkdir -p $(TARGET_OUT_DATA)
|
@mkdir -p $(TARGET_OUT_DATA)
|
||||||
$(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,)
|
$(call build-userimage-ext-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
|
||||||
$(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
|
$(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
else # TARGET_USERIMAGES_USE_EXT2 != true
|
else # INTERNAL_USERIMAGES_USE_EXT != true
|
||||||
|
|
||||||
## Generate a yaffs2 image
|
## Generate a yaffs2 image
|
||||||
define build-userdataimage-target
|
define build-userdataimage-target
|
||||||
|
@ -814,18 +841,18 @@ define build-userdataimage-target
|
||||||
$(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
|
$(hide) $(MKYAFFS2) -f $(mkyaffs2_extra_flags) $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
|
||||||
$(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
|
$(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE),yaffs)
|
||||||
endef
|
endef
|
||||||
endif # TARGET_USERIMAGES_USE_EXT2
|
endif # INTERNAL_USERIMAGES_USE_EXT
|
||||||
|
|
||||||
BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
|
BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
|
INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
|
||||||
$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \
|
$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
|
||||||
$(INTERNAL_USERDATAIMAGE_FILES)
|
$(INTERNAL_USERDATAIMAGE_FILES)
|
||||||
$(build-userdataimage-target)
|
$(build-userdataimage-target)
|
||||||
|
|
||||||
.PHONY: userdataimage-nodeps
|
.PHONY: userdataimage-nodeps
|
||||||
userdataimage-nodeps: $(INTERNAL_MKUSERFS)
|
userdataimage-nodeps: $(INTERNAL_USERIMAGES_DEPS)
|
||||||
$(build-userdataimage-target)
|
$(build-userdataimage-target)
|
||||||
|
|
||||||
#######
|
#######
|
||||||
|
@ -1174,6 +1201,7 @@ $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
|
||||||
$(hide) ./build/tools/releasetools/img_from_target_files \
|
$(hide) ./build/tools/releasetools/img_from_target_files \
|
||||||
-s $(extensions) \
|
-s $(extensions) \
|
||||||
-p $(HOST_OUT) \
|
-p $(HOST_OUT) \
|
||||||
|
$(addprefix --fs_type ,$(INTERNAL_USERIMAGES_EXT_VARIANT)) \
|
||||||
$(BUILT_TARGET_FILES_PACKAGE) $@
|
$(BUILT_TARGET_FILES_PACKAGE) $@
|
||||||
|
|
||||||
.PHONY: updatepackage
|
.PHONY: updatepackage
|
||||||
|
|
|
@ -208,6 +208,8 @@ MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
|
||||||
APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
|
APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
|
||||||
FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
|
FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
|
||||||
MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
|
MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
|
||||||
|
MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
|
||||||
|
MKEXT2USERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
|
||||||
MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
|
MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
|
||||||
MKTARBALL := build/tools/mktarball.sh
|
MKTARBALL := build/tools/mktarball.sh
|
||||||
TUNE2FS := tune2fs
|
TUNE2FS := tune2fs
|
||||||
|
|
|
@ -23,6 +23,11 @@ Usage: img_from_target_files [flags] input_target_files output_image_zip
|
||||||
-b (--board_config) <file>
|
-b (--board_config) <file>
|
||||||
Deprecated.
|
Deprecated.
|
||||||
|
|
||||||
|
-f (--fs_type) <value>
|
||||||
|
The file system type of the user image files to be created.
|
||||||
|
It can be ext fs variants, such as ext2, ext3, ext4, etc.
|
||||||
|
efault is yaffs.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -47,6 +52,9 @@ import common
|
||||||
|
|
||||||
OPTIONS = common.OPTIONS
|
OPTIONS = common.OPTIONS
|
||||||
|
|
||||||
|
class UserImageOptions(object): pass
|
||||||
|
USERIMAGE_OPTIONS = UserImageOptions()
|
||||||
|
USERIMAGE_OPTIONS.fs_type = None
|
||||||
|
|
||||||
def AddUserdata(output_zip):
|
def AddUserdata(output_zip):
|
||||||
"""Create an empty userdata image and store it in output_zip."""
|
"""Create an empty userdata image and store it in output_zip."""
|
||||||
|
@ -61,9 +69,19 @@ def AddUserdata(output_zip):
|
||||||
os.mkdir(user_dir)
|
os.mkdir(user_dir)
|
||||||
img = tempfile.NamedTemporaryFile()
|
img = tempfile.NamedTemporaryFile()
|
||||||
|
|
||||||
p = common.Run(["mkyaffs2image", "-f", user_dir, img.name])
|
build_command = []
|
||||||
|
if USERIMAGE_OPTIONS.fs_type is not None and USERIMAGE_OPTIONS.fs_type.startswith("ext"):
|
||||||
|
build_command = ["mkuserimg.sh",
|
||||||
|
user_dir, img.name, USERIMAGE_OPTIONS.fs_type, "userdata"]
|
||||||
|
if "userdata.img" in OPTIONS.max_image_size:
|
||||||
|
build_command.append(str(OPTIONS.max_image_size["userdata.img"]))
|
||||||
|
else:
|
||||||
|
build_command = ["mkyaffs2image", "-f",
|
||||||
|
user_dir, img.name]
|
||||||
|
|
||||||
|
p = common.Run(build_command)
|
||||||
p.communicate()
|
p.communicate()
|
||||||
assert p.returncode == 0, "mkyaffs2image of userdata.img image failed"
|
assert p.returncode == 0, "build userdata.img image failed"
|
||||||
|
|
||||||
common.CheckSize(img.name, "userdata.img")
|
common.CheckSize(img.name, "userdata.img")
|
||||||
output_zip.write(img.name, "userdata.img")
|
output_zip.write(img.name, "userdata.img")
|
||||||
|
@ -94,10 +112,20 @@ def AddSystem(output_zip):
|
||||||
if (e.errno == errno.EEXIST):
|
if (e.errno == errno.EEXIST):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
p = common.Run(["mkyaffs2image", "-f",
|
build_command = []
|
||||||
os.path.join(OPTIONS.input_tmp, "system"), img.name])
|
if USERIMAGE_OPTIONS.fs_type is not None and USERIMAGE_OPTIONS.fs_type.startswith("ext"):
|
||||||
|
build_command = ["mkuserimg.sh",
|
||||||
|
os.path.join(OPTIONS.input_tmp, "system"), img.name,
|
||||||
|
USERIMAGE_OPTIONS.fs_type, "system"]
|
||||||
|
if "system.img" in OPTIONS.max_image_size:
|
||||||
|
build_command.append(str(OPTIONS.max_image_size["system.img"]))
|
||||||
|
else:
|
||||||
|
build_command = ["mkyaffs2image", "-f",
|
||||||
|
os.path.join(OPTIONS.input_tmp, "system"), img.name]
|
||||||
|
|
||||||
|
p = common.Run(build_command)
|
||||||
p.communicate()
|
p.communicate()
|
||||||
assert p.returncode == 0, "mkyaffs2image of system.img image failed"
|
assert p.returncode == 0, "build system.img image failed"
|
||||||
|
|
||||||
img.seek(os.SEEK_SET, 0)
|
img.seek(os.SEEK_SET, 0)
|
||||||
data = img.read()
|
data = img.read()
|
||||||
|
@ -118,13 +146,15 @@ def main(argv):
|
||||||
def option_handler(o, a):
|
def option_handler(o, a):
|
||||||
if o in ("-b", "--board_config"):
|
if o in ("-b", "--board_config"):
|
||||||
pass # deprecated
|
pass # deprecated
|
||||||
|
elif o in ("-f", "--fs_type"):
|
||||||
|
USERIMAGE_OPTIONS.fs_type = a
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
args = common.ParseOptions(argv, __doc__,
|
args = common.ParseOptions(argv, __doc__,
|
||||||
extra_opts="b:",
|
extra_opts="b:f:",
|
||||||
extra_long_opts=["board_config="],
|
extra_long_opts=["board_config=", "fs_type="],
|
||||||
extra_option_handler=option_handler)
|
extra_option_handler=option_handler)
|
||||||
|
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
|
|
Loading…
Reference in New Issue