summaryrefslogtreecommitdiffstats
path: root/tools/releasetools/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/releasetools/common.py')
-rw-r--r--tools/releasetools/common.py40
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index ab6678a..fc8a2be 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -53,9 +53,35 @@ def Run(args, **kwargs):
return subprocess.Popen(args, **kwargs)
-def LoadMaxSizes():
+def LoadInfoDict():
+ """Read and parse the META/misc_info.txt key/value pairs from the
+ input target files and return a dict."""
+
+ d = {}
+ try:
+ for line in open(os.path.join(OPTIONS.input_tmp, "META", "misc_info.txt")):
+ line = line.strip()
+ if not line or line.startswith("#"): continue
+ k, v = line.split("=", 1)
+ d[k] = v
+ except IOError, e:
+ if e.errno == errno.ENOENT:
+ # ok if misc_info.txt file doesn't exist
+ pass
+ else:
+ raise
+
+ if "fs_type" not in d: info["fs_type"] = "yaffs2"
+ if "partition_type" not in d: info["partition_type"] = "MTD"
+
+ return d
+
+
+def LoadMaxSizes(info):
"""Load the maximum allowable images sizes from the input
- target_files size."""
+ target_files. Uses the imagesizes.txt file if it's available
+ (pre-honeycomb target_files), or the more general info dict (which
+ must be passed in) if not."""
OPTIONS.max_image_size = {}
try:
for line in open(os.path.join(OPTIONS.input_tmp, "META", "imagesizes.txt")):
@@ -66,7 +92,15 @@ def LoadMaxSizes():
OPTIONS.max_image_size[image + ".img"] = size
except IOError, e:
if e.errno == errno.ENOENT:
- pass
+ def copy(x, y):
+ if x in info: OPTIONS.max_image_size[x+".img"] = int(info[x+y])
+ copy("blocksize", "")
+ copy("boot", "_size")
+ copy("recovery", "_size")
+ copy("system", "_size")
+ copy("userdata", "_size")
+ else:
+ raise
def BuildAndAddBootableImage(sourcedir, targetname, output_zip):