blob: 23cb5371470349d5453bf073419c91bbc05fcaca [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",
39 "//core/internal/containerd:loopback.json": "/containerd/conf/cni/99-loopback.conf",
40 "//core/internal/containerd:ptp.json": "/containerd/conf/cni/10-ptp.conf",
41
42 # CNI Plugins
43 "@com_github_containernetworking_plugins//plugins/main/loopback": "/containerd/bin/cni/loopback",
44 "@com_github_containernetworking_plugins//plugins/main/ptp": "/containerd/bin/cni/ptp",
45 "@com_github_containernetworking_plugins//plugins/ipam/host-local": "/containerd/bin/cni/host-local",
Serge Bazanskic3ae7582020-06-08 17:15:26 +020046
47 # Cilium binaries
48 "@com_github_cilium_cilium//cilium": "/cilium/bin/cilium",
49 "@com_github_cilium_cilium//daemon": "/cilium/bin/daemon",
50 "@com_github_cilium_cilium//operator": "/cilium/bin/operator",
Lorenz Brun70f65b22020-07-08 17:02:47 +020051
52 # Delve
53 "@com_github_go_delve_delve//cmd/dlv:dlv": "/dlv",
Serge Bazanski140bddc2020-06-05 21:01:19 +020054 },
Serge Bazanski731d00a2020-02-03 19:08:07 +010055)
56
57genrule(
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020058 name = "image",
59 srcs = [
Serge Bazanski731d00a2020-02-03 19:08:07 +010060 "//third_party/linux:bzImage",
61 ":initramfs",
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020062 ],
63 outs = [
64 "smalltown.img",
65 ],
66 cmd = """
Serge Bazanskidcb3a562020-02-03 13:44:44 +010067 $(location //core/cmd/mkimage) \
Serge Bazanski731d00a2020-02-03 19:08:07 +010068 -efi $(location //third_party/linux:bzImage) \
69 -initramfs $(location :initramfs) \
Leopold Schabel65493072019-11-06 13:40:44 +000070 -out $@
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020071 """,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010072 tools = [
Serge Bazanskidcb3a562020-02-03 13:44:44 +010073 "//core/cmd/mkimage",
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010074 ],
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020075 visibility = ["//visibility:public"],
76)
77
78genrule(
79 name = "swtpm_data",
80 outs = [
81 "tpm/tpm2-00.permall",
82 "tpm/signkey.pem",
83 "tpm/issuercert.pem",
84 ],
85 cmd = """
86 mkdir -p tpm/ca
87
88 cat <<EOF > tpm/swtpm.conf
89create_certs_tool= /usr/share/swtpm/swtpm-localca
90create_certs_tool_config = tpm/swtpm-localca.conf
91create_certs_tool_options = /etc/swtpm-localca.options
92EOF
93
94 cat <<EOF > tpm/swtpm-localca.conf
95statedir = tpm/ca
96signingkey = tpm/ca/signkey.pem
97issuercert = tpm/ca/issuercert.pem
98certserial = tpm/ca/certserial
99EOF
100
101 swtpm_setup \
102 --tpmstate tpm \
103 --create-ek-cert \
104 --create-platform-cert \
105 --allow-signing \
106 --tpm2 \
107 --display \
108 --pcr-banks sha1,sha256,sha384,sha512 \
109 --config tpm/swtpm.conf
110
111 cp tpm/tpm2-00.permall $(location tpm/tpm2-00.permall)
112 cp tpm/ca/issuercert.pem $(location tpm/issuercert.pem)
113 cp tpm/ca/signkey.pem $(location tpm/signkey.pem)
114 """,
115 visibility = ["//visibility:public"],
116)
Lorenz Brun878f5f92020-05-12 16:15:39 +0200117
118load("//core/build/genosrelease:defs.bzl", "os_release")
119
120os_release(
121 name = "os-release-info",
122 os_id = "smalltown",
123 os_name = "Smalltown",
124 stamp_var = "STABLE_SIGNOS_version",
125)