Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (C) 2023 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | if [ $# -ne 2 ]; then |
| 18 | echo "Usage: $0 <top> <ver>" |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | top=$1 |
| 23 | ver=$2 |
| 24 | |
Inseob Kim | 6f18a17 | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 25 | prebuilt_dir=$top/system/sepolicy/prebuilts/api/$ver |
| 26 | mkdir -p "$prebuilt_dir" |
| 27 | cp -r "$top/system/sepolicy/public/" "$prebuilt_dir" |
| 28 | cp -r "$top/system/sepolicy/private/" "$prebuilt_dir" |
Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 29 | |
Inseob Kim | 6f18a17 | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 30 | cat > "$prebuilt_dir/Android.bp" <<EOF |
Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 31 | // Automatically generated file, do not edit! |
| 32 | se_policy_conf { |
| 33 | name: "${ver}_plat_pub_policy.conf", |
Inseob Kim | 61036d9 | 2024-02-21 13:18:49 +0900 | [diff] [blame] | 34 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | 6b1db84 | 2024-03-19 11:07:30 +0900 | [diff] [blame] | 35 | srcs: [ |
| 36 | ":se_build_files{.plat_public_${ver}}", |
| 37 | ":se_build_files{.reqd_mask}", |
| 38 | ], |
Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 39 | installable: false, |
| 40 | build_variant: "user", |
| 41 | } |
| 42 | |
| 43 | se_policy_cil { |
| 44 | name: "${ver}_plat_pub_policy.cil", |
| 45 | src: ":${ver}_plat_pub_policy.conf", |
| 46 | filter_out: [":reqd_policy_mask.cil"], |
| 47 | secilc_check: false, |
| 48 | installable: false, |
| 49 | } |
| 50 | |
| 51 | se_policy_conf { |
| 52 | name: "${ver}_product_pub_policy.conf", |
Inseob Kim | 61036d9 | 2024-02-21 13:18:49 +0900 | [diff] [blame] | 53 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 54 | srcs: [ |
| 55 | ":se_build_files{.plat_public_${ver}}", |
| 56 | ":se_build_files{.system_ext_public_${ver}}", |
| 57 | ":se_build_files{.product_public_${ver}}", |
| 58 | ":se_build_files{.reqd_mask}", |
| 59 | ], |
| 60 | installable: false, |
| 61 | build_variant: "user", |
| 62 | } |
| 63 | |
| 64 | se_policy_cil { |
| 65 | name: "${ver}_product_pub_policy.cil", |
| 66 | src: ":${ver}_product_pub_policy.conf", |
| 67 | filter_out: [":reqd_policy_mask.cil"], |
| 68 | secilc_check: false, |
| 69 | installable: false, |
| 70 | } |
| 71 | |
| 72 | se_policy_conf { |
| 73 | name: "${ver}_plat_policy.conf", |
Inseob Kim | 61036d9 | 2024-02-21 13:18:49 +0900 | [diff] [blame] | 74 | defaults: ["se_policy_conf_flags_defaults"], |
Inseob Kim | d9fd42e | 2024-01-19 18:08:55 +0900 | [diff] [blame] | 75 | srcs: [ |
| 76 | ":se_build_files{.plat_public_${ver}}", |
| 77 | ":se_build_files{.plat_private_${ver}}", |
| 78 | ":se_build_files{.system_ext_public_${ver}}", |
| 79 | ":se_build_files{.system_ext_private_${ver}}", |
| 80 | ":se_build_files{.product_public_${ver}}", |
| 81 | ":se_build_files{.product_private_${ver}}", |
| 82 | ], |
| 83 | installable: false, |
| 84 | build_variant: "user", |
| 85 | } |
| 86 | |
| 87 | se_policy_cil { |
| 88 | name: "${ver}_plat_policy.cil", |
| 89 | src: ":${ver}_plat_policy.conf", |
| 90 | additional_cil_files: [":sepolicy_technical_debt{.plat_private_${ver}}"], |
| 91 | installable: false, |
| 92 | } |
| 93 | |
| 94 | se_policy_binary { |
| 95 | name: "${ver}_plat_policy", |
| 96 | srcs: [":${ver}_plat_policy.cil"], |
| 97 | installable: false, |
| 98 | dist: { |
| 99 | targets: ["base-sepolicy-files-for-mapping"], |
| 100 | }, |
| 101 | } |
| 102 | EOF |
Inseob Kim | 6f18a17 | 2024-03-28 17:52:32 +0900 | [diff] [blame] | 103 | |
| 104 | # Build general_sepolicy.conf, plat_sepolicy.cil, and mapping file for CTS |
| 105 | DIST_DIR=out/dist $top/build/soong/soong_ui.bash --make-mode dist sepolicy_finalize |
| 106 | |
| 107 | cp "$top/out/dist/plat_sepolicy.cil" "$prebuilt_dir/${ver}_plat_sepolicy.cil" |
| 108 | cp "$top/out/dist/general_sepolicy.conf" "$prebuilt_dir/${ver}_general_sepolicy.conf" |
| 109 | cp "$top/out/dist/$ver.cil" "$prebuilt_dir/${ver}_mapping.cil" |
| 110 | |
| 111 | cat >> "$prebuilt_dir/Android.bp" <<EOF |
| 112 | |
| 113 | filegroup { |
| 114 | name: "${ver}_sepolicy_cts_data", |
| 115 | srcs: [ |
| 116 | "${ver}_general_sepolicy.conf", |
| 117 | "${ver}_plat_sepolicy.cil", |
| 118 | "${ver}_mapping.cil", |
| 119 | ], |
| 120 | } |
| 121 | EOF |