use the max image sizes from the target files zip

For some time now the build system has included all the max image
sizes in a file in the META directory.  Use these instead of needing
to parse the BoardConfig.mk file for the device at the time of
building an image or OTA package.
This commit is contained in:
Doug Zongker
2009-08-03 17:27:48 -07:00
parent 7ebafd5aa0
commit fdd8e69c42
3 changed files with 29 additions and 30 deletions

View File

@@ -46,18 +46,18 @@ def Run(args, **kwargs):
return subprocess.Popen(args, **kwargs) return subprocess.Popen(args, **kwargs)
def LoadBoardConfig(fn): def LoadMaxSizes():
"""Parse a board_config.mk file looking for lines that specify the """Load the maximum allowable images sizes from the input
maximum size of various images, and parse them into the target_files size."""
OPTIONS.max_image_size dict."""
OPTIONS.max_image_size = {} OPTIONS.max_image_size = {}
for line in open(fn): try:
line = line.strip() for line in open(os.path.join(OPTIONS.input_tmp, "META", "imagesizes.txt")):
m = re.match(r"BOARD_(BOOT|RECOVERY|SYSTEM|USERDATA)IMAGE_MAX_SIZE" image, size = line.split()
r"\s*:=\s*(\d+)", line) size = int(size)
if not m: continue OPTIONS.max_image_size[image + ".img"] = size
except IOError, e:
OPTIONS.max_image_size[m.group(1).lower() + ".img"] = int(m.group(2)) if e.errno == errno.ENOENT:
pass
def BuildAndAddBootableImage(sourcedir, targetname, output_zip): def BuildAndAddBootableImage(sourcedir, targetname, output_zip):

View File

@@ -21,8 +21,7 @@ use with 'fastboot update'.
Usage: img_from_target_files [flags] input_target_files output_image_zip Usage: img_from_target_files [flags] input_target_files output_image_zip
-b (--board_config) <file> -b (--board_config) <file>
Specifies a BoardConfig.mk file containing image max sizes Deprecated.
against which the generated image files are checked.
""" """
@@ -109,10 +108,10 @@ 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"):
common.LoadBoardConfig(a) pass # deprecated
return True
else: else:
return False return False
return True
args = common.ParseOptions(argv, __doc__, args = common.ParseOptions(argv, __doc__,
extra_opts="b:", extra_opts="b:",
@@ -123,15 +122,15 @@ def main(argv):
common.Usage(__doc__) common.Usage(__doc__)
sys.exit(1) sys.exit(1)
OPTIONS.input_tmp = common.UnzipTemp(args[0])
common.LoadMaxSizes()
if not OPTIONS.max_image_size: if not OPTIONS.max_image_size:
print print
print " WARNING: No board config specified; will not check image" print " WARNING: Failed to load max image sizes; will not enforce"
print " sizes against limits. Use -b to make sure the generated" print " image size limits."
print " images don't exceed partition sizes."
print print
OPTIONS.input_tmp = common.UnzipTemp(args[0])
output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
common.AddBoot(output_zip) common.AddBoot(output_zip)

View File

@@ -22,8 +22,7 @@ a full OTA is produced.
Usage: ota_from_target_files [flags] input_target_files output_ota_package Usage: ota_from_target_files [flags] input_target_files output_ota_package
-b (--board_config) <file> -b (--board_config) <file>
Specifies a BoardConfig.mk file containing image max sizes Deprecated.
against which the generated image files are checked.
-k (--package_key) <key> -k (--package_key) <key>
Key to use to sign the package (default is Key to use to sign the package (default is
@@ -736,7 +735,7 @@ 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"):
common.LoadBoardConfig(a) pass # deprecated
elif o in ("-k", "--package_key"): elif o in ("-k", "--package_key"):
OPTIONS.package_key = a OPTIONS.package_key = a
elif o in ("-i", "--incremental_from"): elif o in ("-i", "--incremental_from"):
@@ -768,13 +767,6 @@ def main(argv):
common.Usage(__doc__) common.Usage(__doc__)
sys.exit(1) sys.exit(1)
if not OPTIONS.max_image_size:
print
print " WARNING: No board config specified; will not check image"
print " sizes against limits. Use -b to make sure the generated"
print " images don't exceed partition sizes."
print
if OPTIONS.script_mode not in ("amend", "edify", "auto"): if OPTIONS.script_mode not in ("amend", "edify", "auto"):
raise ValueError('unknown script mode "%s"' % (OPTIONS.script_mode,)) raise ValueError('unknown script mode "%s"' % (OPTIONS.script_mode,))
@@ -783,6 +775,14 @@ def main(argv):
print "unzipping target target-files..." print "unzipping target target-files..."
OPTIONS.input_tmp = common.UnzipTemp(args[0]) OPTIONS.input_tmp = common.UnzipTemp(args[0])
common.LoadMaxSizes()
if not OPTIONS.max_image_size:
print
print " WARNING: Failed to load max image sizes; will not enforce"
print " image size limits."
print
OPTIONS.target_tmp = OPTIONS.input_tmp OPTIONS.target_tmp = OPTIONS.input_tmp
input_zip = zipfile.ZipFile(args[0], "r") input_zip = zipfile.ZipFile(args[0], "r")
if OPTIONS.package_key: if OPTIONS.package_key: