Fix diffs in system_other image
Make seems to use functionality of build_image that relies on the
output filename. So it sees that the output is system_other.img and
makes changes based on that. We don't use that codepath, so make those
changes ourselves.
Bug: 376539388
Test: diff out/target/product/vsoc_x86_64/system_other.img out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_system_other_image/android_common/system_other.img
Change-Id: I425b54efc5412e780369b2a851606bd1f1c99ae3
diff --git a/filesystem/system_other.go b/filesystem/system_other.go
index 1c00dd3..5309e90 100644
--- a/filesystem/system_other.go
+++ b/filesystem/system_other.go
@@ -23,6 +23,12 @@
"github.com/google/blueprint/proptools"
)
+var (
+ systemOtherPropFileTweaks = pctx.AndroidStaticRule("system_other_prop_file_tweaks", blueprint.RuleParams{
+ Command: `rm -rf $out && sed -e 's@^mount_point=/$$@mount_point=system_other@g' -e 's@^partition_name=system$$@partition_name=system_other@g' $in > $out`,
+ })
+)
+
type SystemOtherImageProperties struct {
// The system_other image always requires a reference to the system image. The system_other
// partition gets built into the system partition's "b" slot in a/b partition builds. Thus, it
@@ -123,12 +129,23 @@
fec := ctx.Config().HostToolPath(ctx, "fec")
pathToolDirs := []string{filepath.Dir(fec.String())}
+ // In make, the exact same prop file is used for both system and system_other. However, I
+ // believe make goes through a different build_image code path that is based on the name of
+ // the output file. So it sees the output file is named system_other.img and makes some changes.
+ // We don't use that codepath, so make the changes manually to the prop file.
+ propFile := android.PathForModuleOut(ctx, "prop")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: systemOtherPropFileTweaks,
+ Input: systemInfo.BuildImagePropFile,
+ Output: propFile,
+ })
+
builder = android.NewRuleBuilder(pctx, ctx)
builder.Command().
Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")).
BuiltTool("build_image").
Text(stagingDir.String()). // input directory
- Input(systemInfo.BuildImagePropFile).
+ Input(propFile).
Implicits(systemInfo.BuildImagePropFileDeps).
Implicit(fec).
Implicit(stagingDirTimestamp).
@@ -140,7 +157,7 @@
// 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)
+ outputHermeticPropFile := m.propFileForHermeticImg(ctx, builder, propFile)
builder.Command().
Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")).
BuiltTool("build_image").