Support for prebuilt_avb
in Soong
Generally, the `root` directories for `prebuilt_etc` and `prebuilt_root` are <partitions>. And <partitions> default to false for InstallInRoot(), they always create a "system" subdirectory. (See android/paths.go:modulePartition()) However, avb keys like `q-developer-gsi.avbpubkey` are installed by default in the `avb` subdirectory under the `root directory` of the <partition>. Therefore, it is necessary to create `prebuilt_avb` in Soong and force the installation directory to be the `avb` subdirectory under the `root directory` of the <partition> to meet the requirements. Bug: 347636127 Test: go test -run TestPrebuiltAvbInstallDirPath Change-Id: I0ee08492da9a96a567700a7285c527b280dcd5db
This commit is contained in:
@@ -50,6 +50,7 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
|
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
|
ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
|
||||||
|
ctx.RegisterModuleType("prebuilt_avb", PrebuiltAvbFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
|
ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
|
ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
|
||||||
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
|
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
|
||||||
@@ -155,6 +156,9 @@ type PrebuiltEtc struct {
|
|||||||
additionalDependencies *android.Paths
|
additionalDependencies *android.Paths
|
||||||
|
|
||||||
usedSrcsProperty bool
|
usedSrcsProperty bool
|
||||||
|
// installInRoot is used to return the value of the InstallInRoot() method. The default value is false.
|
||||||
|
// Currently, only prebuilt_avb can be set to true.
|
||||||
|
installInRoot bool
|
||||||
|
|
||||||
makeClass string
|
makeClass string
|
||||||
}
|
}
|
||||||
@@ -241,6 +245,10 @@ func (p *PrebuiltEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) b
|
|||||||
return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
|
return proptools.Bool(p.properties.Debug_ramdisk_available) || p.ModuleBase.InstallInDebugRamdisk()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PrebuiltEtc) InstallInRoot() bool {
|
||||||
|
return p.installInRoot
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
|
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
|
||||||
return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
|
return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
|
||||||
}
|
}
|
||||||
@@ -494,12 +502,20 @@ func (p *PrebuiltEtc) AndroidModuleBase() *android.ModuleBase {
|
|||||||
|
|
||||||
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
|
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
|
||||||
p.installDirBase = dirBase
|
p.installDirBase = dirBase
|
||||||
|
p.installInRoot = false
|
||||||
p.AddProperties(&p.properties)
|
p.AddProperties(&p.properties)
|
||||||
p.AddProperties(&p.subdirProperties)
|
p.AddProperties(&p.subdirProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitPrebuiltRootModule(p *PrebuiltEtc) {
|
func InitPrebuiltRootModule(p *PrebuiltEtc) {
|
||||||
p.installDirBase = "."
|
p.installDirBase = "."
|
||||||
|
p.installInRoot = false
|
||||||
|
p.AddProperties(&p.properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitPrebuiltAvbModule(p *PrebuiltEtc) {
|
||||||
|
p.installDirBase = "avb"
|
||||||
|
p.installInRoot = true
|
||||||
p.AddProperties(&p.properties)
|
p.AddProperties(&p.properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,6 +569,20 @@ func PrebuiltEtcCaCertsFactory() android.Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generally, a <partition> directory will contain a `system` subdirectory, but the <partition> of
|
||||||
|
// `prebuilt_avb` will not have a `system` subdirectory.
|
||||||
|
// Ultimately, prebuilt_avb will install the prebuilt artifact to the `avb` subdirectory under the
|
||||||
|
// root directory of the partition: <partition_root>/avb.
|
||||||
|
// prebuilt_avb does not allow adding any other subdirectories.
|
||||||
|
func PrebuiltAvbFactory() android.Module {
|
||||||
|
module := &PrebuiltEtc{}
|
||||||
|
InitPrebuiltAvbModule(module)
|
||||||
|
// This module is device-only
|
||||||
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||||
|
android.InitDefaultableModule(module)
|
||||||
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
// prebuilt_root is for a prebuilt artifact that is installed in
|
// prebuilt_root is for a prebuilt artifact that is installed in
|
||||||
// <partition>/ directory. Can't have any sub directories.
|
// <partition>/ directory. Can't have any sub directories.
|
||||||
func PrebuiltRootFactory() android.Module {
|
func PrebuiltRootFactory() android.Module {
|
||||||
|
@@ -244,6 +244,31 @@ func TestPrebuiltRootInstallDirPathValidate(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrebuiltAvbInstallDirPath(t *testing.T) {
|
||||||
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
||||||
|
prebuilt_avb {
|
||||||
|
name: "foo.conf",
|
||||||
|
src: "foo.conf",
|
||||||
|
filename: "foo.conf",
|
||||||
|
//recovery: true,
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
||||||
|
expected := "out/soong/target/product/test_device/root/avb"
|
||||||
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrebuiltAvdInstallDirPathValidate(t *testing.T) {
|
||||||
|
prepareForPrebuiltEtcTest.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("filename cannot contain separator")).RunTestWithBp(t, `
|
||||||
|
prebuilt_avb {
|
||||||
|
name: "foo.conf",
|
||||||
|
src: "foo.conf",
|
||||||
|
filename: "foo/bar.conf",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
||||||
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
||||||
prebuilt_usr_share {
|
prebuilt_usr_share {
|
||||||
|
Reference in New Issue
Block a user