Merge "Add "legacy_android10_support" to "apex""
This commit is contained in:
@@ -343,6 +343,10 @@ type apexBundleProperties struct {
|
|||||||
// Whenever apex_payload.img of the APEX should include dm-verity hashtree.
|
// Whenever apex_payload.img of the APEX should include dm-verity hashtree.
|
||||||
// Should be only used in tests#.
|
// Should be only used in tests#.
|
||||||
Test_only_no_hashtree *bool
|
Test_only_no_hashtree *bool
|
||||||
|
|
||||||
|
// Whether this APEX should support Android10. Default is false. If this is set true, then apex_manifest.json is bundled as well
|
||||||
|
// because Android10 requires legacy apex_manifest.json instead of apex_manifest.pb
|
||||||
|
Legacy_android10_support *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type apexTargetBundleProperties struct {
|
type apexTargetBundleProperties struct {
|
||||||
@@ -507,9 +511,7 @@ type apexBundle struct {
|
|||||||
artApex bool
|
artApex bool
|
||||||
primaryApexType bool
|
primaryApexType bool
|
||||||
|
|
||||||
// intermediate path for apex_manifest.json
|
|
||||||
manifestJsonOut android.WritablePath
|
manifestJsonOut android.WritablePath
|
||||||
manifestJsonFullOut android.WritablePath
|
|
||||||
manifestPbOut android.WritablePath
|
manifestPbOut android.WritablePath
|
||||||
|
|
||||||
// list of commands to create symlinks for backward compatibility
|
// list of commands to create symlinks for backward compatibility
|
||||||
|
@@ -140,8 +140,8 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||||||
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
|
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
|
||||||
})
|
})
|
||||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
|
||||||
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
|
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
|
||||||
|
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
|
||||||
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
|
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()
|
||||||
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
ctx.BottomUp("version", cc.VersionMutator).Parallel()
|
||||||
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
ctx.BottomUp("begin", cc.BeginMutator).Parallel()
|
||||||
@@ -547,9 +547,10 @@ func TestApexManifest(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
|
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
|
||||||
module.Output("apex_manifest.pb")
|
args := module.Rule("apexRule").Args
|
||||||
module.Output("apex_manifest.json")
|
if manifest := args["manifest"]; manifest != module.Output("apex_manifest.pb").Output.String() {
|
||||||
module.Output("apex_manifest_full.json")
|
t.Error("manifest should be apex_manifest.pb, but " + manifest)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicZipApex(t *testing.T) {
|
func TestBasicZipApex(t *testing.T) {
|
||||||
@@ -2452,7 +2453,7 @@ func TestApexWithTests(t *testing.T) {
|
|||||||
ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.json.myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex\n")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
|
||||||
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
|
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
|
||||||
}
|
}
|
||||||
@@ -3034,6 +3035,26 @@ func TestOverrideApex(t *testing.T) {
|
|||||||
ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")
|
ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLegacyAndroid10Support(t *testing.T) {
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
legacy_android10_support: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
|
||||||
|
args := module.Rule("apexRule").Args
|
||||||
|
ensureContains(t, args["opt_flags"], "--manifest_json "+module.Output("apex_manifest.json").Output.String())
|
||||||
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
run := func() int {
|
run := func() int {
|
||||||
setUp()
|
setUp()
|
||||||
|
@@ -103,7 +103,6 @@ var (
|
|||||||
`(. ${out}.copy_commands) && ` +
|
`(. ${out}.copy_commands) && ` +
|
||||||
`APEXER_TOOL_PATH=${tool_path} ` +
|
`APEXER_TOOL_PATH=${tool_path} ` +
|
||||||
`${apexer} --force --manifest ${manifest} ` +
|
`${apexer} --force --manifest ${manifest} ` +
|
||||||
`--manifest_json ${manifest_json} --manifest_json_full ${manifest_json_full} ` +
|
|
||||||
`--file_contexts ${file_contexts} ` +
|
`--file_contexts ${file_contexts} ` +
|
||||||
`--canned_fs_config ${canned_fs_config} ` +
|
`--canned_fs_config ${canned_fs_config} ` +
|
||||||
`--payload_type image ` +
|
`--payload_type image ` +
|
||||||
@@ -114,22 +113,20 @@ var (
|
|||||||
Rspfile: "${out}.copy_commands",
|
Rspfile: "${out}.copy_commands",
|
||||||
RspfileContent: "${copy_commands}",
|
RspfileContent: "${copy_commands}",
|
||||||
Description: "APEX ${image_dir} => ${out}",
|
Description: "APEX ${image_dir} => ${out}",
|
||||||
}, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags",
|
}, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest")
|
||||||
"manifest", "manifest_json", "manifest_json_full",
|
|
||||||
)
|
|
||||||
|
|
||||||
zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
|
zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{
|
||||||
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
|
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
|
||||||
`(. ${out}.copy_commands) && ` +
|
`(. ${out}.copy_commands) && ` +
|
||||||
`APEXER_TOOL_PATH=${tool_path} ` +
|
`APEXER_TOOL_PATH=${tool_path} ` +
|
||||||
`${apexer} --force --manifest ${manifest} --manifest_json_full ${manifest_json_full} ` +
|
`${apexer} --force --manifest ${manifest} ` +
|
||||||
`--payload_type zip ` +
|
`--payload_type zip ` +
|
||||||
`${image_dir} ${out} `,
|
`${image_dir} ${out} `,
|
||||||
CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
|
CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"},
|
||||||
Rspfile: "${out}.copy_commands",
|
Rspfile: "${out}.copy_commands",
|
||||||
RspfileContent: "${copy_commands}",
|
RspfileContent: "${copy_commands}",
|
||||||
Description: "ZipAPEX ${image_dir} => ${out}",
|
Description: "ZipAPEX ${image_dir} => ${out}",
|
||||||
}, "tool_path", "image_dir", "copy_commands", "manifest", "manifest_json_full")
|
}, "tool_path", "image_dir", "copy_commands", "manifest")
|
||||||
|
|
||||||
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
|
apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
@@ -171,7 +168,7 @@ var (
|
|||||||
func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, requireNativeLibs []string) {
|
func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, requireNativeLibs []string) {
|
||||||
manifestSrc := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
|
manifestSrc := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
|
||||||
|
|
||||||
a.manifestJsonFullOut = android.PathForModuleOut(ctx, "apex_manifest_full.json")
|
manifestJsonFullOut := android.PathForModuleOut(ctx, "apex_manifest_full.json")
|
||||||
|
|
||||||
// put dependency({provide|require}NativeLibs) in apex_manifest.json
|
// put dependency({provide|require}NativeLibs) in apex_manifest.json
|
||||||
provideNativeLibs = android.SortedUniqueStrings(provideNativeLibs)
|
provideNativeLibs = android.SortedUniqueStrings(provideNativeLibs)
|
||||||
@@ -186,7 +183,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
|
|||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: apexManifestRule,
|
Rule: apexManifestRule,
|
||||||
Input: manifestSrc,
|
Input: manifestSrc,
|
||||||
Output: a.manifestJsonFullOut,
|
Output: manifestJsonFullOut,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"provideNativeLibs": strings.Join(provideNativeLibs, " "),
|
"provideNativeLibs": strings.Join(provideNativeLibs, " "),
|
||||||
"requireNativeLibs": strings.Join(requireNativeLibs, " "),
|
"requireNativeLibs": strings.Join(requireNativeLibs, " "),
|
||||||
@@ -194,20 +191,22 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if proptools.Bool(a.properties.Legacy_android10_support) {
|
||||||
// b/143654022 Q apexd can't understand newly added keys in apex_manifest.json
|
// b/143654022 Q apexd can't understand newly added keys in apex_manifest.json
|
||||||
// prepare stripped-down version so that APEX modules built from R+ can be installed to Q
|
// prepare stripped-down version so that APEX modules built from R+ can be installed to Q
|
||||||
a.manifestJsonOut = android.PathForModuleOut(ctx, "apex_manifest.json")
|
a.manifestJsonOut = android.PathForModuleOut(ctx, "apex_manifest.json")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: stripApexManifestRule,
|
Rule: stripApexManifestRule,
|
||||||
Input: a.manifestJsonFullOut,
|
Input: manifestJsonFullOut,
|
||||||
Output: a.manifestJsonOut,
|
Output: a.manifestJsonOut,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// from R+, protobuf binary format (.pb) is the standard format for apex_manifest
|
// from R+, protobuf binary format (.pb) is the standard format for apex_manifest
|
||||||
a.manifestPbOut = android.PathForModuleOut(ctx, "apex_manifest.pb")
|
a.manifestPbOut = android.PathForModuleOut(ctx, "apex_manifest.pb")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: pbApexManifestRule,
|
Rule: pbApexManifestRule,
|
||||||
Input: a.manifestJsonFullOut,
|
Input: manifestJsonFullOut,
|
||||||
Output: a.manifestPbOut,
|
Output: a.manifestPbOut,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -256,7 +255,10 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
copyCommands := []string{}
|
copyCommands := []string{}
|
||||||
emitCommands := []string{}
|
emitCommands := []string{}
|
||||||
imageContentFile := android.PathForModuleOut(ctx, a.Name()+"-content.txt")
|
imageContentFile := android.PathForModuleOut(ctx, a.Name()+"-content.txt")
|
||||||
|
emitCommands = append(emitCommands, "echo ./apex_manifest.pb >> "+imageContentFile.String())
|
||||||
|
if proptools.Bool(a.properties.Legacy_android10_support) {
|
||||||
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
emitCommands = append(emitCommands, "echo ./apex_manifest.json >> "+imageContentFile.String())
|
||||||
|
}
|
||||||
for i, src := range filesToCopy {
|
for i, src := range filesToCopy {
|
||||||
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
dest := filepath.Join(a.filesInfo[i].installDir, src.Base())
|
||||||
emitCommands = append(emitCommands, "echo './"+dest+"' >> "+imageContentFile.String())
|
emitCommands = append(emitCommands, "echo './"+dest+"' >> "+imageContentFile.String())
|
||||||
@@ -271,7 +273,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
|
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
|
||||||
|
|
||||||
implicitInputs := append(android.Paths(nil), filesToCopy...)
|
implicitInputs := append(android.Paths(nil), filesToCopy...)
|
||||||
implicitInputs = append(implicitInputs, a.manifestPbOut, a.manifestJsonFullOut, a.manifestJsonOut)
|
implicitInputs = append(implicitInputs, a.manifestPbOut)
|
||||||
|
|
||||||
if a.properties.Whitelisted_files != nil {
|
if a.properties.Whitelisted_files != nil {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
@@ -394,6 +396,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
optFlags = append(optFlags, "--do_not_check_keyname")
|
optFlags = append(optFlags, "--do_not_check_keyname")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if proptools.Bool(a.properties.Legacy_android10_support) {
|
||||||
|
implicitInputs = append(implicitInputs, a.manifestJsonOut)
|
||||||
|
optFlags = append(optFlags, "--manifest_json "+a.manifestJsonOut.String())
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: apexRule,
|
Rule: apexRule,
|
||||||
Implicits: implicitInputs,
|
Implicits: implicitInputs,
|
||||||
@@ -403,8 +410,6 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
|
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
|
||||||
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
||||||
"copy_commands": strings.Join(copyCommands, " && "),
|
"copy_commands": strings.Join(copyCommands, " && "),
|
||||||
"manifest_json_full": a.manifestJsonFullOut.String(),
|
|
||||||
"manifest_json": a.manifestJsonOut.String(),
|
|
||||||
"manifest": a.manifestPbOut.String(),
|
"manifest": a.manifestPbOut.String(),
|
||||||
"file_contexts": a.fileContexts.String(),
|
"file_contexts": a.fileContexts.String(),
|
||||||
"canned_fs_config": cannedFsConfig.String(),
|
"canned_fs_config": cannedFsConfig.String(),
|
||||||
@@ -444,7 +449,6 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
|||||||
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
"image_dir": android.PathForModuleOut(ctx, "image"+suffix).String(),
|
||||||
"copy_commands": strings.Join(copyCommands, " && "),
|
"copy_commands": strings.Join(copyCommands, " && "),
|
||||||
"manifest": a.manifestPbOut.String(),
|
"manifest": a.manifestPbOut.String(),
|
||||||
"manifest_json_full": a.manifestJsonFullOut.String(),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -505,9 +509,8 @@ func (a *apexBundle) setCertificateAndPrivateKey(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
|
func (a *apexBundle) buildFilesInfo(ctx android.ModuleContext) {
|
||||||
if a.installable() {
|
if a.installable() {
|
||||||
// For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
|
// For flattened APEX, do nothing but make sure that APEX manifest and apex_pubkey are also copied along
|
||||||
// with other ordinary files.
|
// with other ordinary files.
|
||||||
a.filesInfo = append(a.filesInfo, newApexFile(a.manifestJsonOut, "apex_manifest.json."+a.Name()+a.suffix, ".", etc, nil))
|
|
||||||
a.filesInfo = append(a.filesInfo, newApexFile(a.manifestPbOut, "apex_manifest.pb."+a.Name()+a.suffix, ".", etc, nil))
|
a.filesInfo = append(a.filesInfo, newApexFile(a.manifestPbOut, "apex_manifest.pb."+a.Name()+a.suffix, ".", etc, nil))
|
||||||
|
|
||||||
// rename to apex_pubkey
|
// rename to apex_pubkey
|
||||||
|
Reference in New Issue
Block a user