summaryrefslogtreecommitdiff
path: root/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem')
-rw-r--r--filesystem/android_device.go25
-rw-r--r--filesystem/android_device_product_out.go2
-rw-r--r--filesystem/avb_add_hash_footer.go7
-rw-r--r--filesystem/filesystem.go17
-rw-r--r--filesystem/system_other.go68
-rw-r--r--filesystem/vbmeta.go54
6 files changed, 163 insertions, 10 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 443e80e67..feb000dc4 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -840,6 +840,15 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path {
Textf("echo avb_enable=true >> %s", miscInfo).
Textf("&& echo avb_building_vbmeta_image=true >> %s", miscInfo).
Textf("&& echo avb_avbtool=avbtool >> %s", miscInfo)
+ for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions {
+ img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag)
+ if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok {
+ builder.Command().Text("cat").Input(provider.PropFileForMiscInfo).Textf(" >> %s", miscInfo)
+ } else {
+ ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", vbmetaPartitionName)
+ }
+ }
+
}
if a.partitionProps.Boot_partition_name != nil {
builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo)
@@ -1046,6 +1055,7 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle
}
apkCerts := []string{}
+ var apkCertsFiles android.Paths
for _, installedModule := range allInstalledModules {
partition := ""
if commonInfo, ok := android.OtherModuleProvider(ctx, installedModule, android.CommonModuleInfoProvider); ok {
@@ -1054,7 +1064,11 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle
ctx.ModuleErrorf("%s does not set CommonModuleInfoKey", installedModule.Name())
}
if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfoProvider); ok {
- apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition))
+ if info.AppSet {
+ apkCertsFiles = append(apkCertsFiles, info.ApkCertsFile)
+ } else {
+ apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition))
+ }
} else if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfosProvider); ok {
for _, certInfo := range info {
// Partition information of apk-in-apex is not exported to the legacy Make packaging system.
@@ -1075,7 +1089,14 @@ func (a *androidDevice) buildApkCertsInfo(ctx android.ModuleContext, allInstalle
}
}
+ apkCertsInfoWithoutAppSets := android.PathForModuleOut(ctx, "apkcerts_without_app_sets.txt")
+ android.WriteFileRuleVerbatim(ctx, apkCertsInfoWithoutAppSets, strings.Join(apkCerts, "\n")+"\n")
apkCertsInfo := android.PathForModuleOut(ctx, "apkcerts.txt")
- android.WriteFileRuleVerbatim(ctx, apkCertsInfo, strings.Join(apkCerts, "\n")+"\n")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cat,
+ Description: "combine apkcerts.txt",
+ Output: apkCertsInfo,
+ Inputs: append(apkCertsFiles, apkCertsInfoWithoutAppSets),
+ })
return apkCertsInfo
}
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index 7d37f1ee7..aa06337ca 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -167,7 +167,7 @@ func (a *androidDevice) copyFilesToProductOutForSoongOnly(ctx android.ModuleCont
}
if proptools.String(a.deviceProps.Android_info) != "" {
- installPath := android.PathForModuleInPartitionInstall(ctx, "", "android_info.txt")
+ installPath := android.PathForModuleInPartitionInstall(ctx, "", "android-info.txt")
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: android.PathForModuleSrc(ctx, *a.deviceProps.Android_info),
diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go
index 327a41fda..c7760120d 100644
--- a/filesystem/avb_add_hash_footer.go
+++ b/filesystem/avb_add_hash_footer.go
@@ -70,7 +70,7 @@ type avbAddHashFooterProperties struct {
Props []avbProp
// The index used to prevent rollback of the image on device.
- Rollback_index *int64
+ Rollback_index proptools.Configurable[int64] `android:"replace_instead_of_append"`
// Include descriptors from images
Include_descriptors_from_images []string `android:"path,arch_variant"`
@@ -134,8 +134,9 @@ func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext
addAvbProp(ctx, cmd, prop)
}
- if a.properties.Rollback_index != nil {
- rollbackIndex := proptools.Int(a.properties.Rollback_index)
+ rollbackIndex := a.properties.Rollback_index.Get(ctx)
+ if rollbackIndex.IsPresent() {
+ rollbackIndex := rollbackIndex.Get()
if rollbackIndex < 0 {
ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index f8faa496f..e86ebf4fa 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -455,6 +455,14 @@ type FilesystemInfo struct {
HasFsverity bool
PropFileForMiscInfo android.Path
+
+ // Additional avb and partition size information.
+ // `system_other` will use this information of `system` dep for misc_info.txt processing.
+ PartitionSize *int64
+ UseAvb bool
+ AvbAlgorithm string
+ AvbHashAlgorithm string
+ AvbKey android.Path
}
// FullInstallPathInfo contains information about the "full install" paths of all the files
@@ -711,6 +719,15 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Owners: f.gatherOwners(specs),
HasFsverity: f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) != nil,
PropFileForMiscInfo: propFileForMiscInfo,
+ PartitionSize: f.properties.Partition_size,
+ }
+ if proptools.Bool(f.properties.Use_avb) {
+ fsInfo.UseAvb = true
+ fsInfo.AvbAlgorithm = proptools.StringDefault(f.properties.Avb_algorithm, "SHA256_RSA4096")
+ fsInfo.AvbHashAlgorithm = proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256")
+ if f.properties.Avb_private_key != nil {
+ fsInfo.AvbKey = android.PathForModuleSrc(ctx, *f.properties.Avb_private_key)
+ }
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
diff --git a/filesystem/system_other.go b/filesystem/system_other.go
index cbfd78b5b..32a6cc784 100644
--- a/filesystem/system_other.go
+++ b/filesystem/system_other.go
@@ -16,8 +16,11 @@ package filesystem
import (
"android/soong/android"
+ "fmt"
"path/filepath"
+ "sort"
"strings"
+ "time"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -117,8 +120,11 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext
// TOOD: CopySpecsToDir only exists on PackagingBase, but doesn't use any fields from it. Clean this up.
(&android.PackagingBase{}).CopySpecsToDir(ctx, builder, specs, stagingDir)
+ fullInstallPaths := []string{}
if len(m.properties.Preinstall_dexpreopt_files_from) > 0 {
builder.Command().Textf("touch %s", filepath.Join(stagingDir.String(), "system-other-odex-marker"))
+ installPath := android.PathForModuleInPartitionInstall(ctx, "system_other", "system-other-odex-marker")
+ fullInstallPaths = append(fullInstallPaths, installPath.String())
}
builder.Command().Textf("touch").Output(stagingDirTimestamp)
builder.Build("assemble_filesystem_staging_dir", "Assemble filesystem staging dir")
@@ -172,16 +178,21 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext
builder.Build("build_system_other_hermetic", "build system other")
fsInfo := FilesystemInfo{
- Output: output,
- OutputHermetic: outputHermetic,
- RootDir: stagingDir,
- FilesystemConfig: m.generateFilesystemConfig(ctx, stagingDir, stagingDirTimestamp),
+ Output: output,
+ OutputHermetic: outputHermetic,
+ RootDir: stagingDir,
+ FilesystemConfig: m.generateFilesystemConfig(ctx, stagingDir, stagingDirTimestamp),
+ PropFileForMiscInfo: m.buildPropFileForMiscInfo(ctx),
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
ctx.SetOutputFiles(android.Paths{output}, "")
ctx.CheckbuildFile(output)
+
+ // Dump compliance metadata
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ complianceMetadataInfo.SetFilesContained(fullInstallPaths)
}
func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path {
@@ -204,3 +215,52 @@ func (f *systemOtherImage) propFileForHermeticImg(ctx android.ModuleContext, bui
Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp)
return propFilePinnedTimestamp
}
+
+func (f *systemOtherImage) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path {
+ var lines []string
+ addStr := func(name string, value string) {
+ lines = append(lines, fmt.Sprintf("%s=%s", name, value))
+ }
+
+ addStr("building_system_other_image", "true")
+
+ systemImage := ctx.GetDirectDepProxyWithTag(*f.properties.System_image, systemImageDependencyTag)
+ systemInfo, ok := android.OtherModuleProvider(ctx, systemImage, FilesystemProvider)
+ if !ok {
+ ctx.PropertyErrorf("system_image", "Expected system_image module to provide FilesystemProvider")
+ return nil
+ }
+ if systemInfo.PartitionSize == nil {
+ addStr("system_other_disable_sparse", "true")
+ }
+ if systemInfo.UseAvb {
+ addStr("avb_system_other_hashtree_enable", "true")
+ addStr("avb_system_other_algorithm", systemInfo.AvbAlgorithm)
+ footerArgs := fmt.Sprintf("--hash_algorithm %s", systemInfo.AvbHashAlgorithm)
+ if rollbackIndex, err := f.avbRollbackIndex(ctx); err == nil {
+ footerArgs += fmt.Sprintf(" --rollback_index %d", rollbackIndex)
+ } else {
+ ctx.ModuleErrorf("Could not determine rollback_index %s\n", err)
+ }
+ addStr("avb_system_other_add_hashtree_footer_args", footerArgs)
+ if systemInfo.AvbKey != nil {
+ addStr("avb_system_other_key_path", systemInfo.AvbKey.String())
+ }
+ }
+
+ sort.Strings(lines)
+
+ propFile := android.PathForModuleOut(ctx, "prop_file")
+ android.WriteFileRule(ctx, propFile, strings.Join(lines, "\n"))
+ return propFile
+}
+
+// Use the default: PlatformSecurityPatch
+// TODO: Get this value from vbmeta_system
+func (f *systemOtherImage) avbRollbackIndex(ctx android.ModuleContext) (int64, error) {
+ t, err := time.Parse(time.DateOnly, ctx.Config().PlatformSecurityPatch())
+ if err != nil {
+ return -1, err
+ }
+ return t.Unix(), err
+}
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index 01b453e25..d59a2aec5 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -16,7 +16,10 @@ package filesystem
import (
"fmt"
+ "sort"
"strconv"
+ "strings"
+ "time"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -124,6 +127,10 @@ type vbmetaPartitionInfo struct {
// The output of the vbmeta module
Output android.Path
+
+ // Information about the vbmeta partition that will be added to misc_info.txt
+ // created by android_device
+ PropFileForMiscInfo android.Path
}
var vbmetaPartitionProvider = blueprint.NewProvider[vbmetaPartitionInfo]()
@@ -302,6 +309,7 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) {
RollbackIndexLocation: ril,
PublicKey: extractedPublicKey,
Output: output,
+ PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx),
})
ctx.SetOutputFiles([]android.Path{output}, "")
@@ -310,6 +318,41 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) {
setCommonFilesystemInfo(ctx, v)
}
+func (v *vbmeta) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Path {
+ var lines []string
+ addStr := func(name string, value string) {
+ lines = append(lines, fmt.Sprintf("%s=%s", name, value))
+ }
+
+ addStr(fmt.Sprintf("avb_%s_algorithm", v.partitionName()), proptools.StringDefault(v.properties.Algorithm, "SHA256_RSA4096"))
+ if v.properties.Private_key != nil {
+ addStr(fmt.Sprintf("avb_%s_key_path", v.partitionName()), android.PathForModuleSrc(ctx, proptools.String(v.properties.Private_key)).String())
+ }
+ if v.properties.Rollback_index_location != nil {
+ addStr(fmt.Sprintf("avb_%s_rollback_index_location", v.partitionName()), strconv.FormatInt(*v.properties.Rollback_index_location, 10))
+ }
+
+ var partitionDepNames []string
+ ctx.VisitDirectDepsProxyWithTag(vbmetaPartitionDep, func(child android.ModuleProxy) {
+ if info, ok := android.OtherModuleProvider(ctx, child, vbmetaPartitionProvider); ok {
+ partitionDepNames = append(partitionDepNames, info.Name)
+ } else {
+ ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", child)
+ }
+ })
+ if v.partitionName() != "vbmeta" { // skip for vbmeta to match Make's misc_info.txt
+ addStr(fmt.Sprintf("avb_%s", v.partitionName()), strings.Join(android.SortedUniqueStrings(partitionDepNames), " "))
+ }
+
+ addStr(fmt.Sprintf("avb_%s_args", v.partitionName()), fmt.Sprintf("--padding_size 4096 --rollback_index %s", v.rollbackIndexString(ctx)))
+
+ sort.Strings(lines)
+
+ propFile := android.PathForModuleOut(ctx, "prop_file_for_misc_info")
+ android.WriteFileRule(ctx, propFile, strings.Join(lines, "\n"))
+ return propFile
+}
+
// Returns the embedded shell command that prints the rollback index
func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string {
if v.properties.Rollback_index != nil {
@@ -320,6 +363,17 @@ func (v *vbmeta) rollbackIndexCommand(ctx android.ModuleContext) string {
}
}
+// Similar to rollbackIndexCommand, but guarantees that the rollback index is
+// always computed during Soong analysis, even if v.properties.Rollback_index is nil
+func (v *vbmeta) rollbackIndexString(ctx android.ModuleContext) string {
+ if v.properties.Rollback_index != nil {
+ return fmt.Sprintf("%d", *v.properties.Rollback_index)
+ } else {
+ t, _ := time.Parse(time.DateOnly, ctx.Config().PlatformSecurityPatch())
+ return fmt.Sprintf("%d", t.Unix())
+ }
+}
+
var _ android.AndroidMkProviderInfoProducer = (*vbmeta)(nil)
func (v *vbmeta) PrepareAndroidMKProviderInfo(config android.Config) *android.AndroidMkProviderInfo {