diff options
Diffstat (limited to 'filesystem')
-rw-r--r-- | filesystem/android_device.go | 35 | ||||
-rw-r--r-- | filesystem/android_device_product_out.go | 2 | ||||
-rw-r--r-- | filesystem/bootimg.go | 8 | ||||
-rw-r--r-- | filesystem/filesystem.go | 22 | ||||
-rw-r--r-- | filesystem/filesystem_test.go | 33 | ||||
-rw-r--r-- | filesystem/vbmeta.go | 18 |
6 files changed, 98 insertions, 20 deletions
diff --git a/filesystem/android_device.go b/filesystem/android_device.go index feb000dc4..9a085a628 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -90,6 +90,10 @@ type DeviceProperties struct { Releasetools_extension *string `android:"path"` FastbootInfo *string `android:"path"` + Partial_ota_update_partitions []string + Flash_block_size *string + Bootloader_in_update_package *bool + // The kernel version in the build. Will be verified against the actual kernel. // If not provided, will attempt to extract it from the loose kernel or the kernel inside // the boot image. The version is later used to decide whether or not to enable uffd_gc @@ -116,6 +120,7 @@ type androidDevice struct { rootDirForFsConfig string rootDirForFsConfigTimestamp android.Path apkCertsInfo android.Path + targetFilesZip android.Path } func AndroidDeviceFactory() android.Module { @@ -391,6 +396,16 @@ func (a *androidDevice) distFiles(ctx android.ModuleContext) { if a.deviceProps.Android_info != nil { ctx.DistForGoal("droidcore-unbundled", android.PathForModuleSrc(ctx, *a.deviceProps.Android_info)) } + if a.miscInfo != nil { + ctx.DistForGoal("droidcore-unbundled", a.miscInfo) + if a.partitionProps.Super_partition_name != nil { + ctx.DistForGoalWithFilename("dist_files", a.miscInfo, "super_misc_info.txt") + } + } + if a.targetFilesZip != nil { + ctx.DistForGoalWithFilename("target-files-package", a.targetFilesZip, namePrefix+insertBeforeExtension(a.targetFilesZip.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + } + } } @@ -579,6 +594,7 @@ func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext, allInstal a.copyImagesToTargetZip(ctx, builder, targetFilesDir) a.copyMetadataToTargetZip(ctx, builder, targetFilesDir, allInstalledModules) + a.targetFilesZip = targetFilesZip builder.Command(). BuiltTool("soong_zip"). Text("-d"). @@ -840,14 +856,25 @@ 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) + + var allChainedVbmetaPartitionTypes []string 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) + if provider.FilesystemPartitionType != "" { // the top-level vbmeta.img + allChainedVbmetaPartitionTypes = append(allChainedVbmetaPartitionTypes, provider.FilesystemPartitionType) + } } else { ctx.ModuleErrorf("vbmeta dep %s does not set vbmetaPartitionProvider\n", vbmetaPartitionName) } } + // Determine the custom vbmeta partitions by removing system and vendor + customVbmetaPartitionTypes := android.RemoveListFromList(allChainedVbmetaPartitionTypes, []string{"system", "vendor"}) + builder.Command().Textf("echo avb_custom_vbmeta_images_partition_list=%s >> %s", + strings.Join(android.SortedUniqueStrings(customVbmetaPartitionTypes), " "), + miscInfo, + ) } if a.partitionProps.Boot_partition_name != nil { @@ -883,6 +910,14 @@ func (a *androidDevice) addMiscInfo(ctx android.ModuleContext) android.Path { builder.Command().Text("cat").Input(bootImgInfo.PropFileForMiscInfo).Textf(" >> %s", miscInfo) } + builder.Command().Textf("echo blocksize=%s >> %s", proptools.String(a.deviceProps.Flash_block_size), miscInfo) + if proptools.Bool(a.deviceProps.Bootloader_in_update_package) { + builder.Command().Textf("echo bootloader_in_update_package=true >> %s", miscInfo) + } + if len(a.deviceProps.Partial_ota_update_partitions) > 0 { + builder.Command().Textf("echo partial_ota_update_partitions_list=%s >> %s", strings.Join(a.deviceProps.Partial_ota_update_partitions, " "), miscInfo) + } + // Sort and dedup builder.Command().Textf("sort -u %s -o %s", miscInfo, miscInfo) 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/bootimg.go b/filesystem/bootimg.go index 5ab0c6899..485eae47c 100644 --- a/filesystem/bootimg.go +++ b/filesystem/bootimg.go @@ -539,6 +539,14 @@ func (b *bootimg) buildPropFileForMiscInfo(ctx android.ModuleContext) android.Pa bootImgType := proptools.String(b.properties.Boot_image_type) addStr("avb_"+bootImgType+"_add_hash_footer_args", b.getAvbHashFooterArgs(ctx)) + if ramdisk := proptools.String(b.properties.Ramdisk_module); ramdisk != "" { + ramdiskModule := ctx.GetDirectDepWithTag(ramdisk, bootimgRamdiskDep) + fsInfo, _ := android.OtherModuleProvider(ctx, ramdiskModule, FilesystemProvider) + if fsInfo.HasOrIsRecovery { + // Create a dup entry for recovery + addStr("avb_recovery_add_hash_footer_args", strings.ReplaceAll(b.getAvbHashFooterArgs(ctx), bootImgType, "recovery")) + } + } 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()) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index e86ebf4fa..fd1c784ec 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -463,6 +463,9 @@ type FilesystemInfo struct { AvbAlgorithm string AvbHashAlgorithm string AvbKey android.Path + PartitionName string + // HasOrIsRecovery returns true for recovery and for ramdisks with a recovery partition. + HasOrIsRecovery bool } // FullInstallPathInfo contains information about the "full install" paths of all the files @@ -720,6 +723,8 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { HasFsverity: f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) != nil, PropFileForMiscInfo: propFileForMiscInfo, PartitionSize: f.properties.Partition_size, + PartitionName: f.partitionName(), + HasOrIsRecovery: f.hasOrIsRecovery(ctx), } if proptools.Bool(f.properties.Use_avb) { fsInfo.UseAvb = true @@ -1177,10 +1182,6 @@ func (f *filesystem) buildPropFileForMiscInfo(ctx android.ModuleContext) android if proptools.Bool(f.properties.Use_avb) { addStr("avb_"+f.partitionName()+"_hashtree_enable", "true") - if f.properties.Avb_private_key != nil { - key := android.PathForModuleSrc(ctx, *f.properties.Avb_private_key) - addStr("avb_"+f.partitionName()+"_key_path", key.String()) - } addStr("avb_"+f.partitionName()+"_add_hashtree_footer_args", strings.TrimSpace(f.getAvbAddHashtreeFooterArgs(ctx))) } @@ -1307,6 +1308,19 @@ func includeFilesInstalledFiles(ctx android.ModuleContext) (ret []depset.DepSet[ return } +func (f *filesystem) hasOrIsRecovery(ctx android.ModuleContext) bool { + if f.partitionName() == "recovery" { + return true + } + ret := false + ctx.VisitDirectDepsWithTag(interPartitionInstallDependencyTag, func(m android.Module) { + if fsProvider, ok := android.OtherModuleProvider(ctx, m, FilesystemProvider); ok && fsProvider.PartitionName == "recovery" { + ret = true + } + }) + return ret +} + func (f *filesystem) buildCpioImage( ctx android.ModuleContext, builder *android.RuleBuilder, diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index bf7f5b64b..e57e45cb6 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -736,15 +736,14 @@ func TestOverrideModulesInDeps(t *testing.T) { stl: "none", system_shared_libs: [], } - android_filesystem { - name: "myfilesystem", - deps: ["myapp"], + phony { + name: "myapp_phony", + required: ["myapp"], } - android_filesystem { - name: "myfilesystem_overridden", - deps: ["myapp", "myoverrideapp"], + phony { + name: "myoverrideapp_phony", + required: ["myoverrideapp"], } - android_app { name: "myapp", platform_apis: true, @@ -755,15 +754,29 @@ func TestOverrideModulesInDeps(t *testing.T) { base: "myapp", required: ["libbar"], } + android_filesystem { + name: "myfilesystem", + deps: ["myapp"], + } + android_filesystem { + name: "myfilesystem_overridden", + deps: ["myapp", "myoverrideapp"], + } + android_filesystem { + name: "myfilesystem_overridden_indirect", + deps: ["myapp_phony", "myoverrideapp_phony"], + } `) partition := result.ModuleForTests(t, "myfilesystem", "android_common") fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) android.AssertStringEquals(t, "filesystem without override app", "app/myapp/myapp.apk\nlib64/libfoo.so\n", fileList) - overriddenPartition := result.ModuleForTests(t, "myfilesystem_overridden", "android_common") - overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) - android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) + for _, overridden := range []string{"myfilesystem_overridden", "myfilesystem_overridden_indirect"} { + overriddenPartition := result.ModuleForTests(t, overridden, "android_common") + overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) + android.AssertStringEquals(t, "filesystem with "+overridden, "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) + } } func TestRamdiskPartitionSetsDevNodes(t *testing.T) { diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go index d59a2aec5..e7a39bef7 100644 --- a/filesystem/vbmeta.go +++ b/filesystem/vbmeta.go @@ -55,6 +55,10 @@ type VbmetaProperties struct { // Name of the partition stored in vbmeta desc. Defaults to the name of this module. Partition_name *string + // Type of the `android_filesystem` for which the vbmeta.img is created. + // Examples are system, vendor, product. + Filesystem_partition_type *string + // Set the name of the output. Defaults to <module_name>.img. Stem *string @@ -118,6 +122,9 @@ type vbmetaPartitionInfo struct { // Name of the partition Name string + // Partition type of the correspdonding android_filesystem. + FilesystemPartitionType string + // Rollback index location, non-negative int RollbackIndexLocation int @@ -305,11 +312,12 @@ func (v *vbmeta) GenerateAndroidBuildActions(ctx android.ModuleContext) { }) android.SetProvider(ctx, vbmetaPartitionProvider, vbmetaPartitionInfo{ - Name: v.partitionName(), - RollbackIndexLocation: ril, - PublicKey: extractedPublicKey, - Output: output, - PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), + Name: v.partitionName(), + FilesystemPartitionType: proptools.String(v.properties.Filesystem_partition_type), + RollbackIndexLocation: ril, + PublicKey: extractedPublicKey, + Output: output, + PropFileForMiscInfo: v.buildPropFileForMiscInfo(ctx), }) ctx.SetOutputFiles([]android.Path{output}, "") |