blob: 5d628f1b91ce025a98d0808fa017952dd8378d31 [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
Lorenz Brun339582b2020-07-29 18:13:35 +020029 # CoreDNS
30 "@com_github_coredns_coredns//:coredns": "/kubernetes/bin/coredns",
31
Serge Bazanski140bddc2020-06-05 21:01:19 +020032 # runsc/gVisor
33 "@com_github_google_gvisor//runsc": "/containerd/bin/runsc",
34 "@com_github_google_gvisor_containerd_shim//cmd/containerd-shim-runsc-v1": "/containerd/bin/containerd-shim-runsc-v1",
35
36 # Containerd
37 "@com_github_containerd_containerd//cmd/containerd": "/containerd/bin/containerd",
38
39 # Containerd config files
40 "//core/internal/containerd:runsc.toml": "/containerd/conf/runsc.toml",
41 "//core/internal/containerd:config.toml": "/containerd/conf/config.toml",
Lorenz Brunf042e6f2020-06-24 16:46:09 +020042 "//core/internal/containerd:cnispec.gojson": "/containerd/conf/cnispec.gojson",
Serge Bazanski140bddc2020-06-05 21:01:19 +020043
Lorenz Brun8b0431a2020-07-13 16:56:36 +020044 # Containerd preseed bundles
45 "//core/tests/e2e/preseedtest:preseedtest.tar": "/containerd/preseed/k8s.io/preseedtest.tar",
Lorenz Bruned0503c2020-07-28 17:21:25 +020046 "//core/tests/e2e/k8s_cts:k8s_cts_image.tar": "/containerd/preseed/k8s.io/k8s_cts.tar",
Lorenz Brun8b0431a2020-07-13 16:56:36 +020047
Serge Bazanski140bddc2020-06-05 21:01:19 +020048 # CNI Plugins
49 "@com_github_containernetworking_plugins//plugins/main/loopback": "/containerd/bin/cni/loopback",
50 "@com_github_containernetworking_plugins//plugins/main/ptp": "/containerd/bin/cni/ptp",
51 "@com_github_containernetworking_plugins//plugins/ipam/host-local": "/containerd/bin/cni/host-local",
Serge Bazanskic3ae7582020-06-08 17:15:26 +020052
53 # Cilium binaries
54 "@com_github_cilium_cilium//cilium": "/cilium/bin/cilium",
55 "@com_github_cilium_cilium//daemon": "/cilium/bin/daemon",
56 "@com_github_cilium_cilium//operator": "/cilium/bin/operator",
Lorenz Brun70f65b22020-07-08 17:02:47 +020057
58 # Delve
59 "@com_github_go_delve_delve//cmd/dlv:dlv": "/dlv",
Serge Bazanski140bddc2020-06-05 21:01:19 +020060 },
Serge Bazanski731d00a2020-02-03 19:08:07 +010061)
62
63genrule(
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020064 name = "image",
65 srcs = [
Serge Bazanski731d00a2020-02-03 19:08:07 +010066 "//third_party/linux:bzImage",
67 ":initramfs",
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020068 ],
69 outs = [
70 "smalltown.img",
71 ],
72 cmd = """
Serge Bazanskidcb3a562020-02-03 13:44:44 +010073 $(location //core/cmd/mkimage) \
Serge Bazanski731d00a2020-02-03 19:08:07 +010074 -efi $(location //third_party/linux:bzImage) \
75 -initramfs $(location :initramfs) \
Leopold Schabel65493072019-11-06 13:40:44 +000076 -out $@
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020077 """,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010078 tools = [
Serge Bazanskidcb3a562020-02-03 13:44:44 +010079 "//core/cmd/mkimage",
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010080 ],
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020081 visibility = ["//visibility:public"],
82)
83
84genrule(
85 name = "swtpm_data",
86 outs = [
87 "tpm/tpm2-00.permall",
88 "tpm/signkey.pem",
89 "tpm/issuercert.pem",
90 ],
91 cmd = """
92 mkdir -p tpm/ca
93
94 cat <<EOF > tpm/swtpm.conf
95create_certs_tool= /usr/share/swtpm/swtpm-localca
96create_certs_tool_config = tpm/swtpm-localca.conf
97create_certs_tool_options = /etc/swtpm-localca.options
98EOF
99
100 cat <<EOF > tpm/swtpm-localca.conf
101statedir = tpm/ca
102signingkey = tpm/ca/signkey.pem
103issuercert = tpm/ca/issuercert.pem
104certserial = tpm/ca/certserial
105EOF
106
107 swtpm_setup \
108 --tpmstate tpm \
109 --create-ek-cert \
110 --create-platform-cert \
111 --allow-signing \
112 --tpm2 \
113 --display \
114 --pcr-banks sha1,sha256,sha384,sha512 \
115 --config tpm/swtpm.conf
116
117 cp tpm/tpm2-00.permall $(location tpm/tpm2-00.permall)
118 cp tpm/ca/issuercert.pem $(location tpm/issuercert.pem)
119 cp tpm/ca/signkey.pem $(location tpm/signkey.pem)
120 """,
121 visibility = ["//visibility:public"],
122)
Lorenz Brun878f5f92020-05-12 16:15:39 +0200123
124load("//core/build/genosrelease:defs.bzl", "os_release")
125
126os_release(
127 name = "os-release-info",
128 os_id = "smalltown",
129 os_name = "Smalltown",
130 stamp_var = "STABLE_SIGNOS_version",
131)