Merge changes I1bfc1a73,I52b9c9ff into main
* changes:
Generate apex_info.pb,care_map.pb,vbmeta_digest.txt in target_files
Create a partial implementation of $PRODUCT_OUT/misc_info.txt
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 005dc34..5911a4e 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -111,6 +111,7 @@
proguardUsageZip android.Path
kernelConfig android.Path
kernelVersion android.Path
+ miscInfo android.Path
}
func AndroidDeviceFactory() android.Module {
@@ -186,6 +187,7 @@
allInstalledModules := a.allInstalledModules(ctx)
a.kernelConfig, a.kernelVersion = a.extractKernelVersionAndConfigs(ctx)
+ a.miscInfo = a.addMiscInfo(ctx)
a.buildTargetFilesZip(ctx, allInstalledModules)
a.buildProguardZips(ctx, allInstalledModules)
@@ -646,6 +648,12 @@
if a.kernelVersion != nil {
builder.Command().Textf("cp").Input(a.kernelVersion).Textf(" %s/META/", targetFilesDir.String())
}
+ // misc_info.txt
+ if a.miscInfo != nil {
+ builder.Command().Textf("cp").Input(a.miscInfo).Textf(" %s/META/", targetFilesDir.String())
+ }
+ // apex_info.pb, care_map.pb, vbmeta_digest.txt
+ a.addImgToTargetFiles(ctx, builder, targetFilesDir.String())
if a.partitionProps.Super_partition_name != nil {
superPartition := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
@@ -660,6 +668,59 @@
}
+// A partial implementation of make's $PRODUCT_OUT/misc_info.txt
+// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=5894?q=misc_info.txt%20f:build%2Fmake%2Fcore%2FMakefile&ss=android%2Fplatform%2Fsuperproject%2Fmain
+// This file is subsequently used by add_img_to_target_files to create additioanl metadata files like apex_info.pb
+// TODO (b/399788119): Complete the migration of misc_info.txt
+func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path {
+ builder := android.NewRuleBuilder(pctx, ctx)
+ miscInfo := android.PathForModuleOut(ctx, "misc_info.txt")
+ builder.Command().
+ Textf("rm -f %s", miscInfo).
+ Textf("&& echo recovery_api_version=%s >> %s", ctx.Config().VendorConfig("recovery").String("recovery_api_version"), miscInfo).
+ Textf("&& echo fstab_version=%s >> %s", ctx.Config().VendorConfig("recovery").String("recovery_fstab_version"), miscInfo).
+ ImplicitOutput(miscInfo)
+
+ if a.partitionProps.Recovery_partition_name == nil {
+ builder.Command().Textf("echo no_recovery=true >> %s", miscInfo)
+ }
+ fsInfos := a.getFsInfos(ctx)
+ for _, partition := range android.SortedKeys(fsInfos) {
+ if fsInfos[partition].UseAvb {
+ builder.Command().Textf("echo 'avb_%s_hashtree_enable=true' >> %s", partition, miscInfo)
+ }
+ }
+ if len(a.partitionProps.Vbmeta_partitions) > 0 {
+ builder.Command().
+ Textf("echo avb_enable=true >> %s", miscInfo).
+ Textf("&& echo avb_building_vbmeta_image=true >> %s", miscInfo).
+ Textf("&& echo avb_avbtool=avbtool >> %s", miscInfo)
+ }
+ if a.partitionProps.Boot_partition_name != nil {
+ builder.Command().Textf("echo boot_images=boot.img >> %s", miscInfo)
+ }
+
+ builder.Build("misc_info", "Building misc_info")
+
+ return miscInfo
+}
+
+// addImgToTargetFiles invokes `add_img_to_target_files` and creates the following files in META/
+// - apex_info.pb
+// - care_map.pb
+// - vbmeta_digest.txt
+func (a *androidDevice) addImgToTargetFiles(ctx android.ModuleContext, builder *android.RuleBuilder, targetFilesDir string) {
+ mkbootimg := ctx.Config().HostToolPath(ctx, "mkbootimg")
+ builder.Command().
+ Textf("PATH=%s:$PATH", ctx.Config().HostToolDir()).
+ Textf("MKBOOTIMG=%s", mkbootimg).
+ Implicit(mkbootimg).
+ BuiltTool("add_img_to_target_files").
+ Flag("-a -v -p").
+ Flag(ctx.Config().HostToolDir()).
+ Text(targetFilesDir)
+}
+
type ApexKeyPathInfo struct {
ApexKeyPath android.Path
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index fc480e6..35fdd00 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -436,6 +436,8 @@
FilesystemConfig android.Path
Owners []InstalledModuleInfo
+
+ UseAvb bool
}
// FullInstallPathInfo contains information about the "full install" paths of all the files
@@ -680,6 +682,7 @@
SelinuxFc: f.selinuxFc,
FilesystemConfig: f.generateFilesystemConfig(ctx, rootDir, rebasedDir),
Owners: f.gatherOwners(specs),
+ UseAvb: proptools.Bool(f.properties.Use_avb),
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)