blob: 5328671678d80d1c56f76c3c070b3416d7c73414 [file] [log] [blame]
Serge Bazanski140bddc2020-06-05 21:01:19 +02001load("//core/build:def.bzl", "smalltown_initramfs")
2
Lorenz Brun70f65b22020-07-08 17:02:47 +02003# debug_build checks if we're building in debug mode and enables various debug features for the image. Currently this
4# is only used for attaching a Delve debugger to init when it's enabled.
5config_setting(
6 name = "debug_build",
7 values = {
8 "compilation_mode": "dbg",
9 },
10)
11
Serge Bazanski140bddc2020-06-05 21:01:19 +020012smalltown_initramfs(
Serge Bazanski731d00a2020-02-03 19:08:07 +010013 name = "initramfs",
Serge Bazanski140bddc2020-06-05 21:01:19 +020014 extra_dirs = [
15 "/kubernetes/conf/flexvolume-plugins",
16 "/containerd/run",
Serge Bazanski731d00a2020-02-03 19:08:07 +010017 ],
Serge Bazanski140bddc2020-06-05 21:01:19 +020018 files = {
19 "//core/cmd/init": "/init",
20 "//third_party/xfsprogs:mkfs.xfs": "/bin/mkfs.xfs",
21
22 # CA Certificate bundle & os-release
23 "@cacerts//file": "/etc/ssl/cert.pem",
24 ":os-release-info": "/etc/os-release",
25
26 # Hyperkube
27 "//core/cmd/kube": "/kubernetes/bin/kube",
28
29 # runsc/gVisor
30 "@com_github_google_gvisor//runsc": "/containerd/bin/runsc",
31 "@com_github_google_gvisor_containerd_shim//cmd/containerd-shim-runsc-v1": "/containerd/bin/containerd-shim-runsc-v1",
32
33 # Containerd
34 "@com_github_containerd_containerd//cmd/containerd": "/containerd/bin/containerd",
35
36 # Containerd config files
37 "//core/internal/containerd:runsc.toml": "/containerd/conf/runsc.toml",
38 "//core/internal/containerd:config.toml": "/containerd/conf/config.toml",
Lorenz Brunf042e6f2020-06-24 16:46:09 +020039 "//core/internal/containerd:cnispec.gojson": "/containerd/conf/cnispec.gojson",
Serge Bazanski140bddc2020-06-05 21:01:19 +020040
41 # CNI Plugins
42 "@com_github_containernetworking_plugins//plugins/main/loopback": "/containerd/bin/cni/loopback",
43 "@com_github_containernetworking_plugins//plugins/main/ptp": "/containerd/bin/cni/ptp",
44 "@com_github_containernetworking_plugins//plugins/ipam/host-local": "/containerd/bin/cni/host-local",
Serge Bazanskic3ae7582020-06-08 17:15:26 +020045
46 # Cilium binaries
47 "@com_github_cilium_cilium//cilium": "/cilium/bin/cilium",
48 "@com_github_cilium_cilium//daemon": "/cilium/bin/daemon",
49 "@com_github_cilium_cilium//operator": "/cilium/bin/operator",
Lorenz Brun70f65b22020-07-08 17:02:47 +020050
51 # Delve
52 "@com_github_go_delve_delve//cmd/dlv:dlv": "/dlv",
Serge Bazanski140bddc2020-06-05 21:01:19 +020053 },
Serge Bazanski731d00a2020-02-03 19:08:07 +010054)
55
56genrule(
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020057 name = "image",
58 srcs = [
Serge Bazanski731d00a2020-02-03 19:08:07 +010059 "//third_party/linux:bzImage",
60 ":initramfs",
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020061 ],
62 outs = [
63 "smalltown.img",
64 ],
65 cmd = """
Serge Bazanskidcb3a562020-02-03 13:44:44 +010066 $(location //core/cmd/mkimage) \
Serge Bazanski731d00a2020-02-03 19:08:07 +010067 -efi $(location //third_party/linux:bzImage) \
68 -initramfs $(location :initramfs) \
Leopold Schabel65493072019-11-06 13:40:44 +000069 -out $@
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020070 """,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010071 tools = [
Serge Bazanskidcb3a562020-02-03 13:44:44 +010072 "//core/cmd/mkimage",
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010073 ],
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020074 visibility = ["//visibility:public"],
75)
76
77genrule(
78 name = "swtpm_data",
79 outs = [
80 "tpm/tpm2-00.permall",
81 "tpm/signkey.pem",
82 "tpm/issuercert.pem",
83 ],
84 cmd = """
85 mkdir -p tpm/ca
86
87 cat <<EOF > tpm/swtpm.conf
88create_certs_tool= /usr/share/swtpm/swtpm-localca
89create_certs_tool_config = tpm/swtpm-localca.conf
90create_certs_tool_options = /etc/swtpm-localca.options
91EOF
92
93 cat <<EOF > tpm/swtpm-localca.conf
94statedir = tpm/ca
95signingkey = tpm/ca/signkey.pem
96issuercert = tpm/ca/issuercert.pem
97certserial = tpm/ca/certserial
98EOF
99
100 swtpm_setup \
101 --tpmstate tpm \
102 --create-ek-cert \
103 --create-platform-cert \
104 --allow-signing \
105 --tpm2 \
106 --display \
107 --pcr-banks sha1,sha256,sha384,sha512 \
108 --config tpm/swtpm.conf
109
110 cp tpm/tpm2-00.permall $(location tpm/tpm2-00.permall)
111 cp tpm/ca/issuercert.pem $(location tpm/issuercert.pem)
112 cp tpm/ca/signkey.pem $(location tpm/signkey.pem)
113 """,
114 visibility = ["//visibility:public"],
115)
Lorenz Brun878f5f92020-05-12 16:15:39 +0200116
117load("//core/build/genosrelease:defs.bzl", "os_release")
118
119os_release(
120 name = "os-release-info",
121 os_id = "smalltown",
122 os_name = "Smalltown",
123 stamp_var = "STABLE_SIGNOS_version",
124)