diff options
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/aconfig_files.go | 16 | ||||
-rw-r--r-- | filesystem/android_device.go | 24 | ||||
-rw-r--r-- | filesystem/android_device_product_out.go | 74 | ||||
-rw-r--r-- | filesystem/avb_add_hash_footer.go | 7 | ||||
-rw-r--r-- | filesystem/filesystem.go | 159 | ||||
-rw-r--r-- | filesystem/fsverity_metadata.go | 23 | ||||
-rw-r--r-- | filesystem/system_image.go | 17 |
7 files changed, 251 insertions, 69 deletions
diff --git a/filesystem/aconfig_files.go b/filesystem/aconfig_files.go index 9a3ca5408..6d034027d 100644 --- a/filesystem/aconfig_files.go +++ b/filesystem/aconfig_files.go @@ -34,7 +34,13 @@ type importAconfigDepDag struct { var importAconfigDependencyTag = interPartitionDepTag{} -func (f *filesystem) buildAconfigFlagsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, dir android.OutputPath) { +func (f *filesystem) buildAconfigFlagsFiles( + ctx android.ModuleContext, + builder *android.RuleBuilder, + specs map[string]android.PackagingSpec, + dir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { var caches []android.Path for _, ps := range specs { caches = append(caches, ps.GetAconfigPaths()...) @@ -70,6 +76,10 @@ func (f *filesystem) buildAconfigFlagsFiles(ctx android.ModuleContext, builder * for _, cache := range caches { cmd.FlagWithInput("--cache ", cache) } + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig_flags.pb"), + SourcePath: installAconfigFlagsPath, + }) f.appendToEntry(ctx, installAconfigFlagsPath) installAconfigStorageDir := dir.Join(ctx, "etc", "aconfig") @@ -90,6 +100,10 @@ func (f *filesystem) buildAconfigFlagsFiles(ctx android.ModuleContext, builder * FlagWithOutput("--out ", outputPath). FlagWithArg("--cache ", installAconfigFlagsPath.String()). FlagWithArg("--version ", strconv.Itoa(storageFilesVersion)) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig", fileName), + SourcePath: outputPath, + }) f.appendToEntry(ctx, outputPath) } diff --git a/filesystem/android_device.go b/filesystem/android_device.go index eb2e0367a..6c048287b 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -15,6 +15,7 @@ package filesystem import ( + "fmt" "strings" "sync/atomic" @@ -150,7 +151,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { } } - a.buildTargetFilesZip(ctx) + //a.buildTargetFilesZip(ctx) TODO(b/393203512): re-enable target_files.zip var deps []android.Path if proptools.String(a.partitionProps.Super_partition_name) != "" { superImage := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag) @@ -209,7 +210,7 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/main.mk;l=1396;drc=6595459cdd8164a6008335f6372c9f97b9094060 ctx.Phony("droidcore-unbundled", allImagesStamp) - validations = append(validations, a.copyFilesToProductOutForSoongOnly(ctx)) + deps = append(deps, a.copyFilesToProductOutForSoongOnly(ctx)) } ctx.Build(pctx, android.BuildParams{ @@ -221,6 +222,8 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Checkbuilding it causes soong to make a phony, so you can say `m <module name>` ctx.CheckbuildFile(allImagesStamp) + + a.setVbmetaPhonyTargets(ctx) } // Helper structs for target_files.zip creation @@ -406,3 +409,20 @@ func (a *androidDevice) getFilesystemInfo(ctx android.ModuleContext, depName str } return fsInfo } + +func (a *androidDevice) setVbmetaPhonyTargets(ctx android.ModuleContext) { + if !proptools.Bool(a.deviceProps.Main_device) { + return + } + + if !ctx.Config().KatiEnabled() { + for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions { + img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag) + if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok { + // make generates `vbmetasystemimage` phony target instead of `vbmeta_systemimage` phony target. + partitionName := strings.ReplaceAll(provider.Name, "_", "") + ctx.Phony(fmt.Sprintf("%simage", partitionName), provider.Output) + } + } + } +} diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go index 916c45adc..1175c428c 100644 --- a/filesystem/android_device_product_out.go +++ b/filesystem/android_device_product_out.go @@ -35,18 +35,6 @@ func (a *androidDevice) copyToProductOut(ctx android.ModuleContext, builder *and func (a *androidDevice) copyFilesToProductOutForSoongOnly(ctx android.ModuleContext) android.Path { filesystemInfos := a.getFsInfos(ctx) - // The current logic to copy the staging directories to PRODUCT_OUT isn't very sound. - // We only track dependencies on the image file, so if the image file wasn't changed, the - // staging directory won't be re-copied. If you do an installclean, it would remove the copied - // staging directories but not affect the intermediates path image file, so the next build - // wouldn't re-copy them. As a hack, create a presence detector that would be deleted on - // an installclean to use as a dep for the staging dir copies. - productOutPresenceDetector := android.PathForModuleInPartitionInstall(ctx, "", "product_out_presence_detector.txt") - ctx.Build(pctx, android.BuildParams{ - Rule: android.Touch, - Output: productOutPresenceDetector, - }) - var deps android.Paths for _, partition := range android.SortedKeys(filesystemInfos) { @@ -57,27 +45,53 @@ func (a *androidDevice) copyFilesToProductOutForSoongOnly(ctx android.ModuleCont Input: info.Output, Output: imgInstallPath, }) - dirStamp := android.PathForModuleOut(ctx, partition+"_staging_dir_copy_stamp.txt") - dirInstallPath := android.PathForModuleInPartitionInstall(ctx, "", partition) - ctx.Build(pctx, android.BuildParams{ - Rule: copyStagingDirRule, - Output: dirStamp, - Implicits: []android.Path{ - info.Output, - productOutPresenceDetector, - }, - Args: map[string]string{ - "dir": info.RebasedDir.String(), - "dest": dirInstallPath.String(), - }, - }) - // Make it so doing `m <moduleName>` or `m <partitionType>` will copy the files to + // Make it so doing `m <moduleName>` or `m <partitionType>image` will copy the files to // PRODUCT_OUT - ctx.Phony(info.ModuleName, dirStamp, imgInstallPath) - ctx.Phony(partition, dirStamp, imgInstallPath) + if partition == "system_ext" { + partition = "systemext" + } + partition = partition + "image" + ctx.Phony(info.ModuleName, imgInstallPath) + ctx.Phony(partition, imgInstallPath) + for _, fip := range info.FullInstallPaths { + // TODO: Directories. But maybe they're not necessary? Adevice doesn't care + // about empty directories, still need to check if adb sync does. + if !fip.IsDir { + if !fip.RequiresFullInstall { + // Some modules set requires_full_install: false, which causes their staging + // directory file to not be installed. This is usually because the file appears + // in both PRODUCT_COPY_FILES and a soong module for the handwritten soong system + // image. In this case, that module's installed files would conflict with the + // PRODUCT_COPY_FILES. However, in soong-only builds, we don't automatically + // create rules for PRODUCT_COPY_FILES unless they're needed in the partition. + // So in that case, nothing is creating the installed path. Create them now + // if that's the case. + if fip.SymlinkTarget == "" { + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Input: fip.SourcePath, + Output: fip.FullInstallPath, + }) + } else { + ctx.Build(pctx, android.BuildParams{ + Rule: android.SymlinkWithBash, + Output: fip.FullInstallPath, + Args: map[string]string{ + "fromPath": fip.SymlinkTarget, + }, + }) + } + } + ctx.Phony(info.ModuleName, fip.FullInstallPath) + ctx.Phony(partition, fip.FullInstallPath) + deps = append(deps, fip.FullInstallPath) + ctx.Phony("sync_"+partition, fip.FullInstallPath) + ctx.Phony("sync", fip.FullInstallPath) + } + } - deps = append(deps, imgInstallPath, dirStamp) + deps = append(deps, imgInstallPath) } // List all individual files to be copied to PRODUCT_OUT here diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go index 9d4ba3e95..f32993c4b 100644 --- a/filesystem/avb_add_hash_footer.go +++ b/filesystem/avb_add_hash_footer.go @@ -46,7 +46,7 @@ type avbProp struct { type avbAddHashFooterProperties struct { // Source file of this image. Can reference a genrule type module with the ":module" syntax. - Src *string `android:"path,arch_variant"` + Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"` // Set the name of the output. Defaults to <module_name>.img. Filename *string @@ -91,12 +91,13 @@ func (a *avbAddHashFooter) installFileName() string { func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext) { builder := android.NewRuleBuilder(pctx, ctx) + src := a.properties.Src.GetOrDefault(ctx, "") - if a.properties.Src == nil { + if src == "" { ctx.PropertyErrorf("src", "missing source file") return } - input := android.PathForModuleSrc(ctx, proptools.String(a.properties.Src)) + input := android.PathForModuleSrc(ctx, src) output := android.PathForModuleOut(ctx, a.installFileName()) builder.Command().Text("cp").Input(input).Output(output) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 357ec32ba..0ce31b293 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -79,7 +79,7 @@ type filesystem struct { } type filesystemBuilder interface { - BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) + BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath, fullInstallPaths *[]FullInstallPathInfo) // Function that filters PackagingSpec in PackagingBase.GatherPackagingSpecs() FilterPackagingSpec(spec android.PackagingSpec) bool // Function that modifies PackagingSpec in PackagingBase.GatherPackagingSpecs() to customize. @@ -119,7 +119,7 @@ type FilesystemProperties struct { Avb_algorithm *string // Hash algorithm used for avbtool (for descriptors). This is passed as hash_algorithm to - // avbtool. Default used by avbtool is sha1. + // avbtool. Default is sha256. Avb_hash_algorithm *string // The security patch passed to as the com.android.build.<type>.security_patch avb property. @@ -389,6 +389,34 @@ type FilesystemInfo struct { BuildImagePropFileDeps android.Paths // Packaging specs to be installed on the system_other image, for the initial boot's dexpreopt. SpecsForSystemOther map[string]android.PackagingSpec + + FullInstallPaths []FullInstallPathInfo +} + +// FullInstallPathInfo contains information about the "full install" paths of all the files +// inside this partition. The full install paths are the files installed in +// out/target/product/<device>/<partition>. This is essentially legacy behavior, maintained for +// tools like adb sync and adevice, but we should update them to query the build system for the +// installed files no matter where they are. +type FullInstallPathInfo struct { + // RequiresFullInstall tells us if the origional module did the install to FullInstallPath + // already. If it's false, the android_device module needs to emit the install rule. + RequiresFullInstall bool + // The "full install" paths for the files in this filesystem. This is the paths in the + // out/target/product/<device>/<partition> folder. They're not used by this filesystem, + // but can be depended on by the top-level android_device module to cause the staging + // directories to be built. + FullInstallPath android.InstallPath + + // The file that's copied to FullInstallPath. May be nil if SymlinkTarget is set or IsDir is + // true. + SourcePath android.Path + + // The target of the symlink, if this file is a symlink. + SymlinkTarget string + + // If this file is a directory. Only used for empty directories, which are mostly mount points. + IsDir bool } var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]() @@ -441,6 +469,13 @@ func (f *filesystem) FilterPackagingSpec(ps android.PackagingSpec) bool { if ps.SkipInstall() { return false } + // "apex" is a fake partition used to install files in out/target/product/<device>/apex/. + // Don't include these files in the partition. We should also look into removing the following + // TODO to check the PackagingSpec's partition against this filesystem's partition for all + // modules, not just autogenerated ones, which will fix this as well. + if ps.Partition() == "apex" { + return false + } if proptools.Bool(f.properties.Is_auto_generated) { // TODO (spandandas): Remove this. pt := f.PartitionType() return ps.Partition() == pt || strings.HasPrefix(ps.Partition(), pt+"/") @@ -485,13 +520,23 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Wipe the root dir to get rid of leftover files from prior builds builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir) specs := f.gatherFilteredPackagingSpecs(ctx) - f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir) - f.buildNonDepsFiles(ctx, builder, rootDir) - f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir) - f.buildEventLogtagsFile(ctx, builder, rebasedDir) - f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir) - f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir) + var fullInstallPaths []FullInstallPathInfo + for _, spec := range specs { + fullInstallPaths = append(fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: spec.FullInstallPath(), + RequiresFullInstall: spec.RequiresFullInstall(), + SourcePath: spec.SrcPath(), + SymlinkTarget: spec.ToGob().SymlinkTarget, + }) + } + + f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir) + f.buildNonDepsFiles(ctx, builder, rootDir, rebasedDir, &fullInstallPaths) + f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir, &fullInstallPaths) + f.buildEventLogtagsFile(ctx, builder, rebasedDir, &fullInstallPaths) + f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir, &fullInstallPaths) + f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir, &fullInstallPaths) var mapFile android.Path var outputHermetic android.Path @@ -531,6 +576,7 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { BuildImagePropFile: buildImagePropFile, BuildImagePropFileDeps: buildImagePropFileDeps, SpecsForSystemOther: f.systemOtherFiles(ctx), + FullInstallPaths: fullInstallPaths, } android.SetProvider(ctx, FilesystemProvider, fsInfo) @@ -645,11 +691,36 @@ func validatePartitionType(ctx android.ModuleContext, p partition) { // Copy extra files/dirs that are not from the `deps` property to `rootDir`, checking for conflicts with files // already in `rootDir`. -func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.OutputPath) { +func (f *filesystem) buildNonDepsFiles( + ctx android.ModuleContext, + builder *android.RuleBuilder, + rootDir android.OutputPath, + rebasedDir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { + rebasedPrefix, err := filepath.Rel(rootDir.String(), rebasedDir.String()) + if err != nil || strings.HasPrefix(rebasedPrefix, "../") { + panic("rebasedDir could not be made relative to rootDir") + } + if !strings.HasSuffix(rebasedPrefix, "/") { + rebasedPrefix += "/" + } + if rebasedPrefix == "./" { + rebasedPrefix = "" + } + // create dirs and symlinks for _, dir := range f.properties.Dirs.GetOrDefault(ctx, nil) { // OutputPath.Join verifies dir builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, dir).String()) + // Only add the fullInstallPath logic for files in the rebased dir. The root dir + // is harder to install to. + if strings.HasPrefix(dir, rebasedPrefix) { + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), strings.TrimPrefix(dir, rebasedPrefix)), + IsDir: true, + }) + } } for _, symlink := range f.properties.Symlinks { @@ -672,6 +743,14 @@ func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *andro builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String())) builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String()) f.appendToEntry(ctx, dst) + // Only add the fullInstallPath logic for files in the rebased dir. The root dir + // is harder to install to. + if strings.HasPrefix(name, rebasedPrefix) { + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), strings.TrimPrefix(name, rebasedPrefix)), + SymlinkTarget: target, + }) + } } // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2835;drc=b186569ef00ff2f2a1fab28aedc75ebc32bcd67b @@ -738,22 +817,23 @@ func (f *filesystem) buildImageUsingBuildImage( Output(output). Text(rootDir.String()) // directory where to find fs_config_files|dirs + // TODO (b/393203512): Re-enable hermetic img file creation for target_files.zip // Add an additional cmd to create a hermetic img file. This will contain pinned timestamps e.g. - propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop") - builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp). - Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp). - Textf(" && echo block_list=%s >> %s", f.getMapFile(ctx).String(), propFilePinnedTimestamp) // mapfile will be an implicit output - - outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName()) - builder.Command(). - Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")). - BuiltTool("build_image"). - Text(rootDir.String()). // input directory - Flag(propFilePinnedTimestamp.String()). - Implicits(toolDeps). - Implicit(fec). - Output(outputHermetic). - Text(rootDir.String()) // directory where to find fs_config_files|dirs + //propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop") + //builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp). + // Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp). + // Textf(" && echo block_list=%s >> %s", f.getMapFile(ctx).String(), propFilePinnedTimestamp) // mapfile will be an implicit output + + //outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName()) + //builder.Command(). + // Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")). + // BuiltTool("build_image"). + // Text(rootDir.String()). // input directory + // Flag(propFilePinnedTimestamp.String()). + // Implicits(toolDeps). + // Implicit(fec). + // Output(outputHermetic). + // Text(rootDir.String()) // directory where to find fs_config_files|dirs if f.properties.Partition_size != nil { assertMaxImageSize(builder, output, *f.properties.Partition_size, false) @@ -762,7 +842,7 @@ func (f *filesystem) buildImageUsingBuildImage( // rootDir is not deleted. Might be useful for quick inspection. builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName())) - return output, outputHermetic, propFile, toolDeps + return output, nil, propFile, toolDeps } func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path { @@ -823,9 +903,8 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and if !proptools.BoolDefault(f.properties.Use_fec, true) { avb_add_hashtree_footer_args += " --do_not_generate_fec" } - if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" { - avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm - } + hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256") + avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm if f.properties.Rollback_index != nil { rollbackIndex := proptools.Int(f.properties.Rollback_index) if rollbackIndex < 0 { @@ -1018,7 +1097,12 @@ var validPartitions = []string{ "recovery", } -func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) { +func (f *filesystem) buildEventLogtagsFile( + ctx android.ModuleContext, + builder *android.RuleBuilder, + rebasedDir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { if !proptools.Bool(f.properties.Build_logtags) { return } @@ -1028,10 +1112,20 @@ func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *a builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String()) builder.Command().Text("cp").Input(android.MergedLogtagsPath(ctx)).Text(eventLogtagsPath.String()) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc", "event-log-tags"), + SourcePath: android.MergedLogtagsPath(ctx), + }) + f.appendToEntry(ctx, eventLogtagsPath) } -func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) { +func (f *filesystem) BuildLinkerConfigFile( + ctx android.ModuleContext, + builder *android.RuleBuilder, + rebasedDir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { if !proptools.Bool(f.properties.Linker_config.Gen_linker_config) { return } @@ -1042,6 +1136,11 @@ func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *a output := rebasedDir.Join(ctx, "etc", "linker.config.pb") builder.Command().Text("cp").Input(intermediateOutput).Output(output) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc", "linker.config.pb"), + SourcePath: intermediateOutput, + }) + f.appendToEntry(ctx, output) } diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go index c3f19363e..a3a2086ce 100644 --- a/filesystem/fsverity_metadata.go +++ b/filesystem/fsverity_metadata.go @@ -44,7 +44,14 @@ func (f *filesystem) writeManifestGeneratorListFile(ctx android.ModuleContext, o android.WriteFileRuleVerbatim(ctx, outputPath, buf.String()) } -func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir android.OutputPath, rebasedDir android.OutputPath) { +func (f *filesystem) buildFsverityMetadataFiles( + ctx android.ModuleContext, + builder *android.RuleBuilder, + specs map[string]android.PackagingSpec, + rootDir android.OutputPath, + rebasedDir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { match := func(path string) bool { for _, pattern := range f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) { if matched, err := filepath.Match(pattern, path); matched { @@ -82,9 +89,13 @@ func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, build FlagWithInput("--fsverity-path ", fsverityPath). FlagWithArg("--signature ", "none"). FlagWithArg("--hash-alg ", "sha256"). - FlagWithArg("--output ", destPath.String()). + FlagWithOutput("--output ", destPath). Text(srcPath.String()) f.appendToEntry(ctx, destPath) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + SourcePath: destPath, + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), spec.RelPathInPackage()+".fsv_meta"), + }) } fsVerityBaseDir := rootDir.String() @@ -148,6 +159,10 @@ func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, build FlagWithArg("--version-name ", ctx.Config().AppsDefaultVersionName()). FlagWithInput("--manifest ", manifestTemplatePath). Text(" --rename-manifest-package com.android.security.fsverity_metadata." + f.partitionName()) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + SourcePath: apkPath, + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), fmt.Sprintf("etc/security/fsverity/BuildManifest%s.apk", apkNameSuffix)), + }) f.appendToEntry(ctx, apkPath) @@ -160,6 +175,10 @@ func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, build FlagWithInput("--cert ", pemPath). FlagWithInput("--key ", keyPath). ImplicitOutput(idsigPath) + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + SourcePath: idsigPath, + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), fmt.Sprintf("etc/security/fsverity/BuildManifest%s.apk.idsig", apkNameSuffix)), + }) f.appendToEntry(ctx, idsigPath) } diff --git a/filesystem/system_image.go b/filesystem/system_image.go index 874d20d80..cc9093f9b 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -44,7 +44,12 @@ func (s systemImage) FsProps() FilesystemProperties { return s.filesystem.properties } -func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) { +func (s *systemImage) BuildLinkerConfigFile( + ctx android.ModuleContext, + builder *android.RuleBuilder, + rebasedDir android.OutputPath, + fullInstallPaths *[]FullInstallPathInfo, +) { if !proptools.Bool(s.filesystem.properties.Linker_config.Gen_linker_config) { return } @@ -55,6 +60,11 @@ func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder * intermediateOutput := android.PathForModuleOut(ctx, "linker.config.pb") linkerconfig.BuildLinkerConfig(ctx, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, intermediateOutput) builder.Command().Text("cp").Input(intermediateOutput).Output(output) + + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, s.PartitionType(), "etc", "linker.config.pb"), + SourcePath: intermediateOutput, + }) } else { // TODO: This branch is the logic that make uses for the linker config file, which is // different than linkerconfig.BuildLinkerConfig used above. Keeping both branches for now @@ -87,6 +97,11 @@ func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder * Implicit(llndkMovedToApexLibraries) // TODO: Make also supports adding an extra append command with PRODUCT_EXTRA_STUB_LIBRARIES, // but that variable appears to have no usages. + + *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{ + FullInstallPath: android.PathForModuleInPartitionInstall(ctx, s.PartitionType(), "etc", "linker.config.pb"), + SourcePath: output, + }) } s.appendToEntry(ctx, output) |