diff options
-rw-r--r-- | android/Android.bp | 4 | ||||
-rw-r--r-- | android/filegroup.go | 52 | ||||
-rw-r--r-- | filesystem/bootimg.go | 38 |
3 files changed, 35 insertions, 59 deletions
diff --git a/android/Android.bp b/android/Android.bp index 4b75148fc..00dc50ac2 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -171,7 +171,3 @@ bootstrap_go_package { // Used by plugins visibility: ["//visibility:public"], } - -otatools_package_filegroup { - name: "otatools_package_filegroup", -} diff --git a/android/filegroup.go b/android/filegroup.go index 9bcfd0a83..4fad52aaa 100644 --- a/android/filegroup.go +++ b/android/filegroup.go @@ -33,7 +33,6 @@ var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx Registrati func RegisterFilegroupBuildComponents(ctx RegistrationContext) { ctx.RegisterModuleType("filegroup", FileGroupFactory) ctx.RegisterModuleType("filegroup_defaults", FileGroupDefaultsFactory) - ctx.RegisterModuleType("otatools_package_filegroup", OtatoolsFileGroupFactory) } type fileGroupProperties struct { @@ -164,54 +163,3 @@ func (fg *fileGroup) IDEInfo(ctx BaseModuleContext, dpInfo *IdeInfo) { } } } - -type OtatoolsFileGroup struct { - ModuleBase -} - -func OtatoolsFileGroupFactory() Module { - module := &OtatoolsFileGroup{} - InitAndroidModule(module) - AddLoadHook(module, func(ctx LoadHookContext) { - module.createOTAToolsPackagefilegroup(ctx) - }) - return module -} - -func (fg *OtatoolsFileGroup) GenerateAndroidBuildActions(ctx ModuleContext) { -} - -// Create the filegroup to collect cert files for otatools.zip. -func (fg *OtatoolsFileGroup) createOTAToolsPackagefilegroup(ctx LoadHookContext) { - ctx.CreateModuleInDirectory( - FileGroupFactory, - ".", - &struct { - Name *string - Srcs []string - Visibility []string - }{ - Name: proptools.StringPtr("soong_generated_otatools_package_filegroup"), - Srcs: []string{ - "build/make/target/product/security/**/*.x509.pem", - "build/make/target/product/security/**/*.pk8", - "device/**/*.pk8", - "device/**/verifiedboot*", - "device/**/*.pem", - "device/**/oem*.prop", - "device/**/*.avbpubkey", - "external/avb/test/data/**/testkey_*.pem", - "external/avb/test/data/**/atx_metadata.bin", - "packages/modules/**/*.x509.pem", - "packages/modules/**/*.pk8", - "packages/modules/**/*.key.pem", - "vendor/**/*.pk8", - "vendor/**/verifiedboot*", - "vendor/**/*.pem", - "vendor/**/oem*.prop", - "vendor/**/*.avbpubkey", - }, - Visibility: []string{"//build/make/tools/otatools_package"}, - }, - ) -} diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go index 7959365e8..a1c4bce58 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -510,6 +510,25 @@ func (b *bootimg) buildPropFile(ctx android.ModuleContext) (android.Path, androi return propFile, deps } +func (b *bootimg) getAvbHashFooterArgs(ctx android.ModuleContext) string { + ret := "" + if !b.bootImageType.isVendorBoot() { + ret += "--prop " + fmt.Sprintf("com.android.build.%s.os_version:%s", b.bootImageType.String(), ctx.Config().PlatformVersionLastStable()) + } + + fingerprintFile := ctx.Config().BuildFingerprintFile(ctx) + ret += " --prop " + fmt.Sprintf("com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", b.bootImageType.String(), fingerprintFile.String()) + + if b.properties.Security_patch != nil { + ret += " --prop " + fmt.Sprintf("com.android.build.%s.security_patch:%s", b.bootImageType.String(), *b.properties.Security_patch) + } + + if b.properties.Avb_rollback_index != nil { + ret += " --rollback_index " + strconv.FormatInt(*b.properties.Avb_rollback_index, 10) + } + return strings.TrimSpace(ret) +} + func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path { var sb strings.Builder addStr := func(name string, value string) { @@ -517,15 +536,28 @@ func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Pa } bootImgType := proptools.String(b.properties.Boot_image_type) - addStr("avb_"+bootImgType+"_add_hash_footer_args", "TODO(b/398036609)") + addStr("avb_"+bootImgType+"_add_hash_footer_args", b.getAvbHashFooterArgs(ctx)) if b.properties.Avb_private_key != nil { addStr("avb_"+bootImgType+"_algorithm", proptools.StringDefault(b.properties.Avb_algorithm, "SHA256_RSA4096")) addStr("avb_"+bootImgType+"_key_path", android.PathForModuleSrc(ctx, proptools.String(b.properties.Avb_private_key)).String()) addStr("avb_"+bootImgType+"_rollback_index_location", strconv.Itoa(proptools.Int(b.properties.Avb_rollback_index_location))) } + if b.properties.Partition_size != nil { + addStr(bootImgType+"_size", strconv.FormatInt(*b.properties.Partition_size, 10)) + } + if bootImgType != "boot" { + addStr(bootImgType, "true") + } + + propFilePreProcessing := android.PathForModuleOut(ctx, "prop_for_misc_info_pre_processing") + android.WriteFileRuleVerbatim(ctx, propFilePreProcessing, sb.String()) + propFile := android.PathForModuleOut(ctx, "prop_file_for_misc_info") + ctx.Build(pctx, android.BuildParams{ + Rule: textFileProcessorRule, + Input: propFilePreProcessing, + Output: propFile, + }) - propFile := android.PathForModuleOut(ctx, "prop_for_misc_info") - android.WriteFileRuleVerbatim(ctx, propFile, sb.String()) return propFile } |