resolved conflicts for merge of a86fcc29 to master

Change-Id: I3868c19bfd309b5b43b5642152a120931fe37315
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 15acddc..a615d1a 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -46,12 +46,17 @@
                           prop_dict["mount_point"]])
     if "partition_size" in prop_dict:
       build_command.append(prop_dict["partition_size"])
+    if "selinux_fc" in prop_dict:
+      build_command.append(prop_dict["selinux_fc"])
   else:
     build_command = ["mkyaffs2image", "-f"]
     if prop_dict.get("mkyaffs2_extra_flags", None):
       build_command.extend(prop_dict["mkyaffs2_extra_flags"].split())
     build_command.append(in_dir)
     build_command.append(out_file)
+    if "selinux_fc" in prop_dict:
+      build_command.append(prop_dict["selinux_fc"])
+      build_command.append(prop_dict["mount_point"])
 
   print "Running: ", " ".join(build_command)
   p = subprocess.Popen(build_command);
@@ -75,6 +80,7 @@
   common_props = (
       "extfs_sparse_flag",
       "mkyaffs2_extra_flags",
+      "selinux_fc",
       )
   for p in common_props:
     copy_prop(p, p)
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 8c31927..5672b5a 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -165,9 +165,9 @@
     fstab = self.info.get("fstab", None)
     if fstab:
       p = fstab[partition]
-      self.script.append('format("%s", "%s", "%s", "%s");' %
+      self.script.append('format("%s", "%s", "%s", "%s", "%s");' %
                          (p.fs_type, common.PARTITION_TYPES[p.fs_type],
-                          p.device, p.length))
+                          p.device, p.length, p.mount_point))
 
   def DeleteFiles(self, file_list):
     """Delete all files in file_list."""
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 7e855ce..3dcfbee 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -48,6 +48,10 @@
 
   -e  (--extra_script)  <file>
       Insert the contents of file at the end of the update script.
+
+  -a  (--aslr_mode)  <on|off>
+      Specify whether to turn on ASLR for the package (on by default).
+
 """
 
 import sys
@@ -381,6 +385,9 @@
   if OPTIONS.wipe_user_data:
     script.FormatPartition("/data")
 
+  if "selinux_fc" in OPTIONS.info_dict:
+    WritePolicyConfig(OPTIONS.info_dict["selinux_fc"], output_zip)
+
   script.FormatPartition("/system")
   script.Mount("/system")
   script.UnpackPackageDir("recovery", "/system")
@@ -415,15 +422,17 @@
   script.AddToZip(input_zip, output_zip)
   WriteMetadata(metadata, output_zip)
 
+def WritePolicyConfig(file_context, output_zip):
+  f = open(file_context, 'r');
+  basename = os.path.basename(file_context)
+  common.ZipWriteStr(output_zip, basename, f.read())
+
 
 def WriteMetadata(metadata, output_zip):
   common.ZipWriteStr(output_zip, "META-INF/com/android/metadata",
                      "".join(["%s=%s\n" % kv
                               for kv in sorted(metadata.iteritems())]))
 
-
-
-
 def LoadSystemFiles(z):
   """Load all the files from SYSTEM/... in a given target-files
   ZipFile, and return a dict of {filename: File object}."""