diff options
author | 2025-01-15 00:53:15 +0000 | |
---|---|---|
committer | 2025-01-15 02:31:19 +0000 | |
commit | 1f0a5a181c26a8cf59e29dcc01706d7fa59237aa (patch) | |
tree | 710fb1bcd47bd8689171add3b936162a984128ca /filesystem/filesystem.go | |
parent | 33c9c479989870e4a1bd82f61312eb0e2e5ebeb0 (diff) |
Create build rules for hermetic .img files
Make packaging generates build rules for two $partition.img files
1. Containing inodes with build timestamps
2. Containing inodes with pinned timestamps
The former is useful for adb sync. The latter is used for
target_files.zip.
This CL creates a build rule to generate (2) with soong `filesystem` modules.
The propFile for (2) will be created by concat'ing the propFile for (1)
with `use_fixed_timestamp=true`
Test: m out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_device/android_x86_64_silvermont/target_files.zip out/target/product/vsoc_x86_64/obj/PACKAGING/target_files_intermediates/aosp_cf_x86_64_phone-target_files.zip
Test: diff -r out/target/product/vsoc_x86_64/obj/PACKAGING/target_files_intermediates/aosp_cf_x86_64_phone-target_files/ out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_device/android_x86_64_silvermont/target_files_dir/ --no-dereference
- super_empty.img and system_other.img are missing
- vbmeta*, boot* and userdata have binary diffs
- the rest are identical
Change-Id: If078220f215693660796090eb9b690b0ad41fd38
Diffstat (limited to 'filesystem/filesystem.go')
-rw-r--r-- | filesystem/filesystem.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 469fd9efa..37a296536 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -363,6 +363,10 @@ func (fs fsType) IsUnknown() bool { type FilesystemInfo struct { // The built filesystem image Output android.Path + // An additional hermetic filesystem image. + // e.g. this will contain inodes with pinned timestamps. + // This will be copied to target_files.zip + OutputHermetic android.Path // A text file containing the list of paths installed on the partition. FileListFile android.Path // The root staging directory used to build the output filesystem. If consuming this, make sure @@ -460,9 +464,10 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { var rootDir android.OutputPath var mapFile android.Path + var outputHermetic android.Path switch f.fsType(ctx) { case ext4Type, erofsType, f2fsType: - f.output, rootDir = f.buildImageUsingBuildImage(ctx) + f.output, outputHermetic, rootDir = f.buildImageUsingBuildImage(ctx) mapFile = f.getMapFile(ctx) case compressedCpioType: f.output, rootDir = f.buildCpioImage(ctx, true) @@ -491,6 +496,9 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { if mapFile != nil { fsInfo.MapFile = mapFile } + if outputHermetic != nil { + fsInfo.OutputHermetic = outputHermetic + } android.SetProvider(ctx, FilesystemProvider, fsInfo) @@ -649,7 +657,7 @@ func (f *filesystem) rootDirString() string { return f.partitionName() } -func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (android.Path, android.OutputPath) { +func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (android.Path, android.Path, android.OutputPath) { rootDir := android.PathForModuleOut(ctx, f.rootDirString()).OutputPath rebasedDir := rootDir if f.properties.Base_dir != nil { @@ -697,6 +705,21 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (andro Output(output). Text(rootDir.String()) // directory where to find fs_config_files|dirs + // Add an additional cmd to create a hermetic img file. This will contain pinned timestamps e.g. + propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop") + builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp).Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp) + + outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName()) + builder.Command(). + Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")). + BuiltTool("build_image"). + Text(rootDir.String()). // input directory + Flag(propFilePinnedTimestamp.String()). + Implicits(toolDeps). + Implicit(fec). + Output(outputHermetic). + Text(rootDir.String()) // directory where to find fs_config_files|dirs + if !ctx.Config().KatiEnabled() { copyImageFileToProductOut(ctx, builder, f.partitionName(), output) } @@ -708,7 +731,7 @@ func (f *filesystem) buildImageUsingBuildImage(ctx android.ModuleContext) (andro // rootDir is not deleted. Might be useful for quick inspection. builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName())) - return output, rootDir + return output, outputHermetic, rootDir } func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path { |