From 721285004cd77813bebbe5484fef4c0dbb46d835 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 13 Mar 2025 23:53:02 +0000 Subject: Refactor filesystem's avb_add_hashtree_footer_args into a function This function will be reused to build misc_info.txt. This CL should be a noop. Test: go build ./android Bug: 398036609 Change-Id: I69d44d8aa05e68db4a77c9c1c3d9ab590cd6550e --- filesystem/filesystem.go | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'filesystem/filesystem.go') diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index d5188d7c2..98551d0c4 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -1064,28 +1064,7 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and addPath("avb_key_path", key) } addStr("partition_name", f.partitionName()) - avb_add_hashtree_footer_args := "" - if !proptools.BoolDefault(f.properties.Use_fec, true) { - avb_add_hashtree_footer_args += " --do_not_generate_fec" - } - hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256") - avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm - if f.properties.Rollback_index != nil { - rollbackIndex := proptools.Int(f.properties.Rollback_index) - if rollbackIndex < 0 { - ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative") - } - avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex) - } - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable()) - // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because - // the build number changed, and we don't want to trigger rebuilds solely based on the build - // number. - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx)) - if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" { - avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch)) - } - addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args) + addStr("avb_add_hashtree_footer_args", f.getAvbAddHashtreeFooterArgs(ctx)) } if f.properties.File_contexts != nil && f.properties.Precompiled_file_contexts != nil { @@ -1165,6 +1144,31 @@ func (f *filesystem) buildPropFile(ctx android.ModuleContext) (android.Path, and return propFile, deps } +func (f *filesystem) getAvbAddHashtreeFooterArgs(ctx android.ModuleContext) string { + avb_add_hashtree_footer_args := "" + if !proptools.BoolDefault(f.properties.Use_fec, true) { + avb_add_hashtree_footer_args += " --do_not_generate_fec" + } + hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256") + avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm + if f.properties.Rollback_index != nil { + rollbackIndex := proptools.Int(f.properties.Rollback_index) + if rollbackIndex < 0 { + ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative") + } + avb_add_hashtree_footer_args += " --rollback_index " + strconv.Itoa(rollbackIndex) + } + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.os_version:%s", f.partitionName(), ctx.Config().PlatformVersionLastStable()) + // We're not going to add BuildFingerPrintFile as a dep. If it changed, it's likely because + // the build number changed, and we don't want to trigger rebuilds solely based on the build + // number. + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.fingerprint:{CONTENTS_OF:%s}", f.partitionName(), ctx.Config().BuildFingerprintFile(ctx)) + if f.properties.Security_patch != nil && proptools.String(f.properties.Security_patch) != "" { + avb_add_hashtree_footer_args += fmt.Sprintf(" --prop com.android.build.%s.security_patch:%s", f.partitionName(), proptools.String(f.properties.Security_patch)) + } + return avb_add_hashtree_footer_args +} + // This method checks if there is any property set for the fstype(s) other than // the current fstype. func (f *filesystem) checkFsTypePropertyError(ctx android.ModuleContext, t fsType, fs string) { -- cgit v1.2.3-59-g8ed1b