Delete prebuilt APEXes when installing source-built APEXes
To build the platform for ASAN, we do
`m && SANITIZE_TARGET='addresss' m`
However, at the end of the second build, the system partition could have
conflicting APEXes; prebuilt APEXes from the first build and
source-built APEXes from the second build. Since the file names for the
prebuilt and the source-built are different (e.g.
com.google.android.media.apex v.s. com.android.media.apex), we end up
having two files for the same APEX. This is confusing apexd at runtime
and the device fails to boot.
To fix this, when building a non-prebuilt APEX, the prebuilt APEX might
have been installed by the previous build is deleted.
Bug: 138146044
Test: lunch aosp_cf_x86_pasan; m && SANITIZE_TARGET='address' m
check that out/target/product/vsoc_x86/system/apex has
com.android.*.apex only.
Change-Id: Ib5a021a297cf0173ea5a3b50e9398b1cf295c558
diff --git a/android/prebuilt.go b/android/prebuilt.go
index b674153..8559df9 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -29,7 +29,7 @@
blueprint.BaseDependencyTag
}
-var prebuiltDepTag prebuiltDependencyTag
+var PrebuiltDepTag prebuiltDependencyTag
type PrebuiltProperties struct {
// When prefer is set to true the prebuilt will be used instead of any source module with
@@ -127,7 +127,7 @@
p := m.Prebuilt()
name := m.base().BaseModuleName()
if ctx.OtherModuleExists(name) {
- ctx.AddReverseDependency(ctx.Module(), prebuiltDepTag, name)
+ ctx.AddReverseDependency(ctx.Module(), PrebuiltDepTag, name)
p.properties.SourceExists = true
} else {
ctx.Rename(name)
@@ -147,7 +147,7 @@
p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
}
} else if s, ok := ctx.Module().(Module); ok {
- ctx.VisitDirectDepsWithTag(prebuiltDepTag, func(m Module) {
+ ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(m Module) {
p := m.(PrebuiltInterface).Prebuilt()
if p.usePrebuilt(ctx, s) {
p.properties.UsePrebuilt = true