diff options
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/android_device.go | 9 | ||||
-rw-r--r-- | filesystem/avb_add_hash_footer.go | 7 | ||||
-rw-r--r-- | filesystem/filesystem.go | 4 | ||||
-rw-r--r-- | filesystem/filesystem_test.go | 23 | ||||
-rw-r--r-- | filesystem/system_other.go | 7 | ||||
-rw-r--r-- | filesystem/vbmeta.go | 54 |
6 files changed, 98 insertions, 6 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 690b9e1be..feb000dc4 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -840,6 +840,15 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { Textf("echo avb_enable=true >> %s", miscInfo). Textf("&& echo avb_building_vbmeta_image=true >> %s", miscInfo). Textf("&& echo avb_avbtool=avbtool >> %s", miscInfo) + for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions { + img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag) + if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok { + builder.Command().Text("cat").Input(provider.PropFileForMiscInfo).Textf(" >> %s", miscInfo) + } else { + ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", vbmetaPartitionName) + } + } + } if a.partitionProps.Boot_partition_name != nil { builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo) diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go index 327a41fda..c7760120d 100644 --- a/filesystem/avb_add_hash_footer.go +++ b/filesystem/avb_add_hash_footer.go @@ -70,7 +70,7 @@ type avbAddHashFooterProperties struct { Props []avbProp // The index used to prevent rollback of the image on device. - Rollback_index *int64 + Rollback_index proptools.Configurable[int64] `android:"replace_instead_of_append"` // Include descriptors from images Include_descriptors_from_images []string `android:"path,arch_variant"` @@ -134,8 +134,9 @@ func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext addAvbProp(ctx, cmd, prop) } - if a.properties.Rollback_index != nil { - rollbackIndex := proptools.Int(a.properties.Rollback_index) + rollbackIndex := a.properties.Rollback_index.Get(ctx) + if rollbackIndex.IsPresent() { + rollbackIndex := rollbackIndex.Get() if rollbackIndex < 0 { ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative") } diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 411770be9..e86ebf4fa 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -1569,7 +1569,7 @@ func (f *filesystem) getLibsForLinkerConfig(ctx android.ModuleContext) ([]androi deps := f.gatherFilteredPackagingSpecs(ctx) ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { - if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled { + if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled { return false } for _, ps := range android.OtherModuleProviderOrDefault( @@ -1590,7 +1590,7 @@ func (f *filesystem) getLibsForLinkerConfig(ctx android.ModuleContext) ([]androi var requireModules []android.ModuleProxy ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { - if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled { + if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled { return false } _, parentInPackage := modulesInPackageByModule[parent] diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index 6d0b49016..bf7f5b64b 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -723,26 +723,47 @@ cc_library { // override_android_* modules implicitly override their base module. // If both of these are listed in `deps`, the base module should not be installed. +// Also, required deps should be updated too. func TestOverrideModulesInDeps(t *testing.T) { result := fixture.RunTestWithBp(t, ` + cc_library_shared { + name: "libfoo", + stl: "none", + system_shared_libs: [], + } + cc_library_shared { + name: "libbar", + stl: "none", + system_shared_libs: [], + } android_filesystem { name: "myfilesystem", + deps: ["myapp"], + } + android_filesystem { + name: "myfilesystem_overridden", deps: ["myapp", "myoverrideapp"], } android_app { name: "myapp", platform_apis: true, + required: ["libfoo"], } override_android_app { name: "myoverrideapp", base: "myapp", + required: ["libbar"], } `) partition := result.ModuleForTests(t, "myfilesystem", "android_common") fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) - android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\n", fileList) + android.AssertStringEquals(t, "filesystem without override app", "app/myapp/myapp.apk\nlib64/libfoo.so\n", fileList) + + overriddenPartition := result.ModuleForTests(t, "myfilesystem_overridden", "android_common") + overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) + android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) } func TestRamdiskPartitionSetsDevNodes(t *testing.T) { diff --git a/filesystem/system_other.go b/filesystem/system_other.go index 348c01035..32a6cc784 100644 --- a/filesystem/system_other.go +++ b/filesystem/system_other.go @@ -120,8 +120,11 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext // TOOD: CopySpecsToDir only exists on PackagingBase, but doesn't use any fields from it. Clean this up. (&android.PackagingBase{}).CopySpecsToDir(ctx, builder, specs, stagingDir) + fullInstallPaths := []string{} if len(m.properties.Preinstall_dexpreopt_files_from) > 0 { builder.Command().Textf("touch %s", filepath.Join(stagingDir.String(), "system-other-odex-marker")) + installPath := android.PathForModuleInPartitionInstall(ctx, "system_other", "system-other-odex-marker") + fullInstallPaths = append(fullInstallPaths, installPath.String()) } builder.Command().Textf("touch").Output(stagingDirTimestamp) builder.Build("assemble_filesystem_staging_dir", "Assemble filesystem staging dir") @@ -186,6 +189,10 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext ctx.SetOutputFiles(android.Paths{output}, "") ctx.CheckbuildFile(output) + + // Dump compliance metadata + complianceMetadataInfo := ctx.ComplianceMetadataInfo() + complianceMetadataInfo.SetFilesContained(fullInstallPaths) } func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path { diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go index 01b453e25..d59a2aec5 100644 --- a/filesystem/vbmeta.go +++ b/filesystem/vbmeta.go @@ -16,7 +16,10 @@ package filesystem import ( "fmt" + "sort" "strconv" + "strings" + "time" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -124,6 +127,10 @@ type vbmetaPartitionInfo struct { // The output of the vbmeta module Output android.Path + + // Information about the vbmeta partition that will be added to misc_info.txt + // created by android_device + PropFileForMiscInfo android.Path } var vbmetaPartitionProvider = blueprint.NewProvider[vbmetaPartitionInfo]() @@ -302,6 +309,7 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { RollbackIndexLocation: ril, PublicKey: extractedPublicKey, Output: output, + PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), }) ctx.SetOutputFiles([]android.Path{output}, "") @@ -310,6 +318,41 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { setCommonFilesystemInfo(ctx, v) } +func (v *vbmeta) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path { + var lines []string + addStr := func(name string, value string) { + lines = append(lines, fmt.Sprintf("%s=%s", name, value)) + } + + addStr(fmt.Sprintf("avb_%s_algorithm", v.partitionName()), proptools.StringDefault(v.properties.Algorithm, "SHA256_RSA4096")) + if v.properties.Private_key != nil { + addStr(fmt.Sprintf("avb_%s_key_path", v.partitionName()), android.PathForModuleSrc(ctx, proptools.String(v.properties.Private_key)).String()) + } + if v.properties.Rollback_index_location != nil { + addStr(fmt.Sprintf("avb_%s_rollback_index_location", v.partitionName()), strconv.FormatInt(*v.properties.Rollback_index_location, 10)) + } + + var partitionDepNames []string + ctx.VisitDirectDepsProxyWithTag(vbmetaPartitionDep, func(child android.ModuleProxy) { + if info, ok := android.OtherModuleProvider(ctx, child, vbmetaPartitionProvider); ok { + partitionDepNames = append(partitionDepNames, info.Name) + } else { + ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", child) + } + }) + if v.partitionName() != "vbmeta" { // skip for vbmeta to match Make's misc_info.txt + addStr(fmt.Sprintf("avb_%s", v.partitionName()), strings.Join(android.SortedUniqueStrings(partitionDepNames), " ")) + } + + addStr(fmt.Sprintf("avb_%s_args", v.partitionName()), fmt.Sprintf("--padding_size 4096 --rollback_index %s", v.rollbackIndexString(ctx))) + + sort.Strings(lines) + + propFile := android.PathForModuleOut(ctx, "prop_file_for_misc_info") + android.WriteFileRule(ctx, propFile, strings.Join(lines, "\n")) + return propFile +} + // Returns the embedded shell command that prints the rollback index func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string { if v.properties.Rollback_index != nil { @@ -320,6 +363,17 @@ func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string { } } +// Similar to rollbackIndexCommand, but guarantees that the rollback index is +// always computed during Soong analysis, even if v.properties.Rollback_index is nil +func (v *vbmeta) rollbackIndexString(ctx android.ModuleContext) string { + if v.properties.Rollback_index != nil { + return fmt.Sprintf("%d", *v.properties.Rollback_index) + } else { + t, _ := time.Parse(time.DateOnly, ctx.Config().PlatformSecurityPatch()) + return fmt.Sprintf("%d", t.Unix()) + } +} + var _ android.AndroidMkProviderInfoProducer = (*vbmeta)(nil) func (v *vbmeta) PrepareAndroidMKProviderInfo(config android.Config) *android.AndroidMkProviderInfo { |