blob: 33ec07d08dcda348078020de5cbefaad6e576bad [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",
46
Serge Bazanski140bddc2020-06-05 21:01:19 +020047 # CNI Plugins
48 "@com_github_containernetworking_plugins//plugins/main/loopback": "/containerd/bin/cni/loopback",
49 "@com_github_containernetworking_plugins//plugins/main/ptp": "/containerd/bin/cni/ptp",
50 "@com_github_containernetworking_plugins//plugins/ipam/host-local": "/containerd/bin/cni/host-local",
Serge Bazanskic3ae7582020-06-08 17:15:26 +020051
52 # Cilium binaries
53 "@com_github_cilium_cilium//cilium": "/cilium/bin/cilium",
54 "@com_github_cilium_cilium//daemon": "/cilium/bin/daemon",
55 "@com_github_cilium_cilium//operator": "/cilium/bin/operator",
Lorenz Brun70f65b22020-07-08 17:02:47 +020056
57 # Delve
58 "@com_github_go_delve_delve//cmd/dlv:dlv": "/dlv",
Serge Bazanski140bddc2020-06-05 21:01:19 +020059 },
Serge Bazanski731d00a2020-02-03 19:08:07 +010060)
61
62genrule(
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020063 name = "image",
64 srcs = [
Serge Bazanski731d00a2020-02-03 19:08:07 +010065 "//third_party/linux:bzImage",
66 ":initramfs",
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020067 ],
68 outs = [
69 "smalltown.img",
70 ],
71 cmd = """
Serge Bazanskidcb3a562020-02-03 13:44:44 +010072 $(location //core/cmd/mkimage) \
Serge Bazanski731d00a2020-02-03 19:08:07 +010073 -efi $(location //third_party/linux:bzImage) \
74 -initramfs $(location :initramfs) \
Leopold Schabel65493072019-11-06 13:40:44 +000075 -out $@
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020076 """,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010077 tools = [
Serge Bazanskidcb3a562020-02-03 13:44:44 +010078 "//core/cmd/mkimage",
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010079 ],
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020080 visibility = ["//visibility:public"],
81)
82
83genrule(
84 name = "swtpm_data",
85 outs = [
86 "tpm/tpm2-00.permall",
87 "tpm/signkey.pem",
88 "tpm/issuercert.pem",
89 ],
90 cmd = """
91 mkdir -p tpm/ca
92
93 cat <<EOF > tpm/swtpm.conf
94create_certs_tool= /usr/share/swtpm/swtpm-localca
95create_certs_tool_config = tpm/swtpm-localca.conf
96create_certs_tool_options = /etc/swtpm-localca.options
97EOF
98
99 cat <<EOF > tpm/swtpm-localca.conf
100statedir = tpm/ca
101signingkey = tpm/ca/signkey.pem
102issuercert = tpm/ca/issuercert.pem
103certserial = tpm/ca/certserial
104EOF
105
106 swtpm_setup \
107 --tpmstate tpm \
108 --create-ek-cert \
109 --create-platform-cert \
110 --allow-signing \
111 --tpm2 \
112 --display \
113 --pcr-banks sha1,sha256,sha384,sha512 \
114 --config tpm/swtpm.conf
115
116 cp tpm/tpm2-00.permall $(location tpm/tpm2-00.permall)
117 cp tpm/ca/issuercert.pem $(location tpm/issuercert.pem)
118 cp tpm/ca/signkey.pem $(location tpm/signkey.pem)
119 """,
120 visibility = ["//visibility:public"],
121)
Lorenz Brun878f5f92020-05-12 16:15:39 +0200122
123load("//core/build/genosrelease:defs.bzl", "os_release")
124
125os_release(
126 name = "os-release-info",
127 os_id = "smalltown",
128 os_name = "Smalltown",
129 stamp_var = "STABLE_SIGNOS_version",
130)