Pack file_contexts into target_files zip.
file_contexts (specified by SELINUX_FC) is needed both when building
and (re)packaging. We used to use the copy in out/ when building, and
looked for the copy in BOOT/RAMDISK/ when packaging from target_files
zip. With system_root_image enabled, the file_contexts needed for
building and packaging might be different from the one on device. So
we explicitly pack the file as META/file_contexts in target_files zip.
Also refactor out the overriding of selinux_fc property into
common.LoadInfoDict().
Change-Id: I94f9ea6671b3792c12c1c21573840743d63da39a
(cherry picked from commit aa7318c3849095aeb3bea00efbf303c0c40a089d)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index c486992..608aad1 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -95,16 +95,7 @@
# images, so build them.
import add_img_to_target_files
- OPTIONS.info_dict = common.LoadInfoDict(input_zip)
-
- # If this image was originally labelled with SELinux contexts,
- # make sure we also apply the labels in our new image. During
- # building, the "file_contexts" is in the out/ directory tree,
- # but for repacking from target-files.zip it's in the root
- # directory of the ramdisk.
- if "selinux_fc" in OPTIONS.info_dict:
- OPTIONS.info_dict["selinux_fc"] = os.path.join(
- OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts")
+ OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
boot_image = common.GetBootableImage(
"boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")