diff options
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r-- | filesystem/filesystem.go | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 1d32b8f70..2244aff57 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -121,6 +121,9 @@ type FilesystemProperties struct { // avbtool. Default used by avbtool is sha1. Avb_hash_algorithm *string + // The security patch passed to as the com.android.build.<type>.security_patch avb property. + Security_patch *string + // Whether or not to use forward-error-correction codes when signing with AVB. Defaults to true. Use_fec *bool @@ -178,6 +181,11 @@ type FilesystemProperties struct { // Install aconfig_flags.pb file for the modules installed in this partition. Gen_aconfig_flags_pb *bool + // List of names of other filesystem partitions to import their aconfig flags from. + // This is used for the system partition to import system_ext's aconfig flags, as currently + // those are considered one "container": aosp/3261300 + Import_aconfig_flags_from []string + Fsverity fsverityProperties // If this property is set to true, the filesystem will call ctx.UncheckedModule(), causing @@ -306,6 +314,9 @@ func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) { if f.properties.Android_filesystem_deps.System_ext != nil { ctx.AddDependency(ctx.Module(), interPartitionDependencyTag, proptools.String(f.properties.Android_filesystem_deps.System_ext)) } + for _, partition := range f.properties.Import_aconfig_flags_from { + ctx.AddDependency(ctx.Module(), importAconfigDependencyTag, partition) + } } type fsType int @@ -465,7 +476,7 @@ func (f *filesystem) validateVintfFragments(ctx android.ModuleContext) { } func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.Path) { - partitionBaseDir := android.PathForModuleOut(ctx, "root", proptools.String(f.properties.Base_dir)).String() + "/" + partitionBaseDir := android.PathForModuleOut(ctx, f.rootDirString(), proptools.String(f.properties.Base_dir)).String() + "/" relPath, inTargetPartition := strings.CutPrefix(installedFile.String(), partitionBaseDir) if inTargetPartition { @@ -526,6 +537,12 @@ func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *andro builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String()) f.appendToEntry(ctx, dst) } + + // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2835;drc=b186569ef00ff2f2a1fab28aedc75ebc32bcd67b + if f.partitionName() == "recovery" { + builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, "root/linkerconfig").String()) + builder.Command().Text("touch").Text(rootDir.Join(ctx, "root/linkerconfig/ld.config.txt").String()) + } } func (f *filesystem) copyPackagingSpecs(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir, rebasedDir android.WritablePath) []string { @@ -555,8 +572,12 @@ func (f *filesystem) copyFilesToProductOut(ctx android.ModuleContext, builder *a builder.Command().Textf("cp -prf %s/* %s", rebasedDir, installPath) } +func (f *filesystem) rootDirString() string { + return f.partitionName() +} + func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) android.Path { - rootDir := android.PathForModuleOut(ctx, "root").OutputPath + rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath rebasedDir := rootDir if f.properties.Base_dir != nil { rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir) @@ -599,6 +620,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) androi Input(propFile). Implicits(toolDeps). Implicit(fec). + FlagWithArg("--build_datetime_file ", ctx.Config().Getenv("BUILD_DATETIME_FILE")). Output(output). Text(rootDir.String()) // directory where to find fs_config_files|dirs @@ -618,11 +640,6 @@ func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path { return fcBin } -// Calculates avb_salt from entry list (sorted) for deterministic output. -func (f *filesystem) salt() string { - return sha1sum(f.entries) -} - func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, android.Paths) { var deps android.Paths var propFileString strings.Builder @@ -685,10 +702,14 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex) } avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable()) + // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because + // the build number changed, and we don't want to trigger rebuilds solely based on the build + // number. avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx)) - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), ctx.Config().PlatformSecurityPatch()) + if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" { + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch)) + } addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args) - addStr("avb_salt", f.salt()) } if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil { @@ -741,10 +762,9 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and android.WriteFileRuleVerbatim(ctx, propFilePreProcessing, propFileString.String()) propFile := android.PathForModuleOut(ctx, "prop") ctx.Build(pctx, android.BuildParams{ - Rule: textFileProcessorRule, - Input: propFilePreProcessing, - Output: propFile, - Implicit: ctx.Config().BuildFingerprintFile(ctx), + Rule: textFileProcessorRule, + Input: propFilePreProcessing, + Output: propFile, }) return propFile, deps } @@ -783,7 +803,7 @@ func (f *filesystem) buildCpioImage(ctx android.ModuleContext, compressed bool) ctx.PropertyErrorf("include_make_built_files", "include_make_built_files is not supported for compressed cpio image.") } - rootDir := android.PathForModuleOut(ctx, "root").OutputPath + rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath rebasedDir := rootDir if f.properties.Base_dir != nil { rebasedDir = rootDir.Join(ctx, *f.properties.Base_dir) @@ -868,29 +888,10 @@ func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *a return } - logtagsFilePaths := make(map[string]bool) - ctx.WalkDeps(func(child, parent android.Module) bool { - if logtagsInfo, ok := android.OtherModuleProvider(ctx, child, android.LogtagsProviderKey); ok { - for _, path := range logtagsInfo.Logtags { - logtagsFilePaths[path.String()] = true - } - } - return true - }) - - if len(logtagsFilePaths) == 0 { - return - } - etcPath := rebasedDir.Join(ctx, "etc") eventLogtagsPath := etcPath.Join(ctx, "event-log-tags") builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String()) - cmd := builder.Command().BuiltTool("merge-event-log-tags"). - FlagWithArg("-o ", eventLogtagsPath.String()) - - for _, path := range android.SortedKeys(logtagsFilePaths) { - cmd.Text(path) - } + builder.Command().Text("cp").Input(android.MergedLogtagsPath(ctx)).Text(eventLogtagsPath.String()) f.appendToEntry(ctx, eventLogtagsPath) } @@ -901,8 +902,10 @@ func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *a } provideModules, _ := f.getLibsForLinkerConfig(ctx) + intermediateOutput := android.PathForModuleOut(ctx, "linker.config.pb") + linkerconfig.BuildLinkerConfig(ctx, android.PathsForModuleSrc(ctx, f.properties.Linker_config.Linker_config_srcs), provideModules, nil, intermediateOutput) output := rebasedDir.Join(ctx, "etc", "linker.config.pb") - linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linker_config.Linker_config_srcs), provideModules, nil, output) + builder.Command().Text("cp").Input(intermediateOutput).Output(output) f.appendToEntry(ctx, output) } @@ -1092,6 +1095,12 @@ func addAutogeneratedRroDeps(ctx android.BottomUpMutatorContext) { } thisPartition := f.PartitionType() if thisPartition != "vendor" && thisPartition != "product" { + if f.properties.Android_filesystem_deps.System != nil { + ctx.PropertyErrorf("android_filesystem_deps.system", "only vendor or product partitions can use android_filesystem_deps") + } + if f.properties.Android_filesystem_deps.System_ext != nil { + ctx.PropertyErrorf("android_filesystem_deps.system_ext", "only vendor or product partitions can use android_filesystem_deps") + } return } ctx.WalkDeps(func(child, parent android.Module) bool { |