Merge "apex.custom_sign_tool property" am: cae893ae40 am: e18be41278 am: f11c7c9e18 am: 4c549b825a am: a18a62bafa

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1869522

Change-Id: Id484c324ea7c73ddb8e610c476535bb11785202d
This commit is contained in:
Treehugger Robot
2021-10-30 01:06:39 +00:00
committed by Automerger Merge Worker
3 changed files with 35 additions and 3 deletions

View File

@@ -178,6 +178,10 @@ type apexBundleProperties struct {
// used in tests.
Test_only_force_compression *bool
// Put extra tags (signer=<value>) to apexkeys.txt, so that release tools can sign this apex
// with the tool to sign payload contents.
Custom_sign_tool *string
// Canonical name of this APEX bundle. Used to determine the path to the
// activated APEX on device (i.e. /apex/<apexVariationName>), and used for the
// apex mutator variations. For override_apex modules, this is the name of the

View File

@@ -7685,6 +7685,28 @@ func TestApexKeysTxt(t *testing.T) {
name: "myapex",
key: "myapex.key",
updatable: false,
custom_sign_tool: "sign_myapex",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
`)
apexKeysText := ctx.SingletonForTests("apex_keys_text")
content := apexKeysText.MaybeDescription("apexkeys.txt").BuildParams.Args["content"]
ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system_ext" sign_tool="sign_myapex"`)
}
func TestApexKeysTxtOverrides(t *testing.T) {
ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
updatable: false,
custom_sign_tool: "sign_myapex",
}
apex_key {

View File

@@ -123,13 +123,18 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
containerCertificate string
containerPrivateKey string
partition string
signTool string
}
toString := func(e apexKeyEntry) string {
format := "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\n"
signTool := ""
if e.signTool != "" {
signTool = fmt.Sprintf(" sign_tool=%q", e.signTool)
}
format := "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q%s\n"
if e.presigned {
return fmt.Sprintf(format, e.name, "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", e.partition)
return fmt.Sprintf(format, e.name, "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", e.partition, signTool)
} else {
return fmt.Sprintf(format, e.name, e.publicKey, e.privateKey, e.containerCertificate, e.containerPrivateKey, e.partition)
return fmt.Sprintf(format, e.name, e.publicKey, e.privateKey, e.containerCertificate, e.containerPrivateKey, e.partition, signTool)
}
}
@@ -145,6 +150,7 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
containerCertificate: pem.String(),
containerPrivateKey: key.String(),
partition: m.PartitionTag(ctx.DeviceConfig()),
signTool: proptools.String(m.properties.Custom_sign_tool),
}
}
})