diff options
author | 2025-03-13 23:12:04 +0000 | |
---|---|---|
committer | 2025-03-13 23:32:33 +0000 | |
commit | f8346b5ba3bf12d22e78e92af2e9b9b408c3f72e (patch) | |
tree | cc76860b1f426b287e82be681dff57cbf7ea9ec9 /filesystem | |
parent | e041103ee8be5a960bd795422c9a292c32e28d04 (diff) |
Add avb info of bootimages in misc_info.txt
Make built $ANDROID_PRODUCT_OUT/misc_info.txt contains the avb
information of the installed boot images. This info overlaps with the
contents of the buildPropFile of the `bootImg` modules, but
- Only some of the entries are written to misc_info.txt
- misc_info.txt contains the "partition qualified" key. e.g.
avb_init_boot_algorithm and not avb_algorithm
This CL adds a secondary `propFileForMiscInfo` to the build actions
of bootimg. This file will be propagated to android_device via a
provider and cat'd to the misc_info.txt created by android_device
(There are still a lot of diffs between Make and Soong misc_info.txt)
Bug: 398036609
Test: Built Soong's misc_info.txt
Change-Id: I0c49ebaf7a2bac934dca05bcdab65b8521b891ed
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/android_device.go | 15 | ||||
-rw-r--r-- | filesystem/bootimg.go | 41 |
2 files changed, 46 insertions, 10 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go index bd887c78f..3f6348dbf 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -789,6 +789,21 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { ctx.ModuleErrorf("Super partition %s does set SuperImageProvider\n", superPartition.Name()) } } + bootImgNames := []*string{ + a.partitionProps.Boot_partition_name, + a.partitionProps.Init_boot_partition_name, + a.partitionProps.Vendor_boot_partition_name, + } + for _, bootImgName := range bootImgNames { + if bootImgName == nil { + continue + } + + bootImg := ctx.GetDirectDepProxyWithTag(proptools.String(bootImgName), filesystemDepTag) + bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider) + // cat avb_ metadata of the boot images + builder.Command().Text("cat").Input(bootImgInfo.PropFileForMiscInfo).Textf(" >> %s", miscInfo) + } builder.Build("misc_info", "Building misc_info") diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index c06c20048..7959365e8 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -238,11 +238,12 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Set BootimgInfo for building target_files.zip dtbPath := b.getDtbPath(ctx) android.SetProvider(ctx, BootimgInfoProvider, BootimgInfo{ - Cmdline: b.properties.Cmdline, - Kernel: kernelPath, - Dtb: dtbPath, - Bootconfig: b.getBootconfigPath(ctx), - Output: output, + Cmdline: b.properties.Cmdline, + Kernel: kernelPath, + Dtb: dtbPath, + Bootconfig: b.getBootconfigPath(ctx), + Output: output, + PropFileForMiscInfo: b.buildPropFileForMiscInfo(ctx), }) extractedPublicKey := android.PathForModuleOut(ctx, b.partitionName()+".avbpubkey") @@ -285,11 +286,12 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) { var BootimgInfoProvider = blueprint.NewProvider[BootimgInfo]() type BootimgInfo struct { - Cmdline []string - Kernel android.Path - Dtb android.Path - Bootconfig android.Path - Output android.Path + Cmdline []string + Kernel android.Path + Dtb android.Path + Bootconfig android.Path + Output android.Path + PropFileForMiscInfo android.Path } func (b *bootimg) getKernelPath(ctx android.ModuleContext) android.Path { @@ -508,6 +510,25 @@ func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, androi return propFile, deps } +func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path { + var sb strings.Builder + addStr := func(name string, value string) { + fmt.Fprintf(&sb, "%s=%s\n", name, value) + } + + bootImgType := proptools.String(b.properties.Boot_image_type) + addStr("avb_"+bootImgType+"_add_hash_footer_args", "TODO(b/398036609)") + if b.properties.Avb_private_key != nil { + addStr("avb_"+bootImgType+"_algorithm", proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096")) + addStr("avb_"+bootImgType+"_key_path", android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)).String()) + addStr("avb_"+bootImgType+"_rollback_index_location", strconv.Itoa(proptools.Int(b.properties.Avb_rollback_index_location))) + } + + propFile := android.PathForModuleOut(ctx, "prop_for_misc_info") + android.WriteFileRuleVerbatim(ctx, propFile, sb.String()) + return propFile +} + var _ android.AndroidMkEntriesProvider = (*bootimg)(nil) // Implements android.AndroidMkEntriesProvider |