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.
580eb4fe38cd71c93b47274f19d9ae3d5d47d4ea 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
diff --git a/apex/builder.go b/apex/builder.go
index ede11d0..5fb9a5f 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -255,10 +255,15 @@
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