boot_image modules inside APEX have correct names

This change fixed the problem that boot_image modules when installed to
an APEX get incorrect names like signed.img. The filename now is
"<modulename>.img" and can be overridden via the new `stem` property.

Bug: 178978059
Test: m
Change-Id: I1b25db04a4a2d888371b174c42f91a0cea87b877
This commit is contained in:
Jiyong Park 2021-02-15 17:57:35 +09:00
parent 0671146fd0
commit 1f55dbd0d6
1 changed files with 11 additions and 7 deletions

View File

@ -38,6 +38,9 @@ type bootimg struct {
}
type bootimgProperties struct {
// Set the name of the output. Defaults to <module_name>.img.
Stem *string
// Path to the linux kernel prebuilt file
Kernel_prebuilt *string `android:"arch_variant,path"`
@ -96,7 +99,7 @@ func (b *bootimg) DepsMutator(ctx android.BottomUpMutatorContext) {
}
func (b *bootimg) installFileName() string {
return b.BaseModuleName() + ".img"
return proptools.StringDefault(b.properties.Stem, b.BaseModuleName()+".img")
}
func (b *bootimg) partitionName() string {
@ -110,6 +113,7 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} else {
// TODO(jiyong): fix this
ctx.PropertyErrorf("vendor_boot", "only vendor_boot:true is supported")
return
}
if proptools.Bool(b.properties.Use_avb) {
@ -123,7 +127,8 @@ func (b *bootimg) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.OutputPath {
output := android.PathForModuleOut(ctx, "unsigned.img").OutputPath
output := android.PathForModuleOut(ctx, "unsigned", b.installFileName()).OutputPath
builder := android.NewRuleBuilder(pctx, ctx)
cmd := builder.Command().BuiltTool("mkbootimg")
@ -182,21 +187,20 @@ func (b *bootimg) buildVendorBootImage(ctx android.ModuleContext) android.Output
}
func (b *bootimg) signImage(ctx android.ModuleContext, unsignedImage android.OutputPath) android.OutputPath {
signedImage := android.PathForModuleOut(ctx, "signed.img").OutputPath
output := android.PathForModuleOut(ctx, b.installFileName()).OutputPath
key := android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key))
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Text("cp").Input(unsignedImage).Output(signedImage)
builder.Command().Text("cp").Input(unsignedImage).Output(output)
builder.Command().
BuiltTool("avbtool").
Flag("add_hash_footer").
FlagWithArg("--partition_name ", b.partitionName()).
FlagWithInput("--key ", key).
FlagWithOutput("--image ", signedImage)
FlagWithOutput("--image ", output)
builder.Build("sign_bootimg", fmt.Sprintf("Signing %s", b.BaseModuleName()))
return signedImage
return output
}
var _ android.AndroidMkEntriesProvider = (*bootimg)(nil)