diff options
author | 2025-02-12 01:32:21 +0000 | |
---|---|---|
committer | 2025-02-12 17:33:48 +0000 | |
commit | 7a42d1c1ca460c32b8deaca5489eabea5dbcbe5e (patch) | |
tree | 79e7ced81d7665316bf197c25b7a97d102b0c97f /filesystem/system_other.go | |
parent | 5ef1a9ca49b520fb82a64f360820811edc79462e (diff) |
Copy system_other.img to target_files.zip
Similar to https://r.android.com/3489814, this adds an additional rule
in systemOtherImage to create a hermetic version of system_other.img
with pinned timestamps. This information will be provided to
android_device via super_image.
block_list information is not implemented for system_other to match the
make behavior
Test: Built the soong built target_files.zip locally
Bug: 385383524
Change-Id: I4cbb4f8a5380203eaef846b3d8a56eb7791f8a34
Diffstat (limited to 'filesystem/system_other.go')
-rw-r--r-- | filesystem/system_other.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/filesystem/system_other.go b/filesystem/system_other.go index 28fe1ce49..1c00dd35e 100644 --- a/filesystem/system_other.go +++ b/filesystem/system_other.go @@ -85,6 +85,7 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext output := android.PathForModuleOut(ctx, "system_other.img") stagingDir := android.PathForModuleOut(ctx, "staging_dir") + stagingDirTimestamp := android.PathForModuleOut(ctx, "staging_dir.timestamp") builder := android.NewRuleBuilder(pctx, ctx) builder.Command().Textf("rm -rf %s && mkdir -p %s", stagingDir, stagingDir) @@ -113,6 +114,8 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext if len(m.properties.Preinstall_dexpreopt_files_from) > 0 { builder.Command().Textf("touch %s", filepath.Join(stagingDir.String(), "system-other-odex-marker")) } + builder.Command().Textf("touch").Output(stagingDirTimestamp) + builder.Build("assemble_filesystem_staging_dir", "Assemble filesystem staging dir") // Most of the time, if build_image were to call a host tool, it accepts the path to the // host tool in a field in the prop file. However, it doesn't have that option for fec, which @@ -120,6 +123,7 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext fec := ctx.Config().HostToolPath(ctx, "fec") pathToolDirs := []string{filepath.Dir(fec.String())} + builder = android.NewRuleBuilder(pctx, ctx) builder.Command(). Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")). BuiltTool("build_image"). @@ -127,11 +131,44 @@ func (m *systemOtherImage) GenerateAndroidBuildActions(ctx android.ModuleContext Input(systemInfo.BuildImagePropFile). Implicits(systemInfo.BuildImagePropFileDeps). Implicit(fec). + Implicit(stagingDirTimestamp). Output(output). Text(stagingDir.String()) builder.Build("build_system_other", "build system other") + // Create a hermetic system_other.img with pinned timestamps + builder = android.NewRuleBuilder(pctx, ctx) + outputHermetic := android.PathForModuleOut(ctx, "for_target_files", "system_other.img") + outputHermeticPropFile := m.propFileForHermeticImg(ctx, builder, systemInfo.BuildImagePropFile) + builder.Command(). + Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")). + BuiltTool("build_image"). + Text(stagingDir.String()). // input directory + Input(outputHermeticPropFile). + Implicits(systemInfo.BuildImagePropFileDeps). + Implicit(fec). + Implicit(stagingDirTimestamp). + Output(outputHermetic). + Text(stagingDir.String()) + + builder.Build("build_system_other_hermetic", "build system other") + + fsInfo := FilesystemInfo{ + Output: output, + OutputHermetic: outputHermetic, + RootDir: stagingDir, + } + + android.SetProvider(ctx, FilesystemProvider, fsInfo) + ctx.SetOutputFiles(android.Paths{output}, "") ctx.CheckbuildFile(output) } + +func (f *systemOtherImage) propFileForHermeticImg(ctx android.ModuleContext, builder *android.RuleBuilder, inputPropFile android.Path) android.Path { + propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop") + builder.Command().Textf("cat").Input(inputPropFile).Flag(">").Output(propFilePinnedTimestamp). + Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp) + return propFilePinnedTimestamp +} |