From 2dfd54d07e160bae670647b8c9dab30c54360ab2 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Mon, 29 Jun 2020 14:54:22 +0900 Subject: [PATCH] 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 --- apex/builder.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apex/builder.go b/apex/builder.go index ede11d05e..5fb9a5fd4 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -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