diff options
author | 2025-01-30 22:23:12 -0800 | |
---|---|---|
committer | 2025-01-30 22:23:12 -0800 | |
commit | a8cacac72a743b6c2d8a4480b3ae6619d22fb2d0 (patch) | |
tree | 80a404b78aacfcd340e37991ab92354b31cb156d | |
parent | 8057bac878c4f15923fab22db11d60bd82596145 (diff) | |
parent | 19fbb07dabf3a0a0836e6c4b36fd5584a2d1957b (diff) |
Merge "Fix staging dir creation for adevice" into main
-rw-r--r-- | android/module_context.go | 52 | ||||
-rw-r--r-- | android/packaging.go | 27 | ||||
-rw-r--r-- | filesystem/aconfig_files.go | 16 | ||||
-rw-r--r-- | filesystem/android_device.go | 2 | ||||
-rw-r--r-- | filesystem/android_device_product_out.go | 70 | ||||
-rw-r--r-- | filesystem/filesystem.go | 112 | ||||
-rw-r--r-- | filesystem/fsverity_metadata.go | 23 | ||||
-rw-r--r-- | filesystem/system_image.go | 17 |
8 files changed, 251 insertions, 68 deletions
diff --git a/android/module_context.go b/android/module_context.go index 1f4758c04..a3dad93f5 100644 --- a/android/module_context.go +++ b/android/module_context.go @@ -591,7 +591,7 @@ func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, na func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec { fullInstallPath := installPath.Join(m, name) - return m.packageFile(fullInstallPath, srcPath, false) + return m.packageFile(fullInstallPath, srcPath, false, false) } func (m *moduleContext) getAconfigPaths() Paths { @@ -615,7 +615,7 @@ func (m *moduleContext) getOwnerAndOverrides() (string, []string) { return owner, overrides } -func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec { +func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool, requiresFullInstall bool) PackagingSpec { licenseFiles := m.Module().EffectiveLicenseFiles() owner, overrides := m.getOwnerAndOverrides() spec := PackagingSpec{ @@ -630,6 +630,8 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e archType: m.target.Arch.ArchType, overrides: uniquelist.Make(overrides), owner: owner, + requiresFullInstall: requiresFullInstall, + fullInstallPath: fullInstallPath, } m.packagingSpecs = append(m.packagingSpecs, spec) return spec @@ -705,7 +707,7 @@ func (m *moduleContext) installFile(installPath InstallPath, name string, srcPat m.installFiles = append(m.installFiles, fullInstallPath) } - m.packageFile(fullInstallPath, srcPath, executable) + m.packageFile(fullInstallPath, srcPath, executable, m.requiresFullInstall()) if checkbuild { m.checkbuildFiles = append(m.checkbuildFiles, srcPath) @@ -755,16 +757,18 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src owner, overrides := m.getOwnerAndOverrides() m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{ - relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()), - srcPath: nil, - symlinkTarget: relPath, - executable: false, - partition: fullInstallPath.partition, - skipInstall: m.skipInstall(), - aconfigPaths: uniquelist.Make(m.getAconfigPaths()), - archType: m.target.Arch.ArchType, - overrides: uniquelist.Make(overrides), - owner: owner, + relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()), + srcPath: nil, + symlinkTarget: relPath, + executable: false, + partition: fullInstallPath.partition, + skipInstall: m.skipInstall(), + aconfigPaths: uniquelist.Make(m.getAconfigPaths()), + archType: m.target.Arch.ArchType, + overrides: uniquelist.Make(overrides), + owner: owner, + requiresFullInstall: m.requiresFullInstall(), + fullInstallPath: fullInstallPath, }) return fullInstallPath @@ -803,16 +807,18 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str owner, overrides := m.getOwnerAndOverrides() m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{ - relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()), - srcPath: nil, - symlinkTarget: absPath, - executable: false, - partition: fullInstallPath.partition, - skipInstall: m.skipInstall(), - aconfigPaths: uniquelist.Make(m.getAconfigPaths()), - archType: m.target.Arch.ArchType, - overrides: uniquelist.Make(overrides), - owner: owner, + relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()), + srcPath: nil, + symlinkTarget: absPath, + executable: false, + partition: fullInstallPath.partition, + skipInstall: m.skipInstall(), + aconfigPaths: uniquelist.Make(m.getAconfigPaths()), + archType: m.target.Arch.ArchType, + overrides: uniquelist.Make(overrides), + owner: owner, + requiresFullInstall: m.requiresFullInstall(), + fullInstallPath: fullInstallPath, }) return fullInstallPath diff --git a/android/packaging.go b/android/packaging.go index 738f215e9..d216c0c18 100644 --- a/android/packaging.go +++ b/android/packaging.go @@ -63,6 +63,15 @@ type PackagingSpec struct { // Name of the module where this packaging spec is output of owner string + + // If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use, + // for the soong-only migration. + requiresFullInstall bool + + // The path to the installed file in out/target/product. This is for legacy purposes, with + // tools that want to interact with these files outside of the build. You should not use it + // inside of the build. Will be nil if this module doesn't require a "full install". + fullInstallPath InstallPath } type packagingSpecGob struct { @@ -175,6 +184,24 @@ func (p *PackagingSpec) GetAconfigPaths() Paths { return p.aconfigPaths.ToSlice() } +// The path to the installed file in out/target/product. This is for legacy purposes, with +// tools that want to interact with these files outside of the build. You should not use it +// inside of the build. Will be nil if this module doesn't require a "full install". +func (p *PackagingSpec) FullInstallPath() InstallPath { + return p.fullInstallPath +} + +// If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use, +// for the soong-only migration. +func (p *PackagingSpec) RequiresFullInstall() bool { + return p.requiresFullInstall +} + +// The source file to be copied to the FullInstallPath. Do not use, for the soong-only migration. +func (p *PackagingSpec) SrcPath() Path { + return p.srcPath +} + type PackageModule interface { Module packagingBase() *PackagingBase 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 3e2f61f1b..6c048287b 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -210,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{ diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go index a6177e3fb..405d71034 100644 --- a/filesystem/android_device_product_out.go +++ b/filesystem/android_device_product_out.go @@ -16,7 +16,6 @@ package filesystem import ( "android/soong/android" - "fmt" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -36,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) { @@ -58,30 +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>image` will copy the files to // PRODUCT_OUT - ctx.Phony(info.ModuleName, dirStamp, imgInstallPath) if partition == "system_ext" { partition = "systemext" } - ctx.Phony(fmt.Sprintf("%simage", partition), dirStamp, imgInstallPath) + partition = partition + "imgage" + 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/filesystem.go b/filesystem/filesystem.go index 815113ea3..e3f3ce866 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. @@ -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]() @@ -485,13 +513,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 +569,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 +684,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 +736,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 @@ -1019,7 +1091,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 } @@ -1029,10 +1106,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 } @@ -1043,6 +1130,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) |