Create avbpubkey module in filesystem_creator
And add the generated module to the deps of the product partition
filesystem module.
Test: m soong_generated_product_filesystem_test
Bug: 376505372
Change-Id: Ib3fed01339d2f748d5f3c8445afbea67fc9ef576
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 0a65c6c..2b967f7 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -62,7 +62,8 @@
module.AddProperties(&module.properties)
android.AddLoadHook(module, func(ctx android.LoadHookContext) {
generatedPrebuiltEtcModuleNames := createPrebuiltEtcModules(ctx)
- createFsGenState(ctx, generatedPrebuiltEtcModuleNames)
+ avbpubkeyGenerated := createAvbpubkeyModule(ctx)
+ createFsGenState(ctx, generatedPrebuiltEtcModuleNames, avbpubkeyGenerated)
module.createInternalModules(ctx)
})
diff --git a/fsgen/fsgen_mutators.go b/fsgen/fsgen_mutators.go
index e9fd513..1253f0d 100644
--- a/fsgen/fsgen_mutators.go
+++ b/fsgen/fsgen_mutators.go
@@ -110,13 +110,13 @@
return generatedPartitions
}
-func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNames []string) *FsGenState {
+func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNames []string, avbpubkeyGenerated bool) *FsGenState {
return ctx.Config().Once(fsGenStateOnceKey, func() interface{} {
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
candidates := android.FirstUniqueStrings(android.Concat(partitionVars.ProductPackages, partitionVars.ProductPackagesDebug))
candidates = android.Concat(candidates, generatedPrebuiltEtcModuleNames)
- return &FsGenState{
+ fsGenState := FsGenState{
depCandidates: candidates,
fsDeps: map[string]*multilibDeps{
// These additional deps are added according to the cuttlefish system image bp.
@@ -177,6 +177,12 @@
fsDepsMutex: sync.Mutex{},
moduleToInstallationProps: map[string]installationProperties{},
}
+
+ if avbpubkeyGenerated {
+ (*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config())
+ }
+
+ return &fsGenState
}).(*FsGenState)
}
diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go
index 983dcfb..b8d5478 100644
--- a/fsgen/prebuilt_etc_modules_gen.go
+++ b/fsgen/prebuilt_etc_modules_gen.go
@@ -344,3 +344,28 @@
return ret
}
+
+func createAvbpubkeyModule(ctx android.LoadHookContext) bool {
+ avbKeyPath := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BoardAvbKeyPath
+ if avbKeyPath == "" {
+ return false
+ }
+ ctx.CreateModuleInDirectory(
+ etc.AvbpubkeyModuleFactory,
+ ".",
+ &struct {
+ Name *string
+ Product_specific *bool
+ Private_key *string
+ No_full_install *bool
+ Visibility []string
+ }{
+ Name: proptools.StringPtr("system_other_avbpubkey"),
+ Product_specific: proptools.BoolPtr(true),
+ Private_key: proptools.StringPtr(avbKeyPath),
+ No_full_install: proptools.BoolPtr(true),
+ Visibility: []string{"//visibility:public"},
+ },
+ )
+ return true
+}