Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 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 | |
Nikita Ioffe | e50da56 | 2019-04-01 17:22:39 +0100 | [diff] [blame] | 15 | // Build rules to build shim apexes. |
| 16 | |
| 17 | genrule { |
| 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 | |
| 23 | genrule { |
| 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 Ioffe | d9a25d4 | 2019-03-26 01:37:03 +0000 | [diff] [blame] | 30 | |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 31 | apex_key { |
| 32 | name: "com.android.apex.cts.shim.key", |
Nikita Ioffe | e50da56 | 2019-04-01 17:22:39 +0100 | [diff] [blame] | 33 | private_key: ":com.android.apex.cts.shim.pem", |
| 34 | public_key: ":com.android.apex.cts.shim.pubkey", |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 35 | installable: false, |
| 36 | } |
| 37 | |
| 38 | genrule { |
Nikita Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 39 | name: "generate_hash_of_dev_null", |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 40 | out: ["hash.txt"], |
| 41 | cmd: "sha512sum -b /dev/null | cut -d' ' -f1 | tee $(out)", |
| 42 | } |
| 43 | |
| 44 | prebuilt_etc { |
Nikita Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 45 | name: "hash_of_dev_null", |
| 46 | src: ":generate_hash_of_dev_null", |
Nikita Ioffe | d9a25d4 | 2019-03-26 01:37:03 +0000 | [diff] [blame] | 47 | filename: "hash.txt", |
| 48 | installable: false, |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | apex { |
Nikita Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 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 | |
| 60 | apex { |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 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", |
Nikita Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 65 | prebuilts: ["hash_of_dev_null"], |
Nikita Ioffe | df07441 | 2019-03-20 07:56:52 +0000 | [diff] [blame] | 66 | installable: false, |
| 67 | } |
| 68 | |
| 69 | genrule { |
Nikita Ioffe | d9a25d4 | 2019-03-26 01:37:03 +0000 | [diff] [blame] | 70 | name: "generate_empty_hash", |
| 71 | out: ["hash.txt"], |
| 72 | cmd: "touch $(out)", |
| 73 | } |
| 74 | |
| 75 | prebuilt_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. |
| 84 | apex { |
| 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 Ioffe | 2cbca0e | 2019-03-27 19:12:11 +0000 | [diff] [blame] | 93 | prebuilt_etc { |
| 94 | name: "apex_shim_additional_file", |
| 95 | src: "additional_file", |
| 96 | filename: "additional_file", |
| 97 | installable: false, |
| 98 | } |
| 99 | |
| 100 | apex { |
| 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 Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 105 | prebuilts: ["hash_of_dev_null", "apex_shim_additional_file"], |
Nikita Ioffe | 2cbca0e | 2019-03-27 19:12:11 +0000 | [diff] [blame] | 106 | installable: false, |
| 107 | } |
| 108 | |
| 109 | prebuilt_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 | |
| 117 | apex { |
| 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 Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 122 | prebuilts: ["hash_of_dev_null", "apex_shim_additional_folder"], |
Nikita Ioffe | 2cbca0e | 2019-03-27 19:12:11 +0000 | [diff] [blame] | 123 | installable: false, |
| 124 | } |
| 125 | |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 126 | apex { |
| 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 Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 131 | prebuilts: ["hash_of_dev_null"], |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 132 | installable: false, |
| 133 | } |
| 134 | |
| 135 | apex { |
| 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 Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 140 | prebuilts: ["hash_of_dev_null"], |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 141 | installable: false, |
| 142 | } |
| 143 | |
| 144 | genrule { |
Nikita Ioffe | 98054d7 | 2019-04-03 14:18:22 +0100 | [diff] [blame] | 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", |
Nikita Ioffe | 0737f4a | 2019-04-23 11:22:38 +0100 | [diff] [blame] | 152 | ":com.android.apex.cts.shim.v3", |
Nikita Ioffe | 98054d7 | 2019-04-03 14:18:22 +0100 | [diff] [blame] | 153 | ], |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 154 | out: ["hash.txt"], |
| 155 | cmd: "sha512sum -b $(in) | cut -d' ' -f1 | tee $(out)", |
| 156 | } |
| 157 | |
| 158 | prebuilt_etc { |
Nikita Ioffe | 98054d7 | 2019-04-03 14:18:22 +0100 | [diff] [blame] | 159 | name: "hash_v1", |
| 160 | src: ":generate_hash_v1", |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 161 | filename: "hash.txt", |
| 162 | installable: false, |
| 163 | } |
| 164 | |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 165 | apex { |
Nikita Ioffe | 98054d7 | 2019-04-03 14:18:22 +0100 | [diff] [blame] | 166 | name: "com.android.apex.cts.shim.v1", |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 167 | manifest: "manifest.json", |
| 168 | file_contexts: "apex.test", |
| 169 | key: "com.android.apex.cts.shim.key", |
Nikita Ioffe | 98054d7 | 2019-04-03 14:18:22 +0100 | [diff] [blame] | 170 | prebuilts: ["hash_v1"], |
Nikita Ioffe | 69a1bc5 | 2019-03-29 14:55:29 +0000 | [diff] [blame] | 171 | installable: false, |
| 172 | } |
Nikita Ioffe | a6fe0e5 | 2019-04-23 20:51:46 +0100 | [diff] [blame] | 173 | |
| 174 | genrule { |
| 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 | |
| 180 | genrule { |
| 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 | |
| 188 | apex_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 | |
| 195 | apex { |
| 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 | } |