consolidate target_files metadata into one key-value file

Instead of separate files for recovery api version, tool extensions,
and mkyaffs2 options, put those all in the generic key-value file.

Change-Id: Ib642311632844d52e4895fd4747093fc7e86232d
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index a74ef89..8250b0e 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -68,8 +68,9 @@
       build_command.append(str(OPTIONS.max_image_size["userdata.img"]))
   else:
     build_command = ["mkyaffs2image", "-f"]
-    if OPTIONS.mkyaffs2_extra_flags is not None:
-      build_command.append(OPTIONS.mkyaffs2_extra_flags);
+    extra = OPTIONS.info_dict.get("mkyaffs2_extra_flags", None)
+    if extra:
+      build_command.extend(extra.split())
     build_command.append(user_dir)
     build_command.append(img.name)
 
@@ -77,7 +78,7 @@
   p.communicate()
   assert p.returncode == 0, "build userdata.img image failed"
 
-  common.CheckSize(img.name, "userdata.img")
+  common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict)
   output_zip.write(img.name, "userdata.img")
   img.close()
   os.rmdir(user_dir)
@@ -115,8 +116,9 @@
       build_command.append(str(OPTIONS.max_image_size["system.img"]))
   else:
     build_command = ["mkyaffs2image", "-f"]
-    if OPTIONS.mkyaffs2_extra_flags is not None:
-      build_command.extend(OPTIONS.mkyaffs2_extra_flags.split());
+    extra = OPTIONS.info_dict.get("mkyaffs2_extra_flags", None)
+    if extra:
+      build_command.extend(extra.split())
     build_command.append(os.path.join(OPTIONS.input_tmp, "system"))
     build_command.append(img.name)
 
@@ -128,7 +130,7 @@
   data = img.read()
   img.close()
 
-  common.CheckSize(data, "system.img")
+  common.CheckSize(data, "system.img", OPTIONS.info_dict)
   common.ZipWriteStr(output_zip, "system.img", data)
 
 
@@ -158,20 +160,13 @@
 
   OPTIONS.input_tmp = common.UnzipTemp(args[0])
 
-  OPTIONS.info_dict = common.LoadInfoDict()
-  common.LoadMaxSizes(OPTIONS.info_dict)
-  if not OPTIONS.max_image_size:
-    print
-    print "  WARNING:  Failed to load max image sizes; will not enforce"
-    print "  image size limits."
-    print
-
-  common.LoadMkyaffs2ExtraFlags()
+  input_zip = zipfile.ZipFile(args[0], "r")
+  OPTIONS.info_dict = common.LoadInfoDict(input_zip)
 
   output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
 
-  common.AddBoot(output_zip)
-  common.AddRecovery(output_zip)
+  common.AddBoot(output_zip, OPTIONS.info_dict)
+  common.AddRecovery(output_zip, OPTIONS.info_dict)
   AddSystem(output_zip)
   AddUserdata(output_zip)
   CopyInfo(output_zip)