1// Copyright (C) 2020 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// A rule to collect apps for debugging purpose. See ApkVerityTestAppPrebuilt/README.md.
16package {
17    default_team: "trendy_team_framework_android_packages",
18    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21genrule {
22    name: "CtsApkVerityTestDebugFiles",
23    srcs: [
24        ":CtsApkVerityTestApp",
25        ":CtsApkVerityTestAppApkIdSig",
26        ":CtsApkVerityTestAppFsvSig",
27        ":CtsApkVerityTestAppDm",
28        ":CtsApkVerityTestAppDmFsvSig",
29        ":CtsApkVerityTestAppSplit",
30        ":CtsApkVerityTestAppSplitFsvSig",
31        ":CtsApkVerityTestAppSplitDm",
32        ":CtsApkVerityTestAppSplitDmFsvSig",
33    ],
34    cmd: "echo $(in) > $(out)",
35    out: ["CtsApkVerityTestDebugFiles.txt"],
36}
37
38// This is a rather complicated way to keep only APKs.
39// exclude_srcs does not work because it uses paths local to Android.bp.
40genrule {
41    name: "CtsApkVerityTestAppApk",
42    srcs: [":CtsApkVerityTestApp"],
43    cmd: "for file in $(in); do " +
44        "   if [[ $$file == *.apk ]]; then " +
45        "     cp $$file $(out); " +
46        "   fi " +
47        " done",
48    out: ["CtsApkVerityTestApp.apk"],
49}
50
51filegroup {
52    name: "CtsApkVerityTestAppDm",
53    srcs: ["CtsApkVerityTestApp.dm"],
54}
55
56filegroup {
57    name: "CtsApkVerityTestAppSplitDm",
58    srcs: ["CtsApkVerityTestAppSplit.dm"],
59}
60
61filegroup {
62    name: "fsverity-debug-key",
63    srcs: ["fsverity-debug-key.pem"],
64}
65
66filegroup {
67    name: "fsverity-debug-cert",
68    srcs: ["fsverity-debug.x509.pem"],
69}
70
71genrule_defaults {
72    name: "cts_apk_verity_sig_gen_default",
73    tools: ["fsverity"],
74    tool_files: [
75        ":fsverity-debug-key",
76        ":fsverity-debug-cert",
77    ],
78    cmd: "$(location fsverity) sign $(in) $(out) " +
79        "--key=$(location :fsverity-debug-key) " +
80        "--cert=$(location :fsverity-debug-cert) " +
81        "> /dev/null",
82}
83
84genrule {
85    name: "CtsApkVerityTestAppFsvSig",
86    defaults: ["cts_apk_verity_sig_gen_default"],
87    srcs: [":CtsApkVerityTestAppApk"],
88    out: ["CtsApkVerityTestApp.apk.fsv_sig"],
89}
90
91genrule {
92    name: "CtsApkVerityTestAppDmFsvSig",
93    defaults: ["cts_apk_verity_sig_gen_default"],
94    srcs: [":CtsApkVerityTestAppDm"],
95    out: ["CtsApkVerityTestApp.dm.fsv_sig"],
96}
97
98genrule {
99    name: "CtsApkVerityTestAppSplitFsvSig",
100    defaults: ["cts_apk_verity_sig_gen_default"],
101    srcs: [":CtsApkVerityTestAppSplit"],
102    out: ["CtsApkVerityTestAppSplit.apk.fsv_sig"],
103}
104
105genrule {
106    name: "CtsApkVerityTestAppSplitDmFsvSig",
107    defaults: ["cts_apk_verity_sig_gen_default"],
108    srcs: [":CtsApkVerityTestAppSplitDm"],
109    out: ["CtsApkVerityTestAppSplit.dm.fsv_sig"],
110}
111