store user-visible image sizes in target-files
Do the yaffs-specific adjustments to image sizes in common.CheckSize,
instead of baking it into the image size stored in the target-files
package. Remove the special fs_type flag and fold it into the
"info_dict" we have for saving key-value pairs from the build system.
Change-Id: I6e63f3330f6277d9a946b22e66cadeb51203ba14
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index 46ac754..a74ef89 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -23,11 +23,6 @@
-b (--board_config) <file>
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
@@ -52,10 +47,6 @@
OPTIONS = common.OPTIONS
-class UserImageOptions(object): pass
-USERIMAGE_OPTIONS = UserImageOptions()
-USERIMAGE_OPTIONS.fs_type = None
-
def AddUserdata(output_zip):
"""Create an empty userdata image and store it in output_zip."""
@@ -70,9 +61,9 @@
img = tempfile.NamedTemporaryFile()
build_command = []
- if USERIMAGE_OPTIONS.fs_type is not None and USERIMAGE_OPTIONS.fs_type.startswith("ext"):
+ if OPTIONS.info_dict.get("fs_type", "").startswith("ext"):
build_command = ["mkuserimg.sh",
- user_dir, img.name, USERIMAGE_OPTIONS.fs_type, "userdata"]
+ user_dir, img.name, OPTIONS.info_dict["fs_type"], "userdata"]
if "userdata.img" in OPTIONS.max_image_size:
build_command.append(str(OPTIONS.max_image_size["userdata.img"]))
else:
@@ -86,8 +77,7 @@
p.communicate()
assert p.returncode == 0, "build userdata.img image failed"
- if USERIMAGE_OPTIONS.fs_type is None or not USERIMAGE_OPTIONS.fs_type.startswith("ext"):
- common.CheckSize(img.name, "userdata.img")
+ common.CheckSize(img.name, "userdata.img")
output_zip.write(img.name, "userdata.img")
img.close()
os.rmdir(user_dir)
@@ -117,10 +107,10 @@
pass
build_command = []
- if USERIMAGE_OPTIONS.fs_type is not None and USERIMAGE_OPTIONS.fs_type.startswith("ext"):
+ if OPTIONS.info_dict.get("fs_type", "").startswith("ext"):
build_command = ["mkuserimg.sh",
os.path.join(OPTIONS.input_tmp, "system"), img.name,
- USERIMAGE_OPTIONS.fs_type, "system"]
+ OPTIONS.info_dict["fs_type"], "system"]
if "system.img" in OPTIONS.max_image_size:
build_command.append(str(OPTIONS.max_image_size["system.img"]))
else:
@@ -138,8 +128,7 @@
data = img.read()
img.close()
- if USERIMAGE_OPTIONS.fs_type is None or not USERIMAGE_OPTIONS.fs_type.startswith("ext"):
- common.CheckSize(data, "system.img")
+ common.CheckSize(data, "system.img")
common.ZipWriteStr(output_zip, "system.img", data)
@@ -154,15 +143,13 @@
def option_handler(o, a):
if o in ("-b", "--board_config"):
pass # deprecated
- elif o in ("-f", "--fs_type"):
- USERIMAGE_OPTIONS.fs_type = a
else:
return False
return True
args = common.ParseOptions(argv, __doc__,
- extra_opts="b:f:",
- extra_long_opts=["board_config=", "fs_type="],
+ extra_opts="b:",
+ extra_long_opts=["board_config="],
extra_option_handler=option_handler)
if len(args) != 2:
@@ -171,8 +158,8 @@
OPTIONS.input_tmp = common.UnzipTemp(args[0])
- info = common.LoadInfoDict()
- common.LoadMaxSizes(info)
+ OPTIONS.info_dict = common.LoadInfoDict()
+ common.LoadMaxSizes(OPTIONS.info_dict)
if not OPTIONS.max_image_size:
print
print " WARNING: Failed to load max image sizes; will not enforce"