Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04f12c96 authored by Jihoon Kang's avatar Jihoon Kang
Browse files

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
parent 4325cbe4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ func filesystemCreatorFactory() android.Module {
	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)
	})

+8 −2
Original line number Diff line number Diff line
@@ -110,13 +110,13 @@ func generatedPartitions(ctx android.LoadHookContext) []string {
	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 @@ func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNam
			fsDepsMutex:               sync.Mutex{},
			moduleToInstallationProps: map[string]installationProperties{},
		}

		if avbpubkeyGenerated {
			(*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config())
		}

		return &fsGenState
	}).(*FsGenState)
}

+25 −0
Original line number Diff line number Diff line
@@ -344,3 +344,28 @@ func createPrebuiltEtcModules(ctx android.LoadHookContext) (ret []string) {

	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
}