blob: ea4b70ff9a60f10aa9b3a636342d4c452064e8d7 [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
Lorenz Brun8b0431a2020-07-13 16:56:36 +020041 # Containerd preseed bundles
42 "//core/tests/e2e/preseedtest:preseedtest.tar": "/containerd/preseed/k8s.io/preseedtest.tar",
43
Serge Bazanski140bddc2020-06-05 21:01:19 +020044 # CNI Plugins
45 "@com_github_containernetworking_plugins//plugins/main/loopback": "/containerd/bin/cni/loopback",
46 "@com_github_containernetworking_plugins//plugins/main/ptp": "/containerd/bin/cni/ptp",
47 "@com_github_containernetworking_plugins//plugins/ipam/host-local": "/containerd/bin/cni/host-local",
Serge Bazanskic3ae7582020-06-08 17:15:26 +020048
49 # Cilium binaries
50 "@com_github_cilium_cilium//cilium": "/cilium/bin/cilium",
51 "@com_github_cilium_cilium//daemon": "/cilium/bin/daemon",
52 "@com_github_cilium_cilium//operator": "/cilium/bin/operator",
Lorenz Brun70f65b22020-07-08 17:02:47 +020053
54 # Delve
55 "@com_github_go_delve_delve//cmd/dlv:dlv": "/dlv",
Serge Bazanski140bddc2020-06-05 21:01:19 +020056 },
Serge Bazanski731d00a2020-02-03 19:08:07 +010057)
58
59genrule(
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020060 name = "image",
61 srcs = [
Serge Bazanski731d00a2020-02-03 19:08:07 +010062 "//third_party/linux:bzImage",
63 ":initramfs",
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020064 ],
65 outs = [
66 "smalltown.img",
67 ],
68 cmd = """
Serge Bazanskidcb3a562020-02-03 13:44:44 +010069 $(location //core/cmd/mkimage) \
Serge Bazanski731d00a2020-02-03 19:08:07 +010070 -efi $(location //third_party/linux:bzImage) \
71 -initramfs $(location :initramfs) \
Leopold Schabel65493072019-11-06 13:40:44 +000072 -out $@
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020073 """,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010074 tools = [
Serge Bazanskidcb3a562020-02-03 13:44:44 +010075 "//core/cmd/mkimage",
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010076 ],
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020077 visibility = ["//visibility:public"],
78)
79
80genrule(
81 name = "swtpm_data",
82 outs = [
83 "tpm/tpm2-00.permall",
84 "tpm/signkey.pem",
85 "tpm/issuercert.pem",
86 ],
87 cmd = """
88 mkdir -p tpm/ca
89
90 cat <<EOF > tpm/swtpm.conf
91create_certs_tool= /usr/share/swtpm/swtpm-localca
92create_certs_tool_config = tpm/swtpm-localca.conf
93create_certs_tool_options = /etc/swtpm-localca.options
94EOF
95
96 cat <<EOF > tpm/swtpm-localca.conf
97statedir = tpm/ca
98signingkey = tpm/ca/signkey.pem
99issuercert = tpm/ca/issuercert.pem
100certserial = tpm/ca/certserial
101EOF
102
103 swtpm_setup \
104 --tpmstate tpm \
105 --create-ek-cert \
106 --create-platform-cert \
107 --allow-signing \
108 --tpm2 \
109 --display \
110 --pcr-banks sha1,sha256,sha384,sha512 \
111 --config tpm/swtpm.conf
112
113 cp tpm/tpm2-00.permall $(location tpm/tpm2-00.permall)
114 cp tpm/ca/issuercert.pem $(location tpm/issuercert.pem)
115 cp tpm/ca/signkey.pem $(location tpm/signkey.pem)
116 """,
117 visibility = ["//visibility:public"],
118)
Lorenz Brun878f5f92020-05-12 16:15:39 +0200119
120load("//core/build/genosrelease:defs.bzl", "os_release")
121
122os_release(
123 name = "os-release-info",
124 os_id = "smalltown",
125 os_name = "Smalltown",
126 stamp_var = "STABLE_SIGNOS_version",
127)