aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-05-29 12:59:35 -0700
committerKenny Root <kroot@google.com>2013-05-29 14:38:48 -0700
commite2e9f613b5259313c5216d4dad719998a2fbf014 (patch)
tree32d6a4a035dca79d150ab9fa77b38b7a26ca4b9e
parenta59f1b2590891271eedbe6ad8b5682bb5761e32a (diff)
downloadbuild-e2e9f613b5259313c5216d4dad719998a2fbf014.tar.gz
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
-rwxr-xr-xtools/releasetools/img_from_target_files8
-rwxr-xr-xtools/releasetools/ota_from_target_files9
2 files changed, 17 insertions, 0 deletions
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index a2aa2bc2f4..e894c42639 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -229,6 +229,14 @@ def main(argv):
OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
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")
+
output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
common.GetBootableImage(
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 170f5b30d8..e0d5d91a65 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -789,6 +789,15 @@ def main(argv):
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)