diff options
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 |