• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
15// 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}
30
31apex_key {
32  name: "com.android.apex.cts.shim.key",
33  private_key: ":com.android.apex.cts.shim.pem",
34  public_key: ":com.android.apex.cts.shim.pubkey",
35  installable: false,
36}
37
38genrule {
39  name: "generate_hash_of_dev_null",
40  out: ["hash.txt"],
41  cmd: "sha512sum -b /dev/null | cut -d' ' -f1 | tee $(out)",
42}
43
44prebuilt_etc {
45  name: "hash_of_dev_null",
46  src: ":generate_hash_of_dev_null",
47  filename: "hash.txt",
48  installable: false,
49}
50
51apex {
52  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 {
61  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",
65  prebuilts: ["hash_of_dev_null"],
66  installable: false,
67}
68
69genrule {
70  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
93prebuilt_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",
105  prebuilts: ["hash_of_dev_null", "apex_shim_additional_file"],
106  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",
122  prebuilts: ["hash_of_dev_null", "apex_shim_additional_folder"],
123  installable: false,
124}
125
126apex {
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",
131  prebuilts: ["hash_of_dev_null"],
132  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",
140  prebuilts: ["hash_of_dev_null"],
141  installable: false,
142}
143
144genrule {
145  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",
152    ":com.android.apex.cts.shim.v3",
153  ],
154  out: ["hash.txt"],
155  cmd: "sha512sum -b $(in) | cut -d' ' -f1 | tee $(out)",
156}
157
158prebuilt_etc {
159  name: "hash_v1",
160  src: ":generate_hash_v1",
161  filename: "hash.txt",
162  installable: false,
163}
164
165apex {
166  name: "com.android.apex.cts.shim.v1",
167  manifest: "manifest.json",
168  file_contexts: "apex.test",
169  key: "com.android.apex.cts.shim.key",
170  prebuilts: ["hash_v1"],
171  installable: false,
172}
173
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}
203