product_specific support for apex_key
apex_key, when with product_specific: true, is installed to /product/etc/security/apex. Bug: 128519063 Test: m (apex_test.go amended) Change-Id: I39e8ac1c486c734dfe0555cd1874468d75e71f34
This commit is contained in:
@@ -827,7 +827,7 @@ func TestKeys(t *testing.T) {
|
|||||||
`)
|
`)
|
||||||
|
|
||||||
// check the APEX keys
|
// check the APEX keys
|
||||||
keys := ctx.ModuleForTests("myapex.key", "").Module().(*apexKey)
|
keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey)
|
||||||
|
|
||||||
if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
|
if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
|
||||||
t.Errorf("public key %q is not %q", keys.public_key_file.String(),
|
t.Errorf("public key %q is not %q", keys.public_key_file.String(),
|
||||||
@@ -1144,3 +1144,43 @@ func TestApexWithShBinary(t *testing.T) {
|
|||||||
|
|
||||||
ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh")
|
ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexInProductPartition(t *testing.T) {
|
||||||
|
ctx := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
|
product_specific: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
product_specific: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
apex := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle)
|
||||||
|
expected := "target/product/test_device/product/apex"
|
||||||
|
actual := apex.installDir.RelPathString()
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
10
apex/key.go
10
apex/key.go
@@ -17,6 +17,7 @@ package apex
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -38,6 +39,7 @@ type apexKey struct {
|
|||||||
|
|
||||||
public_key_file android.Path
|
public_key_file android.Path
|
||||||
private_key_file android.Path
|
private_key_file android.Path
|
||||||
|
installDir android.OutputPath
|
||||||
|
|
||||||
keyName string
|
keyName string
|
||||||
}
|
}
|
||||||
@@ -56,7 +58,8 @@ type apexKeyProperties struct {
|
|||||||
func apexKeyFactory() android.Module {
|
func apexKeyFactory() android.Module {
|
||||||
module := &apexKey{}
|
module := &apexKey{}
|
||||||
module.AddProperties(&module.properties)
|
module.AddProperties(&module.properties)
|
||||||
android.InitAndroidModule(module)
|
// This module is device-only
|
||||||
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +89,9 @@ func (m *apexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
m.keyName = pubKeyName
|
m.keyName = pubKeyName
|
||||||
|
|
||||||
|
m.installDir = android.PathForModuleInstall(ctx, "etc/security/apex")
|
||||||
if m.installable() {
|
if m.installable() {
|
||||||
ctx.InstallFile(android.PathForModuleInstall(ctx, "etc/security/apex"), m.keyName, m.public_key_file)
|
ctx.InstallFile(m.installDir, m.keyName, m.public_key_file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +101,7 @@ func (m *apexKey) AndroidMk() android.AndroidMkData {
|
|||||||
OutputFile: android.OptionalPathForPath(m.public_key_file),
|
OutputFile: android.OptionalPathForPath(m.public_key_file),
|
||||||
Extra: []android.AndroidMkExtraFunc{
|
Extra: []android.AndroidMkExtraFunc{
|
||||||
func(w io.Writer, outputFile android.Path) {
|
func(w io.Writer, outputFile android.Path) {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(TARGET_OUT)/etc/security/apex")
|
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_INSTALLED_MODULE_STEM :=", m.keyName)
|
||||||
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !m.installable())
|
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !m.installable())
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user