blob: 71f847c494e544e897aa22c5fd4f10de628de0d6 [file] [log] [blame]
Nikita Ioffedf074412019-03-20 07:56:52 +00001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Nikita Ioffee50da562019-04-01 17:22:39 +010015// Build rules to build shim apexes.
16
17genrule {
18 name: "com.android.apex.cts.shim.pem",
19 out: ["com.android.apex.cts.shim.pem"],
20 cmd: "openssl genrsa -out $(out) 4096",
21}
22
23genrule {
24 name: "com.android.apex.cts.shim.pubkey",
25 srcs: [":com.android.apex.cts.shim.pem"],
26 out: ["com.android.apex.cts.shim.pubkey"],
27 tools: ["avbtool"],
28 cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)",
29}
Nikita Ioffed9a25d42019-03-26 01:37:03 +000030
Nikita Ioffedf074412019-03-20 07:56:52 +000031apex_key {
32 name: "com.android.apex.cts.shim.key",
Nikita Ioffee50da562019-04-01 17:22:39 +010033 private_key: ":com.android.apex.cts.shim.pem",
34 public_key: ":com.android.apex.cts.shim.pubkey",
Nikita Ioffedf074412019-03-20 07:56:52 +000035 installable: false,
36}
37
38genrule {
Nikita Ioffe0737f4a2019-04-23 11:22:38 +010039 name: "generate_hash_of_dev_null",
Nikita Ioffedf074412019-03-20 07:56:52 +000040 out: ["hash.txt"],
41 cmd: "sha512sum -b /dev/null | cut -d' ' -f1 | tee $(out)",
42}
43
44prebuilt_etc {
Nikita Ioffe0737f4a2019-04-23 11:22:38 +010045 name: "hash_of_dev_null",
46 src: ":generate_hash_of_dev_null",
Nikita Ioffed9a25d42019-03-26 01:37:03 +000047 filename: "hash.txt",
48 installable: false,
Nikita Ioffedf074412019-03-20 07:56:52 +000049}
50
51apex {
Nikita Ioffe0737f4a2019-04-23 11:22:38 +010052 name: "com.android.apex.cts.shim.v3",
53 manifest: "manifest_v3.json",
54 file_contexts: "apex.test",
55 key: "com.android.apex.cts.shim.key",
56 prebuilts: ["hash_of_dev_null"],
57 installable: false,
58}
59
60apex {
Nikita Ioffedf074412019-03-20 07:56:52 +000061 name: "com.android.apex.cts.shim.v2",
62 manifest: "manifest_v2.json",
63 file_contexts: "apex.test",
64 key: "com.android.apex.cts.shim.key",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +010065 prebuilts: ["hash_of_dev_null"],
Nikita Ioffedf074412019-03-20 07:56:52 +000066 installable: false,
67}
68
69genrule {
Nikita Ioffed9a25d42019-03-26 01:37:03 +000070 name: "generate_empty_hash",
71 out: ["hash.txt"],
72 cmd: "touch $(out)",
73}
74
75prebuilt_etc {
76 name: "empty_hash",
77 src: ":generate_empty_hash",
78 filename: "hash.txt",
79 installable: false,
80}
81
82// Use empty hash.txt to make sure that this apex has wrong SHA512, hence trying
83// to stage it should fail.
84apex {
85 name: "com.android.apex.cts.shim.v2_wrong_sha",
86 manifest: "manifest_v2.json",
87 file_contexts: "apex.test",
88 key: "com.android.apex.cts.shim.key",
89 prebuilts: ["empty_hash"],
90 installable: false,
91}
92
Nikita Ioffe2cbca0e2019-03-27 19:12:11 +000093prebuilt_etc {
94 name: "apex_shim_additional_file",
95 src: "additional_file",
96 filename: "additional_file",
97 installable: false,
98}
99
100apex {
101 name: "com.android.apex.cts.shim.v2_additional_file",
102 manifest: "manifest_v2.json",
103 file_contexts: "apex.test",
104 key: "com.android.apex.cts.shim.key",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +0100105 prebuilts: ["hash_of_dev_null", "apex_shim_additional_file"],
Nikita Ioffe2cbca0e2019-03-27 19:12:11 +0000106 installable: false,
107}
108
109prebuilt_etc {
110 name: "apex_shim_additional_folder",
111 src: "additional_file",
112 filename: "additional_file",
113 sub_dir: "additional_folder",
114 installable: false,
115}
116
117apex {
118 name: "com.android.apex.cts.shim.v2_additional_folder",
119 manifest: "manifest_v2.json",
120 file_contexts: "apex.test",
121 key: "com.android.apex.cts.shim.key",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +0100122 prebuilts: ["hash_of_dev_null", "apex_shim_additional_folder"],
Nikita Ioffe2cbca0e2019-03-27 19:12:11 +0000123 installable: false,
124}
125
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000126apex {
127 name: "com.android.apex.cts.shim.v2_with_pre_install_hook",
128 manifest: "manifest_v2_with_pre_install_hook.json",
129 file_contexts: "apex.test",
130 key: "com.android.apex.cts.shim.key",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +0100131 prebuilts: ["hash_of_dev_null"],
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000132 installable: false,
133}
134
135apex {
136 name: "com.android.apex.cts.shim.v2_with_post_install_hook",
137 manifest: "manifest_v2_with_post_install_hook.json",
138 file_contexts: "apex.test",
139 key: "com.android.apex.cts.shim.key",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +0100140 prebuilts: ["hash_of_dev_null"],
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000141 installable: false,
142}
143
144genrule {
Nikita Ioffe98054d72019-04-03 14:18:22 +0100145 name: "generate_hash_v1",
146 srcs: [
147 ":com.android.apex.cts.shim.v2",
148 ":com.android.apex.cts.shim.v2_additional_file",
149 ":com.android.apex.cts.shim.v2_additional_folder",
150 ":com.android.apex.cts.shim.v2_with_pre_install_hook",
151 ":com.android.apex.cts.shim.v2_with_post_install_hook",
Nikita Ioffe0737f4a2019-04-23 11:22:38 +0100152 ":com.android.apex.cts.shim.v3",
Nikita Ioffe98054d72019-04-03 14:18:22 +0100153 ],
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000154 out: ["hash.txt"],
155 cmd: "sha512sum -b $(in) | cut -d' ' -f1 | tee $(out)",
156}
157
158prebuilt_etc {
Nikita Ioffe98054d72019-04-03 14:18:22 +0100159 name: "hash_v1",
160 src: ":generate_hash_v1",
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000161 filename: "hash.txt",
162 installable: false,
163}
164
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000165apex {
Nikita Ioffe98054d72019-04-03 14:18:22 +0100166 name: "com.android.apex.cts.shim.v1",
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000167 manifest: "manifest.json",
168 file_contexts: "apex.test",
169 key: "com.android.apex.cts.shim.key",
Nikita Ioffe98054d72019-04-03 14:18:22 +0100170 prebuilts: ["hash_v1"],
Nikita Ioffe69a1bc52019-03-29 14:55:29 +0000171 installable: false,
172}
Nikita Ioffea6fe0e52019-04-23 20:51:46 +0100173
174genrule {
175 name: "com.android.apex.cts.shim_not_pre_installed.pem",
176 out: ["com.android.apex.cts.shim_not_pre_installed.pem"],
177 cmd: "openssl genrsa -out $(out) 4096",
178}
179
180genrule {
181 name: "com.android.apex.cts.shim_not_pre_installed.pubkey",
182 srcs: [":com.android.apex.cts.shim_not_pre_installed.pem"],
183 out: ["com.android.apex.cts.shim_not_pre_installed.pubkey"],
184 tools: ["avbtool"],
185 cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)",
186}
187
188apex_key {
189 name: "com.android.apex.cts.shim_not_pre_installed.key",
190 private_key: ":com.android.apex.cts.shim_not_pre_installed.pem",
191 public_key: ":com.android.apex.cts.shim_not_pre_installed.pubkey",
192 installable: false,
193}
194
195apex {
196 name: "com.android.apex.cts.shim_not_pre_installed",
197 manifest: "manifest_not_pre_installed.json",
198 file_contexts: "apex.test",
199 key: "com.android.apex.cts.shim_not_pre_installed.key",
200 prebuilts: ["hash_of_dev_null"],
201 installable: false,
202}