diff options
author | 2020-06-24 19:33:06 +0900 | |
---|---|---|
committer | 2020-06-24 23:00:32 +0900 | |
commit | 580eb4fe38cd71c93b47274f19d9ae3d5d47d4ea (patch) | |
tree | 75c952d4c16ce3a2ba75436023290eed60fe7ea1 /apex/builder.go | |
parent | c487ae15ba747ba06c0c72f357228bb933811629 (diff) |
apex: add apex_manifest.pb in file_contexts
apex_manifest.pb is added to payload.img by the build system and is
supposed to be read by apexd during activation.
So, it should be labeled as "system_file" so that apexd can read it
regardless of how file_contexts is defined.
Bug: 159767275
Test: add an apex with file_contexts with everything as vendor_file
apexd should activate the apex.
Change-Id: Ie34eb7ad905828976152d67a7dfabf0add0a5de4
Diffstat (limited to 'apex/builder.go')
-rw-r--r-- | apex/builder.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/apex/builder.go b/apex/builder.go index af43417aa..ac3e64015 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -17,6 +17,7 @@ package apex import ( "encoding/json" "fmt" + "path" "path/filepath" "runtime" "sort" @@ -231,6 +232,38 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, }) } +func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) { + if a.properties.ApexType == zipApex { + return + } + var fileContexts android.Path + if a.properties.File_contexts == nil { + fileContexts = android.PathForSource(ctx, "system/sepolicy/apex", ctx.ModuleName()+"-file_contexts") + } else { + fileContexts = android.PathForModuleSrc(ctx, *a.properties.File_contexts) + } + if a.Platform() { + if matched, err := path.Match("system/sepolicy/**/*", fileContexts.String()); err != nil || !matched { + ctx.PropertyErrorf("file_contexts", "should be under system/sepolicy, but %q", fileContexts) + return + } + } + if !android.ExistentPathForSource(ctx, fileContexts.String()).Valid() { + ctx.PropertyErrorf("file_contexts", "cannot find file_contexts file: %q", a.fileContexts) + return + } + + output := android.PathForModuleOut(ctx, "file_contexts") + rule := android.NewRuleBuilder() + rule.Command().Text("rm").FlagWithOutput("-f ", output) + rule.Command().Text("cat").Input(fileContexts).Text(">>").Output(output) + rule.Command().Text("echo").Text(">>").Output(output) + rule.Command().Text("echo").Flag("/apex_manifest\\\\.pb u:object_r:system_file:s0").Text(">>").Output(output) + rule.Build(pctx, ctx, "file_contexts."+a.Name(), "Generate file_contexts") + + a.fileContexts = output.OutputPath +} + func (a *apexBundle) buildNoticeFiles(ctx android.ModuleContext, apexFileName string) android.NoticeOutputs { var noticeFiles android.Paths |