diff options
author | Jiyong Park <jiyong@google.com> | 2019-04-01 11:15:50 +0900 |
---|---|---|
committer | Jiyong Park <jiyong@google.com> | 2019-04-01 19:24:31 +0900 |
commit | 42cca6c95175d43ea85088181f22f9d2b3d3b583 (patch) | |
tree | e65d6bf35185a959b2ada2ac705d21c22f6a0578 /apex | |
parent | 51e265c5dd91dd5acb94de18c97e20c15d0b1038 (diff) | |
download | build_soong-42cca6c95175d43ea85088181f22f9d2b3d3b583.tar.gz build_soong-42cca6c95175d43ea85088181f22f9d2b3d3b583.tar.bz2 build_soong-42cca6c95175d43ea85088181f22f9d2b3d3b583.zip |
Always bundle the public key for APEX
The public key associated with an APEX is always included in the APEX.
Obviously, the public keys are no longer installed to
/system/etc/security/apex
Bug: 128344735
Test: m
Change-Id: I1e1aef1d32597a447b57d49ab80bbfb921fa8178
Diffstat (limited to 'apex')
-rw-r--r-- | apex/apex.go | 28 | ||||
-rw-r--r-- | apex/apex_test.go | 12 | ||||
-rw-r--r-- | apex/key.go | 24 |
3 files changed, 19 insertions, 45 deletions
diff --git a/apex/apex.go b/apex/apex.go index e07fae06..949457ab 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -396,9 +396,8 @@ type apexBundle struct { outputFiles map[apexPackaging]android.WritablePath installDir android.OutputPath - public_key_file android.Path - private_key_file android.Path - bundle_public_key bool + public_key_file android.Path + private_key_file android.Path container_certificate_file android.Path container_private_key_file android.Path @@ -746,10 +745,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { if key, ok := child.(*apexKey); ok { a.private_key_file = key.private_key_file a.public_key_file = key.public_key_file - // If the key is not installed, bundled it with the APEX. - // Note: this bundled key is valid only for non-production builds - // (eng/userdebug). - a.bundle_public_key = !key.installable() && ctx.Config().Debuggable() return false } else { ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) @@ -968,11 +963,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap optFlags := []string{} // Additional implicit inputs. - implicitInputs = append(implicitInputs, cannedFsConfig, fileContexts, a.private_key_file) - if a.bundle_public_key { - implicitInputs = append(implicitInputs, a.public_key_file) - optFlags = append(optFlags, "--pubkey "+a.public_key_file.String()) - } + implicitInputs = append(implicitInputs, cannedFsConfig, fileContexts, a.private_key_file, a.public_key_file) + optFlags = append(optFlags, "--pubkey "+a.public_key_file.String()) manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName()) if overridden { @@ -1057,7 +1049,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) { if a.installable() { - // For flattened APEX, do nothing but make sure that apex_manifest.json file is also copied along + // For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along // with other ordinary files. manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")) @@ -1070,6 +1062,15 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) { }) a.filesInfo = append(a.filesInfo, apexFile{copiedManifest, ctx.ModuleName() + ".apex_manifest.json", ".", etc, nil, nil}) + // rename to apex_pubkey + copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey") + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Input: a.public_key_file, + Output: copiedPubkey, + }) + a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, ctx.ModuleName() + ".apex_pubkey", ".", etc, nil, nil}) + if ctx.Config().FlattenApex() { for _, fi := range a.filesInfo { dir := filepath.Join("apex", ctx.ModuleName(), fi.installDir) @@ -1215,7 +1216,6 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString())) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) - fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key)) if a.installable() && a.mergedNoticeFile != nil { fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNoticeFile.String()) } diff --git a/apex/apex_test.go b/apex/apex_test.go index 1e8d5b44..46eabe1d 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -299,6 +299,10 @@ func TestBasicApex(t *testing.T) { `) apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") + + optFlags := apexRule.Args["opt_flags"] + ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey") + copyCmds := apexRule.Args["copy_commands"] // Ensure that main rule creates an output @@ -1197,14 +1201,6 @@ func TestApexInProductPartition(t *testing.T) { if actual != expected { t.Errorf("wrong install path. expected %q. actual %q", expected, actual) } - - apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) - expected = "target/product/test_device/product/etc/security/apex" - actual = apex_key.installDir.RelPathString() - if actual != expected { - t.Errorf("wrong install path. expected %q. actual %q", expected, actual) - } - } func TestApexKeyFromOtherModule(t *testing.T) { diff --git a/apex/key.go b/apex/key.go index fbd29bce..a627e4bc 100644 --- a/apex/key.go +++ b/apex/key.go @@ -16,8 +16,6 @@ package apex import ( "fmt" - "io" - "path/filepath" "strings" "android/soong/android" @@ -39,7 +37,6 @@ type apexKey struct { public_key_file android.Path private_key_file android.Path - installDir android.OutputPath keyName string } @@ -64,7 +61,7 @@ func apexKeyFactory() android.Module { } func (m *apexKey) installable() bool { - return m.properties.Installable == nil || proptools.Bool(m.properties.Installable) + return false } func (m *apexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -99,25 +96,6 @@ func (m *apexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) { return } m.keyName = pubKeyName - - m.installDir = android.PathForModuleInstall(ctx, "etc/security/apex") - if m.installable() { - ctx.InstallFile(m.installDir, m.keyName, m.public_key_file) - } -} - -func (m *apexKey) AndroidMk() android.AndroidMkData { - return android.AndroidMkData{ - Class: "ETC", - OutputFile: android.OptionalPathForPath(m.public_key_file), - Extra: []android.AndroidMkExtraFunc{ - func(w io.Writer, outputFile android.Path) { - fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", m.installDir.RelPathString())) - fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", m.keyName) - fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !m.installable()) - }, - }, - } } //////////////////////////////////////////////////////////////////////// |