Pass partition size to mkuserimg.sh

Change-Id: Id6a53d8d552e8ce1bdf83fbb756724454e05e5c8
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index fc8a2be..18ba842 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -93,7 +93,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")
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index 15a43cd..c0d27da 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -74,6 +74,8 @@
   if USERIMAGE_OPTIONS.fs_type is not None and USERIMAGE_OPTIONS.fs_type.startswith("ext"):
     build_command = ["mkuserimg.sh",
                      user_dir, img.name, USERIMAGE_OPTIONS.fs_type, "userdata"]
+    if "userdata.img" in OPTIONS.max_image_size:
+      build_command.append(str(OPTIONS.max_image_size["userdata.img"]))
   else:
     build_command = ["mkyaffs2image", "-f",
                      user_dir, img.name]
@@ -116,6 +118,8 @@
     build_command = ["mkuserimg.sh",
                      os.path.join(OPTIONS.input_tmp, "system"), img.name,
                      USERIMAGE_OPTIONS.fs_type, "system"]
+    if "system.img" in OPTIONS.max_image_size:
+      build_command.append(str(OPTIONS.max_image_size["system.img"]))
   else:
     build_command = ["mkyaffs2image", "-f",
                      os.path.join(OPTIONS.input_tmp, "system"), img.name]