Fix remaining diffs for init_boot and boot images
- Add missing $(cat ) around the fingerprint file
- Add partition size to init_boot
- Add avb keys and algorithms to boot partitions. I used to switch
between the two modes in bootimg modules based on if a key was set,
but now that we are setting a key here I added an explicit mode
property.
- With all these, there are still diffs because avbtool.py introduces
randomness for the salt. If you patch out the randomness locally
the diffs come out clean.
Bug: 377562951
Bug: 377563630
Test: m soong_generated_boot_filesystem_test soong_generated_init_boot_filesystem_test
Change-Id: I448dfb431c240e8d06555fcc5d3e02660e8c2bfb
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 6bfb097..d4301f9 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -546,42 +546,21 @@
}
func generateFsProps(ctx android.EarlyModuleContext, partitionType string) (*filesystem.FilesystemProperties, bool) {
- fsGenState := ctx.Config().Get(fsGenStateOnceKey).(*FsGenState)
fsProps := &filesystem.FilesystemProperties{}
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
- var boardAvbEnable bool
- var boardAvbKeyPath string
- var boardAvbAlgorithm string
- var boardAvbRollbackIndex string
+ var avbInfo avbInfo
var fsType string
if strings.Contains(partitionType, "ramdisk") {
fsType = "compressed_cpio"
} else {
specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
fsType = specificPartitionVars.BoardFileSystemType
- boardAvbEnable = partitionVars.BoardAvbEnable
- boardAvbKeyPath = specificPartitionVars.BoardAvbKeyPath
- boardAvbAlgorithm = specificPartitionVars.BoardAvbAlgorithm
- boardAvbRollbackIndex = specificPartitionVars.BoardAvbRollbackIndex
- if boardAvbEnable {
- if boardAvbKeyPath == "" {
- boardAvbKeyPath = partitionVars.BoardAvbKeyPath
- }
- if boardAvbAlgorithm == "" {
- boardAvbAlgorithm = partitionVars.BoardAvbAlgorithm
- }
- if boardAvbRollbackIndex == "" {
- boardAvbRollbackIndex = partitionVars.BoardAvbRollbackIndex
- }
- }
+ avbInfo = getAvbInfo(ctx.Config(), partitionType)
if fsType == "" {
fsType = "ext4" //default
}
}
- if boardAvbKeyPath != "" {
- boardAvbKeyPath = ":" + fsGenState.avbKeyFilegroups[boardAvbKeyPath]
- }
fsProps.Type = proptools.StringPtr(fsType)
if filesystem.GetFsTypeFromString(ctx, *fsProps.Type).IsUnknown() {
@@ -594,15 +573,13 @@
fsProps.Unchecked_module = proptools.BoolPtr(true)
// BOARD_AVB_ENABLE
- fsProps.Use_avb = proptools.BoolPtr(boardAvbEnable)
+ fsProps.Use_avb = avbInfo.avbEnable
// BOARD_AVB_KEY_PATH
- fsProps.Avb_private_key = proptools.StringPtr(boardAvbKeyPath)
+ fsProps.Avb_private_key = avbInfo.avbkeyFilegroup
// BOARD_AVB_ALGORITHM
- fsProps.Avb_algorithm = proptools.StringPtr(boardAvbAlgorithm)
+ fsProps.Avb_algorithm = avbInfo.avbAlgorithm
// BOARD_AVB_SYSTEM_ROLLBACK_INDEX
- if rollbackIndex, err := strconv.ParseInt(boardAvbRollbackIndex, 10, 64); err == nil {
- fsProps.Rollback_index = proptools.Int64Ptr(rollbackIndex)
- }
+ fsProps.Rollback_index = avbInfo.avbRollbackIndex
fsProps.Partition_name = proptools.StringPtr(partitionType)
@@ -629,6 +606,55 @@
return fsProps, true
}
+type avbInfo struct {
+ avbEnable *bool
+ avbKeyPath *string
+ avbkeyFilegroup *string
+ avbAlgorithm *string
+ avbRollbackIndex *int64
+ avbMode *string
+}
+
+func getAvbInfo(config android.Config, partitionType string) avbInfo {
+ partitionVars := config.ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
+ specificPartitionVars := partitionVars.PartitionQualifiedVariables[partitionType]
+ var result avbInfo
+ boardAvbEnable := partitionVars.BoardAvbEnable
+ if boardAvbEnable {
+ result.avbEnable = proptools.BoolPtr(true)
+ if specificPartitionVars.BoardAvbKeyPath != "" {
+ result.avbKeyPath = proptools.StringPtr(specificPartitionVars.BoardAvbKeyPath)
+ } else if partitionVars.BoardAvbKeyPath != "" {
+ result.avbKeyPath = proptools.StringPtr(partitionVars.BoardAvbKeyPath)
+ }
+ if specificPartitionVars.BoardAvbAlgorithm != "" {
+ result.avbAlgorithm = proptools.StringPtr(specificPartitionVars.BoardAvbAlgorithm)
+ } else if partitionVars.BoardAvbAlgorithm != "" {
+ result.avbAlgorithm = proptools.StringPtr(partitionVars.BoardAvbAlgorithm)
+ }
+ if specificPartitionVars.BoardAvbRollbackIndex != "" {
+ parsed, err := strconv.ParseInt(specificPartitionVars.BoardAvbRollbackIndex, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("Rollback index must be an int, got %s", specificPartitionVars.BoardAvbRollbackIndex))
+ }
+ result.avbRollbackIndex = &parsed
+ } else if partitionVars.BoardAvbRollbackIndex != "" {
+ parsed, err := strconv.ParseInt(partitionVars.BoardAvbRollbackIndex, 10, 64)
+ if err != nil {
+ panic(fmt.Sprintf("Rollback index must be an int, got %s", partitionVars.BoardAvbRollbackIndex))
+ }
+ result.avbRollbackIndex = &parsed
+ }
+ result.avbMode = proptools.StringPtr("make_legacy")
+ }
+ if result.avbKeyPath != nil {
+ fsGenState := config.Get(fsGenStateOnceKey).(*FsGenState)
+ filegroup := fsGenState.avbKeyFilegroups[*result.avbKeyPath]
+ result.avbkeyFilegroup = proptools.StringPtr(":" + filegroup)
+ }
+ return result
+}
+
func (f *filesystemCreator) createFileListDiffTest(ctx android.ModuleContext, partitionType string) android.Path {
partitionModuleName := generatedModuleNameForPartition(ctx.Config(), partitionType)
systemImage := ctx.GetDirectDepWithTag(partitionModuleName, generatedFilesystemDepTag)