am d421f57d: Fix mkyaffs2image extra flags in the release tools.

Merge commit 'd421f57d22009e4d9ce71298c2f93636ff9e7d9d' into gingerbread-plus-aosp

* commit 'd421f57d22009e4d9ce71298c2f93636ff9e7d9d':
  Fix mkyaffs2image extra flags in the release tools.
diff --git a/core/Makefile b/core/Makefile
index 09da022..237ac5a 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1033,6 +1033,9 @@
 	$(hide) echo "system $(call image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt
 	$(hide) echo "userdata $(call image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))" >> $(zip_root)/META/imagesizes.txt
 	$(hide) echo "$(tool_extensions)" > $(zip_root)/META/tool-extensions.txt
+ifdef mkyaffs2_extra_flags
+	$(hide) echo "$(mkyaffs2_extra_flags)" > $(zip_root)/META/mkyaffs2-extra-flags.txt
+endif
 	@# Zip everything up, preserving symlinks
 	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
 	@# Run fs_config on all the system files in the zip, and save the output
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 037c4cf..6bb37ae 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -36,6 +36,7 @@
 OPTIONS.tempfiles = []
 OPTIONS.device_specific = None
 OPTIONS.extras = {}
+OPTIONS.mkyaffs2_extra_flags = None
 
 
 # Values for "certificate" in apkcerts that mean special things.
@@ -69,6 +70,17 @@
       pass
 
 
+def LoadMkyaffs2ExtraFlags():
+  """Load mkyaffs2 extra flags."""
+  try:
+    fn = os.path.join(OPTIONS.input_tmp, "META", "mkyaffs2-extra-flags.txt");
+    if os.access(fn, os.F_OK):
+      OPTIONS.mkyaffs2_extra_flags = open(fn).read().rstrip("\n")
+  except IOError, e:
+    if e.errno == errno.ENOENT:
+      pass
+
+
 def BuildAndAddBootableImage(sourcedir, targetname, output_zip):
   """Take a kernel, cmdline, and ramdisk directory from the input (in
   'sourcedir'), and turn them into a boot image.  Put the boot image
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index 44bed9c..1f119ad 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -76,8 +76,11 @@
     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]
+    build_command = ["mkyaffs2image", "-f"]
+    if OPTIONS.mkyaffs2_extra_flags is not None:
+      build_command.append(OPTIONS.mkyaffs2_extra_flags);
+    build_command.append(user_dir)
+    build_command.append(img.name)
 
   p = common.Run(build_command)
   p.communicate()
@@ -121,8 +124,11 @@
     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]
+    build_command = ["mkyaffs2image", "-f"]
+    if OPTIONS.mkyaffs2_extra_flags is not None:
+      build_command.append(OPTIONS.mkyaffs2_extra_flags);
+    build_command.append(os.path.join(OPTIONS.input_tmp, "system"))
+    build_command.append(img.name)
 
   p = common.Run(build_command)
   p.communicate()
@@ -172,6 +178,8 @@
     print "  image size limits."
     print
 
+  common.LoadMkyaffs2ExtraFlags()
+
   output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
 
   common.AddBoot(output_zip)