diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-04 14:16:38 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-08-04 14:16:38 -0700 |
commit | 7d7630cca8eff1252fbb3cc6ac75eb07617a13e9 (patch) | |
tree | 7f8ffd147b34546ef7651d86c3a5f9e76766a188 /tools/releasetools | |
parent | 0f64a553813cbf7e9e630b9f5dfd3aadbd000281 (diff) | |
parent | b6153173952895441e55d0ff6be332bb7c7605e2 (diff) | |
download | build-7d7630cca8eff1252fbb3cc6ac75eb07617a13e9.zip build-7d7630cca8eff1252fbb3cc6ac75eb07617a13e9.tar.gz build-7d7630cca8eff1252fbb3cc6ac75eb07617a13e9.tar.bz2 |
am b6153173: Merge change 9605 into donut
Merge commit 'b6153173952895441e55d0ff6be332bb7c7605e2'
* commit 'b6153173952895441e55d0ff6be332bb7c7605e2':
use the max image sizes from the target files zip
Diffstat (limited to 'tools/releasetools')
-rw-r--r-- | tools/releasetools/common.py | 22 | ||||
-rwxr-xr-x | tools/releasetools/img_from_target_files | 17 | ||||
-rwxr-xr-x | tools/releasetools/ota_from_target_files | 20 |
3 files changed, 29 insertions, 30 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 4174db5..7cce669 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -47,18 +47,18 @@ def Run(args, **kwargs): return subprocess.Popen(args, **kwargs) -def LoadBoardConfig(fn): - """Parse a board_config.mk file looking for lines that specify the - maximum size of various images, and parse them into the - OPTIONS.max_image_size dict.""" +def LoadMaxSizes(): + """Load the maximum allowable images sizes from the input + target_files size.""" OPTIONS.max_image_size = {} - for line in open(fn): - line = line.strip() - m = re.match(r"BOARD_(BOOT|RECOVERY|SYSTEM|USERDATA)IMAGE_MAX_SIZE" - r"\s*:=\s*(\d+)", line) - if not m: continue - - OPTIONS.max_image_size[m.group(1).lower() + ".img"] = int(m.group(2)) + try: + for line in open(os.path.join(OPTIONS.input_tmp, "META", "imagesizes.txt")): + image, size = line.split() + size = int(size) + OPTIONS.max_image_size[image + ".img"] = size + except IOError, e: + if e.errno == errno.ENOENT: + pass def BuildAndAddBootableImage(sourcedir, targetname, output_zip): diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files index 1d154b9..00abde4 100755 --- a/tools/releasetools/img_from_target_files +++ b/tools/releasetools/img_from_target_files @@ -21,8 +21,7 @@ use with 'fastboot update'. Usage: img_from_target_files [flags] input_target_files output_image_zip -b (--board_config) <file> - Specifies a BoardConfig.mk file containing image max sizes - against which the generated image files are checked. + Deprecated. """ @@ -109,10 +108,10 @@ def main(argv): def option_handler(o, a): if o in ("-b", "--board_config"): - common.LoadBoardConfig(a) - return True + pass # deprecated else: return False + return True args = common.ParseOptions(argv, __doc__, extra_opts="b:", @@ -123,15 +122,15 @@ def main(argv): common.Usage(__doc__) sys.exit(1) + OPTIONS.input_tmp = common.UnzipTemp(args[0]) + + common.LoadMaxSizes() 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 " WARNING: Failed to load max image sizes; will not enforce" + print " image size limits." print - OPTIONS.input_tmp = common.UnzipTemp(args[0]) - output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED) common.AddBoot(output_zip) diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index 58177b4..864c35b 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -22,8 +22,7 @@ a full OTA is produced. Usage: ota_from_target_files [flags] input_target_files output_ota_package -b (--board_config) <file> - Specifies a BoardConfig.mk file containing image max sizes - against which the generated image files are checked. + Deprecated. -k (--package_key) <key> Key to use to sign the package (default is @@ -738,7 +737,7 @@ def main(argv): def option_handler(o, a): if o in ("-b", "--board_config"): - common.LoadBoardConfig(a) + pass # deprecated elif o in ("-k", "--package_key"): OPTIONS.package_key = a elif o in ("-i", "--incremental_from"): @@ -770,13 +769,6 @@ def main(argv): common.Usage(__doc__) 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"): raise ValueError('unknown script mode "%s"' % (OPTIONS.script_mode,)) @@ -785,6 +777,14 @@ def main(argv): print "unzipping target target-files..." 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 input_zip = zipfile.ZipFile(args[0], "r") if OPTIONS.package_key: |