apex: add / in file_contexts as system_file

apex_manifest.pb is added to payload.img by the build system and is
supposed to be read by apexd during activation.

So, / and /apex_manifest.pb should be labeled as "system_file" so
that apexd can read it regardless of how file_contexts is defined.

580eb4fe38 adds /apex_manifest.pb and this
change adds / as well to file_contexts.

Bug: 159767275
Test: add an apex with file_contexts with everything as vendor_file
      apexd should activate the apex.
Change-Id: I827fa3af49ca7f20f3f82fcb16868f60d94d9531
This commit is contained in:
Jooyung Han
2020-06-29 14:54:22 +09:00
parent 0c6f111d7b
commit 2dfd54d07e

View File

@@ -255,10 +255,15 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) {
output := android.PathForModuleOut(ctx, "file_contexts")
rule := android.NewRuleBuilder()
// remove old file
rule.Command().Text("rm").FlagWithOutput("-f ", output)
// copy file_contexts
rule.Command().Text("cat").Input(fileContexts).Text(">>").Output(output)
// new line
rule.Command().Text("echo").Text(">>").Output(output)
// force-label /apex_manifest.pb and / as system_file so that apexd can read them
rule.Command().Text("echo").Flag("/apex_manifest\\\\.pb u:object_r:system_file:s0").Text(">>").Output(output)
rule.Command().Text("echo").Flag("/ u:object_r:system_file:s0").Text(">>").Output(output)
rule.Build(pctx, ctx, "file_contexts."+a.Name(), "Generate file_contexts")
a.fileContexts = output.OutputPath