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/common.py b/tools/releasetools/common.py
index 2a81133..8b163c0 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -41,6 +41,7 @@
 OPTIONS.device_specific = None
 OPTIONS.extras = {}
 OPTIONS.mkyaffs2_extra_flags = None
+OPTIONS.info_dict = None
 
 
 # Values for "certificate" in apkcerts that mean special things.
@@ -85,7 +86,7 @@
 def LoadMaxSizes(info):
   """Load the maximum allowable images sizes from the input
   target_files.  Uses the imagesizes.txt file if it's available
-  (pre-honeycomb target_files), or the more general info dict (which
+  (pre-gingerbread target_files), or the more general info dict (which
   must be passed in) if not."""
   OPTIONS.max_image_size = {}
   try:
@@ -98,7 +99,7 @@
   except IOError, e:
     if e.errno == errno.ENOENT:
       def copy(x, y):
-        if x in info: OPTIONS.max_image_size[x+".img"] = int(info[x+y])
+        if x+y in info: OPTIONS.max_image_size[x+".img"] = int(info[x+y])
       copy("blocksize", "")
       copy("boot", "_size")
       copy("recovery", "_size")
@@ -297,9 +298,18 @@
   """Check the data string passed against the max size limit, if
   any, for the given target.  Raise exception if the data is too big.
   Print a warning if the data is nearing the maximum size."""
+
+  fs_type = OPTIONS.info_dict.get("fs_type", None)
+  if not fs_type: return
+
   limit = OPTIONS.max_image_size.get(target, None)
   if limit is None: return
 
+  if fs_type == "yaffs2":
+    # image size should be increased by 1/64th to account for the
+    # spare area (64 bytes per 2k page)
+    limit = limit / 2048 * (2048+64)
+
   size = len(data)
   pct = float(size) * 100.0 / limit
   msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)