extfs support for img_from_target_files

Change-Id: Ie3df70426066bff467792b8528bc4528eb6afe15
This commit is contained in:
Ying Wang 2010-06-16 14:31:34 -07:00
parent 96c286daf1
commit 933abf15bc
2 changed files with 47 additions and 10 deletions

View File

@ -521,6 +521,7 @@ 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)
INTERNAL_USERIMAGES_USE_EXT := true INTERNAL_USERIMAGES_USE_EXT := true
INTERNAL_USERIMAGES_EXT_VARIANT := ext2 INTERNAL_USERIMAGES_EXT_VARIANT := ext2
@ -537,15 +538,18 @@ endif
endif endif
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true) ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MKEXT2IMG) $(TUNE2FS) $(E2FSCK)
INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
# $(1): src directory # $(1): src directory
# $(2): output file # $(2): output file
# $(3): label (if any) # $(3): label (if any)
# $(4): ext variant (ext2, ext3, ext4) # $(4): ext variant (ext2, ext3, ext4)
define build-userimage-ext-target define build-userimage-ext-target
@mkdir -p $(dir $(2)) @mkdir -p $(dir $(2))
$(hide) $(MKEXT2USERIMG) $(MKEXT2IMG) $(TUNE2FS) $(E2FSCK) $(1) $(2) $(4) $(3) $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
$(MKEXT2USERIMG) $(1) $(2) $(4) $(3)
endef endef
INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MKEXT2IMG) $(TUNE2FS) $(E2FSCK)
else else
INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2) INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
endif endif
@ -836,7 +840,12 @@ otatools: $(HOST_OUT_EXECUTABLES)/minigzip \
$(HOST_OUT_EXECUTABLES)/bsdiff \ $(HOST_OUT_EXECUTABLES)/bsdiff \
$(HOST_OUT_EXECUTABLES)/imgdiff \ $(HOST_OUT_EXECUTABLES)/imgdiff \
$(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
$(HOST_OUT_JAVA_LIBRARIES)/signapk.jar $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
$(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
$(HOST_OUT_EXECUTABLES)/genext2fs \
$(HOST_OUT_EXECUTABLES)/tune2fs \
$(HOST_OUT_EXECUTABLES)/e2fsck
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# A zip of the directories that map to the target filesystem. # A zip of the directories that map to the target filesystem.
@ -1135,6 +1144,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

View File

@ -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.
Default is yaffs.
""" """
import sys import sys
@ -47,6 +52,10 @@ 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 +70,17 @@ 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"]
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 +111,18 @@ 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"]
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 +143,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: