master
py 1,579 lines 40.2 KB
Raw
1 import os
2 from pathlib import Path
3
4 import dagger
5
6
7 _ALPINE_COMMON_PACKAGES = [
8 "alpine-sdk",
9 "autoconf",
10 "automake",
11 "bash",
12 "binutils",
13 "bison",
14 "cmake",
15 "curl",
16 "curl-static",
17 "elfutils-dev",
18 "flex",
19 "gcc",
20 "git",
21 "gnutls-dev",
22 "gzip",
23 "jq",
24 "libelf-static",
25 "libmnl-dev",
26 "libmnl-static",
27 "libtool",
28 "libuv-dev",
29 "libuv-static",
30 "lz4-dev",
31 "lz4-static",
32 "make",
33 "mongo-c-driver-dev",
34 "mongo-c-driver-static",
35 "musl-fts-dev",
36 "ncurses",
37 "ncurses-static",
38 "netcat-openbsd",
39 "ninja",
40 "openssh",
41 "pcre2-dev",
42 "pkgconfig",
43 "protobuf-dev",
44 "snappy-dev",
45 "snappy-static",
46 "util-linux-dev",
47 "wget",
48 "xz",
49 "yaml-dev",
50 "yaml-static",
51 "zlib-dev",
52 "zlib-static",
53 "zstd-dev",
54 "zstd-static",
55 ]
56
57
58 def build_alpine_3_18(
59 client: dagger.Client, platform: dagger.Platform
60 ) -> dagger.Container:
61 ctr = client.container(platform=platform).from_("alpine:3.18")
62
63 pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
64
65 ctr = ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
66
67 return ctr
68
69
70 def build_alpine_3_19(
71 client: dagger.Client, platform: dagger.Platform
72 ) -> dagger.Container:
73 ctr = client.container(platform=platform).from_("alpine:3.19")
74
75 pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
76
77 ctr = ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
78
79 return ctr
80
81
82 def static_build_openssl(
83 client: dagger.Client, ctr: dagger.Container
84 ) -> dagger.Container:
85 tree = (
86 client.git(url="https://github.com/openssl/openssl", keep_git_dir=True)
87 .tag("openssl-3.1.4")
88 .tree()
89 )
90
91 #
92 # TODO: verify 32-bit builds
93 #
94 ctr = (
95 ctr.with_directory("/openssl", tree)
96 .with_workdir("/openssl")
97 .with_env_variable("CFLAGS", "-fno-lto -pipe")
98 .with_env_variable("LDFLAGS", "-static")
99 .with_env_variable("PKG_CONFIG", "pkg-config --static")
100 .with_exec(
101 [
102 "sed",
103 "-i",
104 "s/disable('static', 'pic', 'threads');/disable('static', 'pic');/",
105 "Configure",
106 ]
107 )
108 .with_exec(
109 [
110 "./config",
111 "-static",
112 "threads",
113 "no-tests",
114 "--prefix=/openssl-static",
115 "--openssldir=/opt/netdata/etc/ssl",
116 ]
117 )
118 .with_exec(["make", "V=1", "-j", str(os.cpu_count())])
119 .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install_sw"])
120 .with_exec(["ln", "-s", "/openssl-static/lib", "/openssl-static/lib64"])
121 .with_exec(["perl", "configdata.pm", "--dump"])
122 )
123
124 return ctr
125
126
127 def static_build_bash(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
128 tree = (
129 client.git(url="https://git.savannah.gnu.org/git/bash.git", keep_git_dir=True)
130 .tag("bash-5.1")
131 .tree()
132 )
133
134 ctr = (
135 ctr.with_directory("/bash", tree)
136 .with_workdir("/bash")
137 .with_env_variable("CFLAGS", "-pipe")
138 .with_env_variable("LDFLAGS", "")
139 .with_env_variable("PKG_CONFIG", "pkg-config --static")
140 .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
141 .with_exec(
142 [
143 "./configure",
144 "--prefix",
145 "/opt/netdata",
146 "--without-bash-malloc",
147 "--enable-static-link",
148 "--enable-net-redirections",
149 "--enable-array-variables",
150 "--disable-progcomp",
151 "--disable-profiling",
152 "--disable-nls",
153 "--disable-dependency-tracking",
154 ]
155 )
156 .with_exec(
157 [
158 "echo",
159 "-e",
160 "all:\nclean:\ninstall:\n",
161 ">",
162 "examples/loadables/Makefile",
163 ]
164 )
165 .with_exec(["make", "clean"])
166 # see: https://gitweb.gentoo.org/repo/gentoo.git/tree/app-shells/bash/files/bash-5.1-parallel_make.patch?id=4c2ebbf4b8bc660beb98cc2d845c73375d6e4f50
167 .with_exec(["make", "V=1", "-j", "2", "install"])
168 .with_exec(["strip", "/opt/netdata/bin/bash"])
169 )
170
171 return ctr
172
173
174 def static_build_curl(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
175 tree = (
176 client.git(url="https://github.com/curl/curl", keep_git_dir=True)
177 .tag("curl-8_20_0")
178 .tree()
179 )
180
181 ctr = (
182 ctr.with_directory("/curl", tree)
183 .with_workdir("/curl")
184 .with_env_variable("CFLAGS", "-I/openssl-static/include -pipe")
185 .with_env_variable("LDFLAGS", "-static -L/openssl-static/lib64")
186 .with_env_variable("PKG_CONFIG", "pkg-config --static")
187 .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
188 .with_exec(["autoreconf", "-ifv"])
189 .with_exec(
190 [
191 "./configure",
192 "--prefix=/curl-static",
193 "--enable-optimize",
194 "--disable-shared",
195 "--enable-static",
196 "--enable-http",
197 "--disable-ldap",
198 "--disable-ldaps",
199 "--enable-proxy",
200 "--disable-dict",
201 "--disable-telnet",
202 "--disable-tftp",
203 "--disable-pop3",
204 "--disable-imap",
205 "--disable-smb",
206 "--disable-smtp",
207 "--disable-gopher",
208 "--enable-ipv6",
209 "--enable-cookies",
210 "--with-ca-fallback",
211 "--with-openssl",
212 "--disable-dependency-tracking",
213 ]
214 )
215 .with_exec(
216 ["sed", "-i", "-e", "s/LDFLAGS =/LDFLAGS = -all-static/", "src/Makefile"]
217 )
218 .with_exec(["make", "clean"])
219 .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
220 .with_exec(["cp", "/curl-static/bin/curl", "/opt/netdata/bin/curl"])
221 .with_exec(["strip", "/opt/netdata/bin/curl"])
222 )
223
224 return ctr
225
226
227 def static_build_ioping(
228 client: dagger.Client, ctr: dagger.Container
229 ) -> dagger.Container:
230 tree = (
231 client.git(url="https://github.com/koct9i/ioping", keep_git_dir=True)
232 .tag("v1.3")
233 .tree()
234 )
235
236 ctr = (
237 ctr.with_directory("/ioping", tree)
238 .with_workdir("/ioping")
239 .with_env_variable("CFLAGS", "-static -pipe")
240 .with_exec(["mkdir", "-p", "/opt/netdata/usr/libexec/netdata/plugins.d"])
241 .with_exec(["make", "V=1"])
242 .with_exec(
243 [
244 "install",
245 "-o",
246 "root",
247 "-g",
248 "root",
249 "-m",
250 "4750",
251 "ioping",
252 "/opt/netdata/usr/libexec/netdata/plugins.d",
253 ]
254 )
255 .with_exec(["strip", "/opt/netdata/usr/libexec/netdata/plugins.d/ioping"])
256 )
257
258 return ctr
259
260
261 def static_build_libnetfilter_acct(
262 client: dagger.Client, ctr: dagger.Container
263 ) -> dagger.Container:
264 tree = (
265 client.git(url="git://git.netfilter.org/libnetfilter_acct", keep_git_dir=True)
266 .tag("libnetfilter_acct-1.0.3")
267 .tree()
268 )
269
270 ctr = (
271 ctr.with_directory("/libnetfilter_acct", tree)
272 .with_workdir("/libnetfilter_acct")
273 .with_env_variable("CFLAGS", "-static -I/usr/include/libmnl -pipe")
274 .with_env_variable("LDFLAGS", "-static -L/usr/lib -lmnl")
275 .with_env_variable("PKG_CONFIG", "pkg-config --static")
276 .with_env_variable("PKG_CONFIG_PATH", "/usr/lib/pkgconfig")
277 .with_exec(["autoreconf", "-ifv"])
278 .with_exec(
279 [
280 "./configure",
281 "--prefix=/libnetfilter_acct-static",
282 "--exec-prefix=/libnetfilter_acct-static",
283 ]
284 )
285 .with_exec(["make", "clean"])
286 .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
287 )
288
289 return ctr
290
291
292 def static_build_netdata(
293 client: dagger.Client, ctr: dagger.Container
294 ) -> dagger.Container:
295 CFLAGS = [
296 "-ffunction-sections",
297 "-fdata-sections",
298 "-static",
299 "-O2",
300 "-funroll-loops",
301 "-I/openssl-static/include",
302 "-I/libnetfilter_acct-static/include/libnetfilter_acct",
303 "-I/curl-local/include/curl",
304 "-I/usr/include/libmnl",
305 "-pipe",
306 ]
307
308 LDFLAGS = [
309 "-Wl,--gc-sections",
310 "-static",
311 "-L/openssl-static/lib64",
312 "-L/libnetfilter_acct-static/lib",
313 "-lnetfilter_acct",
314 "-L/usr/lib",
315 "-lmnl",
316 "-L/usr/lib",
317 "-lzstd",
318 "-L/curl-local/lib",
319 ]
320
321 PKG_CONFIG = [
322 "pkg-config",
323 "--static",
324 ]
325
326 PKG_CONFIG_PATH = [
327 "/openssl-static/lib64/pkgconfig",
328 "/libnetfilter_acct-static/lib/pkgconfig",
329 "/usr/lib/pkgconfig",
330 "/curl-local/lib/pkgconfig",
331 ]
332
333 CMAKE_FLAGS = [
334 "-DOPENSSL_ROOT_DIR=/openssl-static",
335 "-DOPENSSL_LIBRARIES=/openssl-static/lib64",
336 "-DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static",
337 "-DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include",
338 "-DLWS_OPENSSL_LIBRARIES=/openssl-static/lib64/libssl.a;/openssl-static/lib64/libcrypto.a",
339 ]
340
341 NETDATA_INSTALLER_CMD = [
342 "./netdata-installer.sh",
343 "--install-prefix",
344 "/opt",
345 "--dont-wait",
346 "--dont-start-it",
347 "--disable-exporting-mongodb",
348 "--use-system-protobuf",
349 "--dont-scrub-cflags-even-though-it-may-break-things",
350 "--one-time-build",
351 "--enable-lto",
352 ]
353
354 ctr = (
355 ctr.with_workdir("/netdata")
356 .with_env_variable("NETDATA_CMAKE_OPTIONS", "-DCMAKE_BUILD_TYPE=Debug")
357 .with_env_variable("CFLAGS", " ".join(CFLAGS))
358 .with_env_variable("LDFLAGS", " ".join(LDFLAGS))
359 .with_env_variable("PKG_CONFIG", " ".join(PKG_CONFIG))
360 .with_env_variable("PKG_CONFIG_PATH", ":".join(PKG_CONFIG_PATH))
361 .with_env_variable("CMAKE_FLAGS", " ".join(CMAKE_FLAGS))
362 .with_env_variable("EBPF_LIBC", "static")
363 .with_env_variable("IS_NETDATA_STATIC_BINARY", "yes")
364 .with_exec(NETDATA_INSTALLER_CMD)
365 )
366
367 return ctr
368
369
370 def static_build(client, repo_path):
371 cmake_build_release_path = os.path.join(repo_path, "cmake-build-release")
372
373 ctr = build_alpine_3_18(client, dagger.Platform("linux/x86_64"))
374 ctr = static_build_openssl(client, ctr)
375 ctr = static_build_bash(client, ctr)
376 ctr = static_build_curl(client, ctr)
377 ctr = static_build_ioping(client, ctr)
378 ctr = static_build_libnetfilter_acct(client, ctr)
379
380 ctr = ctr.with_directory(
381 "/netdata",
382 client.host().directory(repo_path),
383 exclude=[
384 f"{cmake_build_release_path}/*",
385 "fluent-bit/build",
386 ],
387 )
388
389 # TODO: link bin/sbin
390
391 ctr = static_build_netdata(client, ctr)
392
393 build_dir = ctr.directory("/opt/netdata")
394 artifact_dir = os.path.join(Path.home(), "ci/netdata-static")
395 output_task = build_dir.export(artifact_dir)
396 return output_task
397
398
399 _CENTOS_COMMON_PACKAGES = [
400 "autoconf",
401 "autoconf-archive",
402 "autogen",
403 "automake",
404 "bison",
405 "bison-devel",
406 "cmake",
407 "cups-devel",
408 "curl",
409 "diffutils",
410 "elfutils-libelf-devel",
411 "findutils",
412 "flex",
413 "flex-devel",
414 "freeipmi-devel",
415 "gcc",
416 "gcc-c++",
417 "git-core",
418 "golang",
419 "json-c-devel",
420 "libyaml-devel",
421 "libatomic",
422 "libcurl-devel",
423 "libmnl-devel",
424 "libnetfilter_acct-devel",
425 "libtool",
426 "libuuid-devel",
427 "libuv-devel",
428 "libzstd-devel",
429 "lm_sensors",
430 "lz4-devel",
431 "make",
432 "ninja-build",
433 "openssl-devel",
434 "openssl-perl",
435 "patch",
436 "pcre2-devel",
437 "pkgconfig",
438 "pkgconfig(libmongoc-1.0)",
439 "procps",
440 "protobuf-c-devel",
441 "protobuf-compiler",
442 "protobuf-devel",
443 "rpm-build",
444 "rpm-devel",
445 "rpmdevtools",
446 "snappy-devel",
447 "systemd-devel",
448 "wget",
449 "zlib-devel",
450 ]
451
452
453 def build_amazon_linux_2(
454 client: dagger.Client, platform: dagger.Platform
455 ) -> dagger.Container:
456 ctr = client.container(platform=platform).from_("amazonlinux:2")
457
458 pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES]
459
460 ctr = (
461 ctr.with_exec(["yum", "update", "-y"])
462 .with_exec(["yum", "install", "-y"] + pkgs)
463 .with_exec(["yum", "clean", "all"])
464 .with_exec(["c_rehash"])
465 .with_exec(
466 [
467 "mkdir",
468 "-p",
469 "/root/rpmbuild/BUILD",
470 "/root/rpmbuild/RPMS",
471 "/root/rpmbuild/SOURCES",
472 "/root/rpmbuild/SPECS",
473 "/root/rpmbuild/SRPMS",
474 ]
475 )
476 )
477
478 if platform == "linux/x86_64":
479 machine = "x86_64"
480 elif platform == "linux/arm64":
481 machine = "aarch64"
482 else:
483 raise Exception(
484 "Amaxon Linux 2 supports only linux/amd64 and linux/arm64 platforms."
485 )
486
487
488 checksum_path = Path(__file__).parent / f"files/cmake-{machine}.sha256"
489
490 ctr = (
491 ctr.with_file(
492 f"cmake-{machine}.sha256",
493 client.host().file(checksum_path.as_posix()),
494 )
495 .with_exec(
496 [
497 "curl",
498 "--fail",
499 "-sSL",
500 "--connect-timeout",
501 "20",
502 "--retry",
503 "3",
504 "--output",
505 f"cmake-{machine}.sh",
506 f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
507 ]
508 )
509 .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
510 .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
511 .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
512 )
513
514 return ctr
515
516
517 def build_centos_7(
518 client: dagger.Client, platform: dagger.Platform
519 ) -> dagger.Container:
520 ctr = client.container(platform=platform).from_("centos:7")
521
522 pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES] + ["bash"]
523
524 ctr = (
525 ctr.with_exec(["yum", "install", "-y", "epel-release"])
526 .with_exec(["yum", "update", "-y"])
527 .with_exec(["yum", "install", "-y"] + pkgs)
528 .with_exec(["yum", "clean", "all"])
529 .with_exec(["c_rehash"])
530 .with_exec(
531 [
532 "mkdir",
533 "-p",
534 "/root/rpmbuild/BUILD",
535 "/root/rpmbuild/RPMS",
536 "/root/rpmbuild/SOURCES",
537 "/root/rpmbuild/SPECS",
538 "/root/rpmbuild/SRPMS",
539 ]
540 )
541 )
542
543 if platform == "linux/x86_64":
544 machine = "x86_64"
545 elif platform == "linux/arm64":
546 machine = "aarch64"
547 else:
548 raise Exception("CentOS 7 supports only linux/amd64 and linux/arm64 platforms.")
549
550 checksum_path = Path(__file__).parent / f"files/cmake-{machine}.sha256"
551
552 ctr = (
553 ctr.with_file(
554 f"cmake-{machine}.sha256",
555 client.host().file(checksum_path.as_posix()),
556 )
557 .with_exec(
558 [
559 "curl",
560 "--fail",
561 "-sSL",
562 "--connect-timeout",
563 "20",
564 "--retry",
565 "3",
566 "--output",
567 f"cmake-{machine}.sh",
568 f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
569 ]
570 )
571 .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
572 .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
573 .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
574 )
575
576 return ctr
577
578
579 _ROCKY_LINUX_COMMON_PACKAGES = [
580 "autoconf",
581 "autoconf-archive",
582 "automake",
583 "bash",
584 "bison",
585 "cmake",
586 "cups-devel",
587 "curl",
588 "libcurl-devel",
589 "diffutils",
590 "elfutils-libelf-devel",
591 "findutils",
592 "flex",
593 "freeipmi-devel",
594 "gcc",
595 "gcc-c++",
596 "git",
597 "golang",
598 "json-c-devel",
599 "libatomic",
600 "libmnl-devel",
601 "libtool",
602 "libuuid-devel",
603 "libuv-devel",
604 "libyaml-devel",
605 "libzstd-devel",
606 "lm_sensors",
607 "lz4-devel",
608 "make",
609 "ninja-build",
610 "nc",
611 "openssl-devel",
612 "openssl-perl",
613 "patch",
614 "pcre2-devel",
615 "pkgconfig",
616 "pkgconfig(libmongoc-1.0)",
617 "procps",
618 "protobuf-c-devel",
619 "protobuf-compiler",
620 "protobuf-devel",
621 "python3",
622 "python3-pyyaml",
623 "rpm-build",
624 "rpm-devel",
625 "rpmdevtools",
626 "snappy-devel",
627 "systemd-devel",
628 "wget",
629 "zlib-devel",
630 ]
631
632
633 def build_rocky_linux_8(
634 client: dagger.Client, platform: dagger.Platform
635 ) -> dagger.Container:
636 ctr = client.container(platform=platform).from_("rockylinux:8")
637
638 pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES] + ["autogen"]
639
640 ctr = (
641 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
642 .with_exec(
643 [
644 "dnf",
645 "install",
646 "-y",
647 "--nodocs",
648 "dnf-command(config-manager)",
649 "epel-release",
650 ]
651 )
652 .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
653 .with_exec(["dnf", "clean", "packages"])
654 .with_exec(
655 [
656 "dnf",
657 "install",
658 "-y",
659 "--nodocs",
660 "--setopt=install_weak_deps=False",
661 "--setopt=diskspacecheck=False",
662 ]
663 + pkgs
664 )
665 .with_exec(["rm", "-rf", "/var/cache/dnf"])
666 .with_exec(["c_rehash"])
667 .with_exec(
668 [
669 "mkdir",
670 "-p",
671 "/root/rpmbuild/BUILD",
672 "/root/rpmbuild/RPMS",
673 "/root/rpmbuild/SOURCES",
674 "/root/rpmbuild/SPECS",
675 "/root/rpmbuild/SRPMS",
676 ]
677 )
678 )
679
680 return ctr
681
682
683 def build_rocky_linux_9(
684 client: dagger.Client, platform: dagger.Platform
685 ) -> dagger.Container:
686 ctr = client.container(platform=platform).from_("rockylinux:9")
687
688 pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES]
689
690 ctr = (
691 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
692 .with_exec(
693 [
694 "dnf",
695 "install",
696 "-y",
697 "--nodocs",
698 "dnf-command(config-manager)",
699 "epel-release",
700 ]
701 )
702 .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
703 .with_exec(["dnf", "clean", "packages"])
704 .with_exec(
705 [
706 "dnf",
707 "install",
708 "-y",
709 "--allowerasing",
710 "--nodocs",
711 "--setopt=install_weak_deps=False",
712 "--setopt=diskspacecheck=False",
713 ]
714 + pkgs
715 )
716 .with_exec(["rm", "-rf", "/var/cache/dnf"])
717 .with_exec(["c_rehash"])
718 .with_exec(
719 [
720 "mkdir",
721 "-p",
722 "/root/rpmbuild/BUILD",
723 "/root/rpmbuild/RPMS",
724 "/root/rpmbuild/SOURCES",
725 "/root/rpmbuild/SPECS",
726 "/root/rpmbuild/SRPMS",
727 ]
728 )
729 )
730
731 return ctr
732
733
734 _CENTOS_STREAM_COMMON_PACKAGES = [
735 "autoconf",
736 "autoconf-archive",
737 "automake",
738 "bash",
739 "bison",
740 "cmake",
741 "cups-devel",
742 "curl",
743 "libcurl-devel",
744 "libyaml-devel",
745 "diffutils",
746 "elfutils-libelf-devel",
747 "findutils",
748 "flex",
749 "freeipmi-devel",
750 "gcc",
751 "gcc-c++",
752 "git",
753 "golang",
754 "json-c-devel",
755 "libatomic",
756 "libmnl-devel",
757 "libtool",
758 "libuuid-devel",
759 "libuv-devel",
760 # "libzstd-devel",
761 "lm_sensors",
762 "lz4-devel",
763 "make",
764 "ninja-build",
765 "nc",
766 "openssl-devel",
767 "openssl-perl",
768 "patch",
769 "pcre2-devel",
770 "pkgconfig",
771 "pkgconfig(libmongoc-1.0)",
772 "procps",
773 "protobuf-c-devel",
774 "protobuf-compiler",
775 "protobuf-devel",
776 "python3",
777 "python3-pyyaml",
778 "rpm-build",
779 "rpm-devel",
780 "rpmdevtools",
781 "snappy-devel",
782 "systemd-devel",
783 "wget",
784 "zlib-devel",
785 ]
786
787
788 def build_centos_stream_8(
789 client: dagger.Client, platform: dagger.Platform
790 ) -> dagger.Container:
791 ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream8")
792
793 pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES] + ["autogen"]
794
795 ctr = (
796 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
797 .with_exec(
798 [
799 "dnf",
800 "install",
801 "-y",
802 "--nodocs",
803 "dnf-command(config-manager)",
804 "epel-release",
805 ]
806 )
807 .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
808 .with_exec(["dnf", "clean", "packages"])
809 .with_exec(
810 [
811 "dnf",
812 "install",
813 "-y",
814 "--nodocs",
815 "--setopt=install_weak_deps=False",
816 "--setopt=diskspacecheck=False",
817 ]
818 + pkgs
819 )
820 .with_exec(["rm", "-rf", "/var/cache/dnf"])
821 .with_exec(["c_rehash"])
822 .with_exec(
823 [
824 "mkdir",
825 "-p",
826 "/root/rpmbuild/BUILD",
827 "/root/rpmbuild/RPMS",
828 "/root/rpmbuild/SOURCES",
829 "/root/rpmbuild/SPECS",
830 "/root/rpmbuild/SRPMS",
831 ]
832 )
833 )
834
835 return ctr
836
837
838 def build_centos_stream_9(
839 client: dagger.Client, platform: dagger.Platform
840 ) -> dagger.Container:
841 ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream9")
842
843 pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES]
844
845 ctr = (
846 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
847 .with_exec(
848 [
849 "dnf",
850 "install",
851 "-y",
852 "--nodocs",
853 "dnf-command(config-manager)",
854 "epel-release",
855 ]
856 )
857 .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
858 .with_exec(["dnf", "clean", "packages"])
859 .with_exec(
860 [
861 "dnf",
862 "install",
863 "-y",
864 "--allowerasing",
865 "--nodocs",
866 "--setopt=install_weak_deps=False",
867 "--setopt=diskspacecheck=False",
868 ]
869 + pkgs
870 )
871 .with_exec(["rm", "-rf", "/var/cache/dnf"])
872 .with_exec(["c_rehash"])
873 .with_exec(
874 [
875 "mkdir",
876 "-p",
877 "/root/rpmbuild/BUILD",
878 "/root/rpmbuild/RPMS",
879 "/root/rpmbuild/SOURCES",
880 "/root/rpmbuild/SPECS",
881 "/root/rpmbuild/SRPMS",
882 ]
883 )
884 )
885
886 return ctr
887
888
889 _ORACLE_LINUX_COMMON_PACKAGES = list(_ROCKY_LINUX_COMMON_PACKAGES)
890
891
892 def build_oracle_linux_9(
893 client: dagger.Client, platform: dagger.Platform
894 ) -> dagger.Container:
895 ctr = client.container(platform=platform).from_("oraclelinux:9")
896
897 pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES]
898
899 repo_path = str(Path(__file__).parent.parent.parent)
900 this_path = os.path.join(repo_path, "packaging/dag")
901
902 ctr = (
903 ctr.with_file(
904 "/etc/yum.repos.d/ol9-epel.repo",
905 client.host().file(f"{this_path}/ol9-epel.repo"),
906 )
907 .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_codeready_builder"])
908 .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_developer_EPEL"])
909 .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
910 .with_exec(["dnf", "clean", "-y", "packages"])
911 .with_exec(
912 [
913 "dnf",
914 "install",
915 "-y",
916 "--nodocs",
917 "--setopt=install_weak_deps=False",
918 "--setopt=diskspacecheck=False",
919 ]
920 + pkgs
921 )
922 .with_exec(["rm", "-rf", "/var/cache/dnf"])
923 .with_exec(["c_rehash"])
924 .with_exec(
925 [
926 "mkdir",
927 "-p",
928 "/root/rpmbuild/BUILD",
929 "/root/rpmbuild/RPMS",
930 "/root/rpmbuild/SOURCES",
931 "/root/rpmbuild/SPECS",
932 "/root/rpmbuild/SRPMS",
933 ]
934 )
935 )
936
937 return ctr
938
939
940 def build_oracle_linux_8(
941 client: dagger.Client, platform: dagger.Platform
942 ) -> dagger.Container:
943 ctr = client.container(platform=platform).from_("oraclelinux:8")
944
945 pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES] + ["autogen"]
946
947 repo_path = str(Path(__file__).parent.parent.parent)
948 this_path = os.path.join(repo_path, "packaging/dag")
949
950 ctr = (
951 ctr.with_file(
952 "/etc/yum.repos.d/ol8-epel.repo",
953 client.host().file(f"{this_path}/ol8-epel.repo"),
954 )
955 .with_exec(["dnf", "config-manager", "--set-enabled", "ol8_codeready_builder"])
956 .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
957 .with_exec(["dnf", "clean", "-y", "packages"])
958 .with_exec(
959 [
960 "dnf",
961 "install",
962 "-y",
963 "--nodocs",
964 "--setopt=install_weak_deps=False",
965 "--setopt=diskspacecheck=False",
966 ]
967 + pkgs
968 )
969 .with_exec(["rm", "-rf", "/var/cache/dnf"])
970 .with_exec(["c_rehash"])
971 .with_exec(
972 [
973 "mkdir",
974 "-p",
975 "/root/rpmbuild/BUILD",
976 "/root/rpmbuild/RPMS",
977 "/root/rpmbuild/SOURCES",
978 "/root/rpmbuild/SPECS",
979 "/root/rpmbuild/SRPMS",
980 ]
981 )
982 )
983
984 return ctr
985
986
987 _OPENSUSE_COMMON_PACKAGES = [
988 "autoconf",
989 "autoconf-archive",
990 "autogen",
991 "automake",
992 "bison",
993 "cmake",
994 "cups",
995 "cups-devel",
996 "curl",
997 "diffutils",
998 "flex",
999 "freeipmi-devel",
1000 "gcc",
1001 "gcc-c++",
1002 "git-core",
1003 "go",
1004 "json-glib-devel",
1005 "judy-devel",
1006 "libatomic1",
1007 "libcurl-devel",
1008 "libelf-devel",
1009 "liblz4-devel",
1010 "libjson-c-devel",
1011 "libyaml-devel",
1012 "libmnl0",
1013 "libmnl-devel",
1014 "libnetfilter_acct1",
1015 "libnetfilter_acct-devel",
1016 "libpcre2-8-0",
1017 "libopenssl-devel",
1018 "libtool",
1019 "libuv-devel",
1020 "libuuid-devel",
1021 "libzstd-devel",
1022 "make",
1023 "ninja",
1024 "patch",
1025 "pkg-config",
1026 "protobuf-devel",
1027 "rpm-build",
1028 "rpm-devel",
1029 "rpmdevtools",
1030 "snappy-devel",
1031 "systemd-devel",
1032 "tar",
1033 "wget",
1034 "xen-devel",
1035 ]
1036
1037
1038 def build_opensuse_tumbleweed(
1039 client: dagger.Client, platform: dagger.Platform
1040 ) -> dagger.Container:
1041 ctr = client.container(platform=platform).from_("opensuse/tumbleweed:latest")
1042
1043 pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["protobuf-c"]
1044
1045 ctr = (
1046 ctr.with_exec(["zypper", "update", "-y"])
1047 .with_exec(
1048 [
1049 "zypper",
1050 "install",
1051 "-y",
1052 "--allow-downgrade",
1053 ]
1054 + pkgs
1055 )
1056 .with_exec(["zypper", "clean"])
1057 .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
1058 .with_exec(["c_rehash"])
1059 .with_exec(
1060 [
1061 "mkdir",
1062 "-p",
1063 "/usr/src/packages/BUILD",
1064 "/usr/src/packages/RPMS",
1065 "/usr/src/packages/SOURCES",
1066 "/usr/src/packages/SPECS",
1067 "/usr/src/packages/SRPMS",
1068 ]
1069 )
1070 )
1071
1072 return ctr
1073
1074
1075 def build_opensuse_15_5(
1076 client: dagger.Client, platform: dagger.Platform
1077 ) -> dagger.Container:
1078 ctr = client.container(platform=platform).from_("opensuse/leap:15.5")
1079
1080 pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
1081
1082 ctr = (
1083 ctr.with_exec(["zypper", "update", "-y"])
1084 .with_exec(
1085 [
1086 "zypper",
1087 "install",
1088 "-y",
1089 "--allow-downgrade",
1090 ]
1091 + pkgs
1092 )
1093 .with_exec(["zypper", "clean"])
1094 .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
1095 .with_exec(["c_rehash"])
1096 .with_exec(
1097 [
1098 "mkdir",
1099 "-p",
1100 "/usr/src/packages/BUILD",
1101 "/usr/src/packages/RPMS",
1102 "/usr/src/packages/SOURCES",
1103 "/usr/src/packages/SPECS",
1104 "/usr/src/packages/SRPMS",
1105 ]
1106 )
1107 )
1108
1109 return ctr
1110
1111
1112 def build_opensuse_15_4(
1113 client: dagger.Client, platform: dagger.Platform
1114 ) -> dagger.Container:
1115 crt = client.container(platform=platform).from_("opensuse/leap:15.4")
1116
1117 pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
1118
1119 crt = (
1120 crt.with_exec(["zypper", "update", "-y"])
1121 .with_exec(
1122 [
1123 "zypper",
1124 "install",
1125 "-y",
1126 "--allow-downgrade",
1127 ]
1128 + pkgs
1129 )
1130 .with_exec(["zypper", "clean"])
1131 .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
1132 .with_exec(["c_rehash"])
1133 .with_exec(
1134 [
1135 "mkdir",
1136 "-p",
1137 "/usr/src/packages/BUILD",
1138 "/usr/src/packages/RPMS",
1139 "/usr/src/packages/SOURCES",
1140 "/usr/src/packages/SPECS",
1141 "/usr/src/packages/SRPMS",
1142 ]
1143 )
1144 )
1145
1146 return crt
1147
1148
1149 _FEDORA_COMMON_PACKAGES = [
1150 "autoconf",
1151 "autoconf-archive",
1152 "autogen",
1153 "automake",
1154 "bash",
1155 "bison",
1156 "cmake",
1157 "cups-devel",
1158 "curl",
1159 "diffutils",
1160 "elfutils-libelf-devel",
1161 "findutils",
1162 "flex",
1163 "freeipmi-devel",
1164 "gcc",
1165 "gcc-c++",
1166 "git-core",
1167 "golang",
1168 "json-c-devel",
1169 "libcurl-devel",
1170 "libyaml-devel",
1171 "Judy-devel",
1172 "libatomic",
1173 "libmnl-devel",
1174 "libnetfilter_acct-devel",
1175 "libtool",
1176 "libuuid-devel",
1177 "libuv-devel",
1178 "libzstd-devel",
1179 "lz4-devel",
1180 "make",
1181 "ninja-build",
1182 "openssl-devel",
1183 "openssl-perl",
1184 "patch",
1185 "pcre2-devel",
1186 "pkgconfig",
1187 ]
1188
1189
1190 def build_fedora_37(
1191 client: dagger.Client, platform: dagger.Platform
1192 ) -> dagger.Container:
1193 ctr = client.container(platform=platform).from_("fedora:37")
1194
1195 pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
1196
1197 ctr = (
1198 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
1199 .with_exec(["dnf", "clean", "-y", "packages"])
1200 .with_exec(
1201 [
1202 "dnf",
1203 "install",
1204 "-y",
1205 "--nodocs",
1206 "--setopt=install_weak_deps=False",
1207 "--setopt=diskspacecheck=False",
1208 ]
1209 + pkgs
1210 )
1211 .with_exec(["rm", "-rf", "/var/cache/dnf"])
1212 .with_exec(["c_rehash"])
1213 .with_exec(
1214 [
1215 "mkdir",
1216 "-p",
1217 "/root/rpmbuild/BUILD",
1218 "/root/rpmbuild/RPMS",
1219 "/root/rpmbuild/SOURCES",
1220 "/root/rpmbuild/SPECS",
1221 "/root/rpmbuild/SRPMS",
1222 ]
1223 )
1224 )
1225
1226 return ctr
1227
1228
1229 def build_fedora_38(
1230 client: dagger.Client, platform: dagger.Platform
1231 ) -> dagger.Container:
1232 ctr = client.container(platform=platform).from_("fedora:38")
1233
1234 pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
1235
1236 ctr = (
1237 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
1238 .with_exec(["dnf", "clean", "-y", "packages"])
1239 .with_exec(
1240 [
1241 "dnf",
1242 "install",
1243 "-y",
1244 "--nodocs",
1245 "--setopt=install_weak_deps=False",
1246 "--setopt=diskspacecheck=False",
1247 ]
1248 + pkgs
1249 )
1250 .with_exec(["rm", "-rf", "/var/cache/dnf"])
1251 .with_exec(["c_rehash"])
1252 .with_exec(
1253 [
1254 "mkdir",
1255 "-p",
1256 "/root/rpmbuild/BUILD",
1257 "/root/rpmbuild/RPMS",
1258 "/root/rpmbuild/SOURCES",
1259 "/root/rpmbuild/SPECS",
1260 "/root/rpmbuild/SRPMS",
1261 ]
1262 )
1263 )
1264
1265 return ctr
1266
1267
1268 def build_fedora_39(
1269 client: dagger.Client, platform: dagger.Platform
1270 ) -> dagger.Container:
1271 ctr = client.container(platform=platform).from_("fedora:39")
1272
1273 pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
1274
1275 ctr = (
1276 ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
1277 .with_exec(["dnf", "clean", "-y", "packages"])
1278 .with_exec(
1279 [
1280 "dnf",
1281 "install",
1282 "-y",
1283 "--nodocs",
1284 "--setopt=install_weak_deps=False",
1285 "--setopt=diskspacecheck=False",
1286 ]
1287 + pkgs
1288 )
1289 .with_exec(["rm", "-rf", "/var/cache/dnf"])
1290 .with_exec(["c_rehash"])
1291 .with_exec(
1292 [
1293 "mkdir",
1294 "-p",
1295 "/root/rpmbuild/BUILD",
1296 "/root/rpmbuild/RPMS",
1297 "/root/rpmbuild/SOURCES",
1298 "/root/rpmbuild/SPECS",
1299 "/root/rpmbuild/SRPMS",
1300 ]
1301 )
1302 )
1303
1304 return ctr
1305
1306
1307 _DEBIAN_COMMON_PACKAGES = [
1308 "autoconf",
1309 "autoconf-archive",
1310 "autogen",
1311 "automake",
1312 "bison",
1313 "build-essential",
1314 "ca-certificates",
1315 "cmake",
1316 "curl",
1317 "dh-autoreconf",
1318 "dh-make",
1319 "dpkg-dev",
1320 "flex",
1321 "g++",
1322 "gcc",
1323 "git-buildpackage",
1324 "git-core",
1325 "golang",
1326 "libatomic1",
1327 "libcurl4-openssl-dev",
1328 "libcups2-dev",
1329 "libdistro-info-perl",
1330 "libelf-dev",
1331 "libipmimonitoring-dev",
1332 "libjson-c-dev",
1333 "libyaml-dev",
1334 "libjudy-dev",
1335 "liblz4-dev",
1336 "libmnl-dev",
1337 "libmongoc-dev",
1338 "libnetfilter-acct-dev",
1339 "libpcre2-dev",
1340 "libprotobuf-dev",
1341 "libprotoc-dev",
1342 "libsnappy-dev",
1343 "libsystemd-dev",
1344 "libssl-dev",
1345 "libtool",
1346 "libuv1-dev",
1347 "libzstd-dev",
1348 "make",
1349 "ninja-build",
1350 "pkg-config",
1351 "protobuf-compiler",
1352 "systemd",
1353 "uuid-dev",
1354 "wget",
1355 "zlib1g-dev",
1356 ]
1357
1358
1359 def build_debian_10(
1360 client: dagger.Client, platform: dagger.Platform
1361 ) -> dagger.Container:
1362 ctr = client.container(platform=platform).from_("debian:buster")
1363
1364 pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["dh-systemd", "libxen-dev"]
1365
1366 ctr = (
1367 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1368 .with_exec(["apt-get", "update"])
1369 .with_exec(["apt-get", "upgrade", "-y"])
1370 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1371 .with_exec(["apt-get", "clean"])
1372 .with_exec(["c_rehash"])
1373 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1374 )
1375
1376 return ctr
1377
1378
1379 def build_debian_11(
1380 client: dagger.Client, platform: dagger.Platform
1381 ) -> dagger.Container:
1382 ctr = client.container(platform=platform).from_("debian:bullseye")
1383
1384 pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["libxen-dev"]
1385
1386 ctr = (
1387 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1388 .with_exec(["apt-get", "update"])
1389 .with_exec(["apt-get", "upgrade", "-y"])
1390 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1391 .with_exec(["apt-get", "clean"])
1392 .with_exec(["c_rehash"])
1393 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1394 )
1395
1396 return ctr
1397
1398
1399 def build_debian_12(
1400 client: dagger.Client, platform: dagger.Platform
1401 ) -> dagger.Container:
1402 ctr = client.container(platform=platform).from_("debian:bookworm")
1403
1404 pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES]
1405
1406 if platform != dagger.Platform("linux/i386"):
1407 pkgs.append("libxen-dev")
1408
1409 ctr = (
1410 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1411 .with_exec(["apt-get", "update"])
1412 .with_exec(["apt-get", "upgrade", "-y"])
1413 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1414 .with_exec(["apt-get", "clean"])
1415 .with_exec(["c_rehash"])
1416 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1417 )
1418
1419 return ctr
1420
1421
1422 _UBUNTU_COMMON_PACKAGES = [
1423 "autoconf",
1424 "autoconf-archive",
1425 "autogen",
1426 "automake",
1427 "bison",
1428 "build-essential",
1429 "ca-certificates",
1430 "cmake",
1431 "curl",
1432 "dh-autoreconf",
1433 "dh-make",
1434 "dpkg-dev",
1435 "flex",
1436 "g++",
1437 "gcc",
1438 "git-buildpackage",
1439 "git-core",
1440 "golang",
1441 "libatomic1",
1442 "libcurl4-openssl-dev",
1443 "libcups2-dev",
1444 "libdistro-info-perl",
1445 "libelf-dev",
1446 "libipmimonitoring-dev",
1447 "libjson-c-dev",
1448 "libyaml-dev",
1449 "libjudy-dev",
1450 "liblz4-dev",
1451 "libmnl-dev",
1452 "libmongoc-dev",
1453 "libnetfilter-acct-dev",
1454 "libpcre2-dev",
1455 "libprotobuf-dev",
1456 "libprotoc-dev",
1457 "libsnappy-dev",
1458 "libsystemd-dev",
1459 "libssl-dev",
1460 "libtool",
1461 "libuv1-dev",
1462 "libxen-dev",
1463 "libzstd-dev",
1464 "make",
1465 "ninja-build",
1466 "pkg-config",
1467 "protobuf-compiler",
1468 "systemd",
1469 "uuid-dev",
1470 "wget",
1471 "zlib1g-dev",
1472 ]
1473
1474
1475 def build_ubuntu_20_04(
1476 client: dagger.Client, platform: dagger.Platform
1477 ) -> dagger.Container:
1478 ctr = client.container(platform=platform).from_("ubuntu:20.04")
1479
1480 pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES] + ["dh-systemd"]
1481
1482 ctr = (
1483 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1484 .with_exec(["apt-get", "update"])
1485 .with_exec(["apt-get", "upgrade", "-y"])
1486 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1487 .with_exec(["apt-get", "clean"])
1488 .with_exec(["c_rehash"])
1489 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1490 )
1491
1492 #
1493 # FIXME: add kitware for cmake on arm-hf
1494 #
1495
1496 return ctr
1497
1498
1499 def build_ubuntu_22_04(
1500 client: dagger.Client, platform: dagger.Platform
1501 ) -> dagger.Container:
1502 ctr = client.container(platform=platform).from_("ubuntu:22.04")
1503
1504 pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
1505
1506 ctr = (
1507 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1508 .with_exec(["apt-get", "update"])
1509 .with_exec(["apt-get", "upgrade", "-y"])
1510 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1511 .with_exec(["apt-get", "clean"])
1512 .with_exec(["c_rehash"])
1513 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1514 )
1515
1516 return ctr
1517
1518
1519 def build_ubuntu_23_04(
1520 client: dagger.Client, platform: dagger.Platform
1521 ) -> dagger.Container:
1522 ctr = client.container(platform=platform).from_("ubuntu:23.04")
1523
1524 pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
1525
1526 ctr = (
1527 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1528 .with_exec(["apt-get", "update"])
1529 .with_exec(["apt-get", "upgrade", "-y"])
1530 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1531 .with_exec(["apt-get", "clean"])
1532 .with_exec(["c_rehash"])
1533 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1534 )
1535
1536 return ctr
1537
1538
1539 def build_ubuntu_23_10(
1540 client: dagger.Client, platform: dagger.Platform
1541 ) -> dagger.Container:
1542 ctr = client.container(platform=platform).from_("ubuntu:23.10")
1543
1544 pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
1545
1546 ctr = (
1547 ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
1548 .with_exec(["apt-get", "update"])
1549 .with_exec(["apt-get", "upgrade", "-y"])
1550 .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
1551 .with_exec(["apt-get", "clean"])
1552 .with_exec(["c_rehash"])
1553 .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
1554 )
1555
1556 return ctr
1557
1558
1559 def install_cargo(ctr: dagger.Container) -> dagger.Container:
1560 bin_paths = [
1561 "/root/.cargo/bin",
1562 "/usr/local/sbin",
1563 "/usr/local/bin",
1564 "/usr/sbin",
1565 "/usr/bin",
1566 "/sbin",
1567 "/bin",
1568 ]
1569
1570 ctr = (
1571 ctr.with_workdir("/")
1572 .with_exec(["sh", "-c", "curl https://sh.rustup.rs -sSf | sh -s -- -y"])
1573 .with_env_variable("PATH", ":".join(bin_paths))
1574 .with_exec(["cargo", "new", "--bin", "hello"])
1575 .with_workdir("/hello")
1576 .with_exec(["cargo", "run", "-v", "-v"])
1577 )
1578
1579 return ctr