Remove "flattened" apexes

Now soong doesn't build "flattened" apexes.

Bug: 279835185
Test: m nothing (soong tests)
Test: m && launch_cvd (cuttlefish)
Change-Id: Id3c540ece1a15cecacc185da9aa17285edd2f493
This commit is contained in:
Jooyung Han
2023-06-20 16:25:59 +09:00
parent be24d2733c
commit eec1b3fe26
7 changed files with 98 additions and 317 deletions

View File

@@ -382,23 +382,6 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output
rule.Command().Text("echo").Text("/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output)
rule.Command().Text("echo").Text("/").Text(forceLabel).Text(">>").Output(output)
}
case flattenedApex:
// For flattened apexes, install path should be prepended.
// File_contexts file should be emiited to make via LOCAL_FILE_CONTEXTS
// so that it can be merged into file_contexts.bin
apexPath := android.InstallPathToOnDevicePath(ctx, a.installDir.Join(ctx, a.Name()))
apexPath = strings.ReplaceAll(apexPath, ".", `\\.`)
// remove old file
rule.Command().Text("rm").FlagWithOutput("-f ", output)
// copy file_contexts
rule.Command().Text("awk").Text(`'/object_r/{printf("` + apexPath + `%s\n", $0)}'`).Input(fileContexts).Text(">").Output(output)
// new line
rule.Command().Text("echo").Text(">>").Output(output)
if !useFileContextsAsIs {
// force-label /apex_manifest.pb and /
rule.Command().Text("echo").Text(apexPath + "/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output)
rule.Command().Text("echo").Text(apexPath + "/").Text(forceLabel).Text(">>").Output(output)
}
default:
panic(fmt.Errorf("unsupported type %v", a.properties.ApexType))
}
@@ -479,8 +462,8 @@ func markManifestTestOnly(ctx android.ModuleContext, androidManifestFile android
})
}
// buildUnflattendApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
// buildApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildApex(ctx android.ModuleContext) {
apexType := a.properties.ApexType
suffix := apexType.suffix()
apexName := a.BaseModuleName()
@@ -963,49 +946,6 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
a.installedFilesFile = a.buildInstalledFilesFile(ctx, a.outputFile, imageDir)
}
// buildFlattenedApex creates rules for a flattened APEX. Flattened APEX actually doesn't have a
// single output file. It is a phony target for all the files under /system/apex/<name> directory.
// This function creates the installation rules for the files.
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
bundleName := a.Name()
installedSymlinks := append(android.InstallPaths(nil), a.compatSymlinks...)
if a.installable() {
for _, fi := range a.filesInfo {
dir := filepath.Join("apex", bundleName, fi.installDir)
installDir := android.PathForModuleInstall(ctx, dir)
if a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform() {
pathOnDevice := filepath.Join("/", fi.partition, fi.path())
installedSymlinks = append(installedSymlinks,
ctx.InstallAbsoluteSymlink(installDir, fi.stem(), pathOnDevice))
} else {
if fi.class == appSet {
as := fi.module.(*java.AndroidAppSet)
ctx.InstallFileWithExtraFilesZip(installDir, as.BaseModuleName()+".apk",
as.OutputFile(), as.PackedAdditionalOutputs())
} else {
target := ctx.InstallFile(installDir, fi.stem(), fi.builtFile)
for _, sym := range fi.symlinks {
installedSymlinks = append(installedSymlinks,
ctx.InstallSymlink(installDir, sym, target))
}
}
}
}
// Create install rules for the files added in GenerateAndroidBuildActions after
// buildFlattenedApex is called. Add the links to system libs (if any) as dependencies
// of the apex_manifest.pb file since it is always present.
dir := filepath.Join("apex", bundleName)
installDir := android.PathForModuleInstall(ctx, dir)
ctx.InstallFile(installDir, "apex_manifest.pb", a.manifestPbOut, installedSymlinks.Paths()...)
ctx.InstallFile(installDir, "apex_pubkey", a.publicKeyFile)
}
a.fileContexts = a.buildFileContexts(ctx)
a.outputFile = android.PathForModuleInstall(ctx, "apex", bundleName)
}
// getCertificateAndPrivateKey retrieves the cert and the private key that will be used to sign
// the zip container of this APEX. See the description of the 'certificate' property for how
// the cert and the private key are found.