Fix signing process for SELinux file_contexts
When not building locally and just using a target-files.zip from some
other build, it still tries to access the file_contexts from the out/
directory. This change instead looks at the unzipped target-files.zip
hierarchy to grab that information.
Bug: 9191141
Change-Id: I6ea12e82d6c6376fcada412314c5eefc97ff4853
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 170f5b3..e0d5d91 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -789,6 +789,15 @@
OPTIONS.target_tmp = OPTIONS.input_tmp
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")
+
if OPTIONS.verbose:
print "--- target info ---"
common.DumpInfoDict(OPTIONS.info_dict)