12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580 |
- import os
- from pathlib import Path
- import dagger
- _ALPINE_COMMON_PACKAGES = [
- "alpine-sdk",
- "autoconf",
- "automake",
- "bash",
- "binutils",
- "bison",
- "cmake",
- "curl",
- "curl-static",
- "elfutils-dev",
- "flex",
- "gcc",
- "git",
- "gnutls-dev",
- "gzip",
- "jq",
- "libelf-static",
- "libmnl-dev",
- "libmnl-static",
- "libtool",
- "libuv-dev",
- "libuv-static",
- "lz4-dev",
- "lz4-static",
- "make",
- "mongo-c-driver-dev",
- "mongo-c-driver-static",
- "musl-fts-dev",
- "ncurses",
- "ncurses-static",
- "netcat-openbsd",
- "ninja",
- "openssh",
- "pcre2-dev",
- "pkgconfig",
- "protobuf-dev",
- "snappy-dev",
- "snappy-static",
- "util-linux-dev",
- "wget",
- "xz",
- "yaml-dev",
- "yaml-static",
- "zlib-dev",
- "zlib-static",
- "zstd-dev",
- "zstd-static",
- ]
- def build_alpine_3_18(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("alpine:3.18")
- pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
- ctr = ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
- return ctr
- def build_alpine_3_19(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("alpine:3.19")
- pkgs = [pkg for pkg in _ALPINE_COMMON_PACKAGES]
- ctr = ctr.with_exec(["apk", "add", "--no-cache"] + pkgs)
- return ctr
- def static_build_openssl(
- client: dagger.Client, ctr: dagger.Container
- ) -> dagger.Container:
- tree = (
- client.git(url="https://github.com/openssl/openssl", keep_git_dir=True)
- .tag("openssl-3.1.4")
- .tree()
- )
- #
- # TODO: verify 32-bit builds
- #
- ctr = (
- ctr.with_directory("/openssl", tree)
- .with_workdir("/openssl")
- .with_env_variable("CFLAGS", "-fno-lto -pipe")
- .with_env_variable("LDFLAGS", "-static")
- .with_env_variable("PKG_CONFIG", "pkg-config --static")
- .with_exec(
- [
- "sed",
- "-i",
- "s/disable('static', 'pic', 'threads');/disable('static', 'pic');/",
- "Configure",
- ]
- )
- .with_exec(
- [
- "./config",
- "-static",
- "threads",
- "no-tests",
- "--prefix=/openssl-static",
- "--openssldir=/opt/netdata/etc/ssl",
- ]
- )
- .with_exec(["make", "V=1", "-j", str(os.cpu_count())])
- .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install_sw"])
- .with_exec(["ln", "-s", "/openssl-static/lib", "/openssl-static/lib64"])
- .with_exec(["perl", "configdata.pm", "--dump"])
- )
- return ctr
- def static_build_bash(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
- tree = (
- client.git(url="https://git.savannah.gnu.org/git/bash.git", keep_git_dir=True)
- .tag("bash-5.1")
- .tree()
- )
- ctr = (
- ctr.with_directory("/bash", tree)
- .with_workdir("/bash")
- .with_env_variable("CFLAGS", "-pipe")
- .with_env_variable("LDFLAGS", "")
- .with_env_variable("PKG_CONFIG", "pkg-config --static")
- .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
- .with_exec(
- [
- "./configure",
- "--prefix",
- "/opt/netdata",
- "--without-bash-malloc",
- "--enable-static-link",
- "--enable-net-redirections",
- "--enable-array-variables",
- "--disable-progcomp",
- "--disable-profiling",
- "--disable-nls",
- "--disable-dependency-tracking",
- ]
- )
- .with_exec(
- [
- "echo",
- "-e",
- "all:\nclean:\ninstall:\n",
- ">",
- "examples/loadables/Makefile",
- ]
- )
- .with_exec(["make", "clean"])
- # see: https://gitweb.gentoo.org/repo/gentoo.git/tree/app-shells/bash/files/bash-5.1-parallel_make.patch?id=4c2ebbf4b8bc660beb98cc2d845c73375d6e4f50
- .with_exec(["make", "V=1", "-j", "2", "install"])
- .with_exec(["strip", "/opt/netdata/bin/bash"])
- )
- return ctr
- def static_build_curl(client: dagger.Client, ctr: dagger.Container) -> dagger.Container:
- tree = (
- client.git(url="https://github.com/curl/curl", keep_git_dir=True)
- .tag("curl-8_4_0")
- .tree()
- )
- ctr = (
- ctr.with_directory("/curl", tree)
- .with_workdir("/curl")
- .with_env_variable("CFLAGS", "-I/openssl-static/include -pipe")
- .with_env_variable("LDFLAGS", "-static -L/openssl-static/lib64")
- .with_env_variable("PKG_CONFIG", "pkg-config --static")
- .with_env_variable("PKG_CONFIG_PATH", "/openssl-static/lib64/pkgconfig")
- .with_exec(["autoreconf", "-ifv"])
- .with_exec(
- [
- "./configure",
- "--prefix=/curl-static",
- "--enable-optimize",
- "--disable-shared",
- "--enable-static",
- "--enable-http",
- "--disable-ldap",
- "--disable-ldaps",
- "--enable-proxy",
- "--disable-dict",
- "--disable-telnet",
- "--disable-tftp",
- "--disable-pop3",
- "--disable-imap",
- "--disable-smb",
- "--disable-smtp",
- "--disable-gopher",
- "--enable-ipv6",
- "--enable-cookies",
- "--with-ca-fallback",
- "--with-openssl",
- "--disable-dependency-tracking",
- ]
- )
- .with_exec(
- ["sed", "-i", "-e", "s/LDFLAGS =/LDFLAGS = -all-static/", "src/Makefile"]
- )
- .with_exec(["make", "clean"])
- .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
- .with_exec(["cp", "/curl-static/bin/curl", "/opt/netdata/bin/curl"])
- .with_exec(["strip", "/opt/netdata/bin/curl"])
- )
- return ctr
- def static_build_ioping(
- client: dagger.Client, ctr: dagger.Container
- ) -> dagger.Container:
- tree = (
- client.git(url="https://github.com/koct9i/ioping", keep_git_dir=True)
- .tag("v1.3")
- .tree()
- )
- ctr = (
- ctr.with_directory("/ioping", tree)
- .with_workdir("/ioping")
- .with_env_variable("CFLAGS", "-static -pipe")
- .with_exec(["mkdir", "-p", "/opt/netdata/usr/libexec/netdata/plugins.d"])
- .with_exec(["make", "V=1"])
- .with_exec(
- [
- "install",
- "-o",
- "root",
- "-g",
- "root",
- "-m",
- "4750",
- "ioping",
- "/opt/netdata/usr/libexec/netdata/plugins.d",
- ]
- )
- .with_exec(["strip", "/opt/netdata/usr/libexec/netdata/plugins.d/ioping"])
- )
- return ctr
- def static_build_libnetfilter_acct(
- client: dagger.Client, ctr: dagger.Container
- ) -> dagger.Container:
- tree = (
- client.git(url="git://git.netfilter.org/libnetfilter_acct", keep_git_dir=True)
- .tag("libnetfilter_acct-1.0.3")
- .tree()
- )
- ctr = (
- ctr.with_directory("/libnetfilter_acct", tree)
- .with_workdir("/libnetfilter_acct")
- .with_env_variable("CFLAGS", "-static -I/usr/include/libmnl -pipe")
- .with_env_variable("LDFLAGS", "-static -L/usr/lib -lmnl")
- .with_env_variable("PKG_CONFIG", "pkg-config --static")
- .with_env_variable("PKG_CONFIG_PATH", "/usr/lib/pkgconfig")
- .with_exec(["autoreconf", "-ifv"])
- .with_exec(
- [
- "./configure",
- "--prefix=/libnetfilter_acct-static",
- "--exec-prefix=/libnetfilter_acct-static",
- ]
- )
- .with_exec(["make", "clean"])
- .with_exec(["make", "V=1", "-j", str(os.cpu_count()), "install"])
- )
- return ctr
- def static_build_netdata(
- client: dagger.Client, ctr: dagger.Container
- ) -> dagger.Container:
- CFLAGS = [
- "-ffunction-sections",
- "-fdata-sections",
- "-static",
- "-O2",
- "-funroll-loops",
- "-I/openssl-static/include",
- "-I/libnetfilter_acct-static/include/libnetfilter_acct",
- "-I/curl-local/include/curl",
- "-I/usr/include/libmnl",
- "-pipe",
- ]
- LDFLAGS = [
- "-Wl,--gc-sections",
- "-static",
- "-L/openssl-static/lib64",
- "-L/libnetfilter_acct-static/lib",
- "-lnetfilter_acct",
- "-L/usr/lib",
- "-lmnl",
- "-L/usr/lib",
- "-lzstd",
- "-L/curl-local/lib",
- ]
- PKG_CONFIG = [
- "pkg-config",
- "--static",
- ]
- PKG_CONFIG_PATH = [
- "/openssl-static/lib64/pkgconfig",
- "/libnetfilter_acct-static/lib/pkgconfig",
- "/usr/lib/pkgconfig",
- "/curl-local/lib/pkgconfig",
- ]
- CMAKE_FLAGS = [
- "-DOPENSSL_ROOT_DIR=/openssl-static",
- "-DOPENSSL_LIBRARIES=/openssl-static/lib64",
- "-DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/openssl-static",
- "-DLWS_OPENSSL_INCLUDE_DIRS=/openssl-static/include",
- "-DLWS_OPENSSL_LIBRARIES=/openssl-static/lib64/libssl.a;/openssl-static/lib64/libcrypto.a",
- ]
- NETDATA_INSTALLER_CMD = [
- "./netdata-installer.sh",
- "--install-prefix",
- "/opt",
- "--dont-wait",
- "--dont-start-it",
- "--disable-exporting-mongodb",
- "--require-cloud",
- "--use-system-protobuf",
- "--dont-scrub-cflags-even-though-it-may-break-things",
- "--one-time-build",
- "--enable-lto",
- ]
- ctr = (
- ctr.with_workdir("/netdata")
- .with_env_variable("NETDATA_CMAKE_OPTIONS", "-DCMAKE_BUILD_TYPE=Debug")
- .with_env_variable("CFLAGS", " ".join(CFLAGS))
- .with_env_variable("LDFLAGS", " ".join(LDFLAGS))
- .with_env_variable("PKG_CONFIG", " ".join(PKG_CONFIG))
- .with_env_variable("PKG_CONFIG_PATH", ":".join(PKG_CONFIG_PATH))
- .with_env_variable("CMAKE_FLAGS", " ".join(CMAKE_FLAGS))
- .with_env_variable("EBPF_LIBC", "static")
- .with_env_variable("IS_NETDATA_STATIC_BINARY", "yes")
- .with_exec(NETDATA_INSTALLER_CMD)
- )
- return ctr
- def static_build(client, repo_path):
- cmake_build_release_path = os.path.join(repo_path, "cmake-build-release")
- ctr = build_alpine_3_18(client, dagger.Platform("linux/x86_64"))
- ctr = static_build_openssl(client, ctr)
- ctr = static_build_bash(client, ctr)
- ctr = static_build_curl(client, ctr)
- ctr = static_build_ioping(client, ctr)
- ctr = static_build_libnetfilter_acct(client, ctr)
- ctr = ctr.with_directory(
- "/netdata",
- client.host().directory(repo_path),
- exclude=[
- f"{cmake_build_release_path}/*",
- "fluent-bit/build",
- ],
- )
- # TODO: link bin/sbin
- ctr = static_build_netdata(client, ctr)
- build_dir = ctr.directory("/opt/netdata")
- artifact_dir = os.path.join(Path.home(), "ci/netdata-static")
- output_task = build_dir.export(artifact_dir)
- return output_task
- _CENTOS_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "autogen",
- "automake",
- "bison",
- "bison-devel",
- "cmake",
- "cups-devel",
- "curl",
- "diffutils",
- "elfutils-libelf-devel",
- "findutils",
- "flex",
- "flex-devel",
- "freeipmi-devel",
- "gcc",
- "gcc-c++",
- "git-core",
- "golang",
- "json-c-devel",
- "libyaml-devel",
- "libatomic",
- "libcurl-devel",
- "libmnl-devel",
- "libnetfilter_acct-devel",
- "libtool",
- "libuuid-devel",
- "libuv-devel",
- "libzstd-devel",
- "lm_sensors",
- "lz4-devel",
- "make",
- "ninja-build",
- "openssl-devel",
- "openssl-perl",
- "patch",
- "pcre2-devel",
- "pkgconfig",
- "pkgconfig(libmongoc-1.0)",
- "procps",
- "protobuf-c-devel",
- "protobuf-compiler",
- "protobuf-devel",
- "rpm-build",
- "rpm-devel",
- "rpmdevtools",
- "snappy-devel",
- "systemd-devel",
- "wget",
- "zlib-devel",
- ]
- def build_amazon_linux_2(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("amazonlinux:2")
- pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["yum", "update", "-y"])
- .with_exec(["yum", "install", "-y"] + pkgs)
- .with_exec(["yum", "clean", "all"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- if platform == "linux/x86_64":
- machine = "x86_64"
- elif platform == "linux/arm64":
- machine = "aarch64"
- else:
- raise Exception(
- "Amaxon Linux 2 supports only linux/amd64 and linux/arm64 platforms."
- )
- checksum_path = Path(__file__).parent / f"files/cmake-{machine}.sha256"
- ctr = (
- ctr.with_file(
- f"cmake-{machine}.sha256",
- client.host().file(checksum_path.as_posix()),
- )
- .with_exec(
- [
- "curl",
- "--fail",
- "-sSL",
- "--connect-timeout",
- "20",
- "--retry",
- "3",
- "--output",
- f"cmake-{machine}.sh",
- f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
- ]
- )
- .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
- .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
- .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
- )
- return ctr
- def build_centos_7(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("centos:7")
- pkgs = [pkg for pkg in _CENTOS_COMMON_PACKAGES] + ["bash"]
- ctr = (
- ctr.with_exec(["yum", "install", "-y", "epel-release"])
- .with_exec(["yum", "update", "-y"])
- .with_exec(["yum", "install", "-y"] + pkgs)
- .with_exec(["yum", "clean", "all"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- if platform == "linux/x86_64":
- machine = "x86_64"
- elif platform == "linux/arm64":
- machine = "aarch64"
- else:
- raise Exception("CentOS 7 supports only linux/amd64 and linux/arm64 platforms.")
- checksum_path = Path(__file__).parent / f"files/cmake-{machine}.sha256"
- ctr = (
- ctr.with_file(
- f"cmake-{machine}.sha256",
- client.host().file(checksum_path.as_posix()),
- )
- .with_exec(
- [
- "curl",
- "--fail",
- "-sSL",
- "--connect-timeout",
- "20",
- "--retry",
- "3",
- "--output",
- f"cmake-{machine}.sh",
- f"https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-{machine}.sh",
- ]
- )
- .with_exec(["sha256sum", "-c", f"cmake-{machine}.sha256"])
- .with_exec(["chmod", "u+x", f"./cmake-{machine}.sh"])
- .with_exec([f"./cmake-{machine}.sh", "--skip-license", "--prefix=/usr/local"])
- )
- return ctr
- _ROCKY_LINUX_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "automake",
- "bash",
- "bison",
- "cmake",
- "cups-devel",
- "curl",
- "libcurl-devel",
- "diffutils",
- "elfutils-libelf-devel",
- "findutils",
- "flex",
- "freeipmi-devel",
- "gcc",
- "gcc-c++",
- "git",
- "golang",
- "json-c-devel",
- "libatomic",
- "libmnl-devel",
- "libtool",
- "libuuid-devel",
- "libuv-devel",
- "libyaml-devel",
- "libzstd-devel",
- "lm_sensors",
- "lz4-devel",
- "make",
- "ninja-build",
- "nc",
- "openssl-devel",
- "openssl-perl",
- "patch",
- "pcre2-devel",
- "pkgconfig",
- "pkgconfig(libmongoc-1.0)",
- "procps",
- "protobuf-c-devel",
- "protobuf-compiler",
- "protobuf-devel",
- "python3",
- "python3-pyyaml",
- "rpm-build",
- "rpm-devel",
- "rpmdevtools",
- "snappy-devel",
- "systemd-devel",
- "wget",
- "zlib-devel",
- ]
- def build_rocky_linux_8(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("rockylinux:8")
- pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES] + ["autogen"]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "dnf-command(config-manager)",
- "epel-release",
- ]
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
- .with_exec(["dnf", "clean", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- def build_rocky_linux_9(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("rockylinux:9")
- pkgs = [pkg for pkg in _ROCKY_LINUX_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "dnf-command(config-manager)",
- "epel-release",
- ]
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
- .with_exec(["dnf", "clean", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--allowerasing",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- _CENTOS_STREAM_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "automake",
- "bash",
- "bison",
- "cmake",
- "cups-devel",
- "curl",
- "libcurl-devel",
- "libyaml-devel",
- "diffutils",
- "elfutils-libelf-devel",
- "findutils",
- "flex",
- "freeipmi-devel",
- "gcc",
- "gcc-c++",
- "git",
- "golang",
- "json-c-devel",
- "libatomic",
- "libmnl-devel",
- "libtool",
- "libuuid-devel",
- "libuv-devel",
- # "libzstd-devel",
- "lm_sensors",
- "lz4-devel",
- "make",
- "ninja-build",
- "nc",
- "openssl-devel",
- "openssl-perl",
- "patch",
- "pcre2-devel",
- "pkgconfig",
- "pkgconfig(libmongoc-1.0)",
- "procps",
- "protobuf-c-devel",
- "protobuf-compiler",
- "protobuf-devel",
- "python3",
- "python3-pyyaml",
- "rpm-build",
- "rpm-devel",
- "rpmdevtools",
- "snappy-devel",
- "systemd-devel",
- "wget",
- "zlib-devel",
- ]
- def build_centos_stream_8(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream8")
- pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES] + ["autogen"]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "dnf-command(config-manager)",
- "epel-release",
- ]
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "powertools"])
- .with_exec(["dnf", "clean", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- def build_centos_stream_9(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("quay.io/centos/centos:stream9")
- pkgs = [pkg for pkg in _CENTOS_STREAM_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "dnf-command(config-manager)",
- "epel-release",
- ]
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "crb"])
- .with_exec(["dnf", "clean", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--allowerasing",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- _ORACLE_LINUX_COMMON_PACKAGES = list(_ROCKY_LINUX_COMMON_PACKAGES)
- def build_oracle_linux_9(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("oraclelinux:9")
- pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES]
- repo_path = str(Path(__file__).parent.parent.parent)
- this_path = os.path.join(repo_path, "packaging/dag")
- ctr = (
- ctr.with_file(
- "/etc/yum.repos.d/ol9-epel.repo",
- client.host().file(f"{this_path}/ol9-epel.repo"),
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_codeready_builder"])
- .with_exec(["dnf", "config-manager", "--set-enabled", "ol9_developer_EPEL"])
- .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(["dnf", "clean", "-y", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- def build_oracle_linux_8(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("oraclelinux:8")
- pkgs = [pkg for pkg in _ORACLE_LINUX_COMMON_PACKAGES] + ["autogen"]
- repo_path = str(Path(__file__).parent.parent.parent)
- this_path = os.path.join(repo_path, "packaging/dag")
- ctr = (
- ctr.with_file(
- "/etc/yum.repos.d/ol8-epel.repo",
- client.host().file(f"{this_path}/ol8-epel.repo"),
- )
- .with_exec(["dnf", "config-manager", "--set-enabled", "ol8_codeready_builder"])
- .with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(["dnf", "clean", "-y", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- _OPENSUSE_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "autogen",
- "automake",
- "bison",
- "cmake",
- "cups",
- "cups-devel",
- "curl",
- "diffutils",
- "flex",
- "freeipmi-devel",
- "gcc",
- "gcc-c++",
- "git-core",
- "go",
- "json-glib-devel",
- "judy-devel",
- "libatomic1",
- "libcurl-devel",
- "libelf-devel",
- "liblz4-devel",
- "libjson-c-devel",
- "libyaml-devel",
- "libmnl0",
- "libmnl-devel",
- "libnetfilter_acct1",
- "libnetfilter_acct-devel",
- "libpcre2-8-0",
- "libopenssl-devel",
- "libtool",
- "libuv-devel",
- "libuuid-devel",
- "libzstd-devel",
- "make",
- "ninja",
- "patch",
- "pkg-config",
- "protobuf-devel",
- "rpm-build",
- "rpm-devel",
- "rpmdevtools",
- "snappy-devel",
- "systemd-devel",
- "tar",
- "wget",
- "xen-devel",
- ]
- def build_opensuse_tumbleweed(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("opensuse/tumbleweed:latest")
- pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["protobuf-c"]
- ctr = (
- ctr.with_exec(["zypper", "update", "-y"])
- .with_exec(
- [
- "zypper",
- "install",
- "-y",
- "--allow-downgrade",
- ]
- + pkgs
- )
- .with_exec(["zypper", "clean"])
- .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/usr/src/packages/BUILD",
- "/usr/src/packages/RPMS",
- "/usr/src/packages/SOURCES",
- "/usr/src/packages/SPECS",
- "/usr/src/packages/SRPMS",
- ]
- )
- )
- return ctr
- def build_opensuse_15_5(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("opensuse/leap:15.5")
- pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
- ctr = (
- ctr.with_exec(["zypper", "update", "-y"])
- .with_exec(
- [
- "zypper",
- "install",
- "-y",
- "--allow-downgrade",
- ]
- + pkgs
- )
- .with_exec(["zypper", "clean"])
- .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/usr/src/packages/BUILD",
- "/usr/src/packages/RPMS",
- "/usr/src/packages/SOURCES",
- "/usr/src/packages/SPECS",
- "/usr/src/packages/SRPMS",
- ]
- )
- )
- return ctr
- def build_opensuse_15_4(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- crt = client.container(platform=platform).from_("opensuse/leap:15.4")
- pkgs = [pkg for pkg in _OPENSUSE_COMMON_PACKAGES] + ["libprotobuf-c-devel"]
- crt = (
- crt.with_exec(["zypper", "update", "-y"])
- .with_exec(
- [
- "zypper",
- "install",
- "-y",
- "--allow-downgrade",
- ]
- + pkgs
- )
- .with_exec(["zypper", "clean"])
- .with_exec(["rm", "-rf", "/var/cache/zypp/*/*"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/usr/src/packages/BUILD",
- "/usr/src/packages/RPMS",
- "/usr/src/packages/SOURCES",
- "/usr/src/packages/SPECS",
- "/usr/src/packages/SRPMS",
- ]
- )
- )
- return crt
- _FEDORA_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "autogen",
- "automake",
- "bash",
- "bison",
- "cmake",
- "cups-devel",
- "curl",
- "diffutils",
- "elfutils-libelf-devel",
- "findutils",
- "flex",
- "freeipmi-devel",
- "gcc",
- "gcc-c++",
- "git-core",
- "golang",
- "json-c-devel",
- "libcurl-devel",
- "libyaml-devel",
- "Judy-devel",
- "libatomic",
- "libmnl-devel",
- "libnetfilter_acct-devel",
- "libtool",
- "libuuid-devel",
- "libuv-devel",
- "libzstd-devel",
- "lz4-devel",
- "make",
- "ninja-build",
- "openssl-devel",
- "openssl-perl",
- "patch",
- "pcre2-devel",
- "pkgconfig",
- ]
- def build_fedora_37(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("fedora:37")
- pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(["dnf", "clean", "-y", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- def build_fedora_38(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("fedora:38")
- pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(["dnf", "clean", "-y", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- def build_fedora_39(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("fedora:39")
- pkgs = [pkg for pkg in _FEDORA_COMMON_PACKAGES]
- ctr = (
- ctr.with_exec(["dnf", "distro-sync", "-y", "--nodocs"])
- .with_exec(["dnf", "clean", "-y", "packages"])
- .with_exec(
- [
- "dnf",
- "install",
- "-y",
- "--nodocs",
- "--setopt=install_weak_deps=False",
- "--setopt=diskspacecheck=False",
- ]
- + pkgs
- )
- .with_exec(["rm", "-rf", "/var/cache/dnf"])
- .with_exec(["c_rehash"])
- .with_exec(
- [
- "mkdir",
- "-p",
- "/root/rpmbuild/BUILD",
- "/root/rpmbuild/RPMS",
- "/root/rpmbuild/SOURCES",
- "/root/rpmbuild/SPECS",
- "/root/rpmbuild/SRPMS",
- ]
- )
- )
- return ctr
- _DEBIAN_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "autogen",
- "automake",
- "bison",
- "build-essential",
- "ca-certificates",
- "cmake",
- "curl",
- "dh-autoreconf",
- "dh-make",
- "dpkg-dev",
- "flex",
- "g++",
- "gcc",
- "git-buildpackage",
- "git-core",
- "golang",
- "libatomic1",
- "libcurl4-openssl-dev",
- "libcups2-dev",
- "libdistro-info-perl",
- "libelf-dev",
- "libipmimonitoring-dev",
- "libjson-c-dev",
- "libyaml-dev",
- "libjudy-dev",
- "liblz4-dev",
- "libmnl-dev",
- "libmongoc-dev",
- "libnetfilter-acct-dev",
- "libpcre2-dev",
- "libprotobuf-dev",
- "libprotoc-dev",
- "libsnappy-dev",
- "libsystemd-dev",
- "libssl-dev",
- "libtool",
- "libuv1-dev",
- "libzstd-dev",
- "make",
- "ninja-build",
- "pkg-config",
- "protobuf-compiler",
- "systemd",
- "uuid-dev",
- "wget",
- "zlib1g-dev",
- ]
- def build_debian_10(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("debian:buster")
- pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["dh-systemd", "libxen-dev"]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- def build_debian_11(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("debian:bullseye")
- pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES] + ["libxen-dev"]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- def build_debian_12(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("debian:bookworm")
- pkgs = [pkg for pkg in _DEBIAN_COMMON_PACKAGES]
- if platform != dagger.Platform("linux/i386"):
- pkgs.append("libxen-dev")
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- _UBUNTU_COMMON_PACKAGES = [
- "autoconf",
- "autoconf-archive",
- "autogen",
- "automake",
- "bison",
- "build-essential",
- "ca-certificates",
- "cmake",
- "curl",
- "dh-autoreconf",
- "dh-make",
- "dpkg-dev",
- "flex",
- "g++",
- "gcc",
- "git-buildpackage",
- "git-core",
- "golang",
- "libatomic1",
- "libcurl4-openssl-dev",
- "libcups2-dev",
- "libdistro-info-perl",
- "libelf-dev",
- "libipmimonitoring-dev",
- "libjson-c-dev",
- "libyaml-dev",
- "libjudy-dev",
- "liblz4-dev",
- "libmnl-dev",
- "libmongoc-dev",
- "libnetfilter-acct-dev",
- "libpcre2-dev",
- "libprotobuf-dev",
- "libprotoc-dev",
- "libsnappy-dev",
- "libsystemd-dev",
- "libssl-dev",
- "libtool",
- "libuv1-dev",
- "libxen-dev",
- "libzstd-dev",
- "make",
- "ninja-build",
- "pkg-config",
- "protobuf-compiler",
- "systemd",
- "uuid-dev",
- "wget",
- "zlib1g-dev",
- ]
- def build_ubuntu_20_04(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("ubuntu:20.04")
- pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES] + ["dh-systemd"]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- #
- # FIXME: add kitware for cmake on arm-hf
- #
- return ctr
- def build_ubuntu_22_04(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("ubuntu:22.04")
- pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- def build_ubuntu_23_04(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("ubuntu:23.04")
- pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- def build_ubuntu_23_10(
- client: dagger.Client, platform: dagger.Platform
- ) -> dagger.Container:
- ctr = client.container(platform=platform).from_("ubuntu:23.10")
- pkgs = [pkg for pkg in _UBUNTU_COMMON_PACKAGES]
- ctr = (
- ctr.with_env_variable("DEBIAN_FRONTEND", "noninteractive")
- .with_exec(["apt-get", "update"])
- .with_exec(["apt-get", "upgrade", "-y"])
- .with_exec(["apt-get", "install", "-y", "--no-install-recommends"] + pkgs)
- .with_exec(["apt-get", "clean"])
- .with_exec(["c_rehash"])
- .with_exec(["rm", "-rf", "/var/lib/apt/lists/*"])
- )
- return ctr
- def install_cargo(ctr: dagger.Container) -> dagger.Container:
- bin_paths = [
- "/root/.cargo/bin",
- "/usr/local/sbin",
- "/usr/local/bin",
- "/usr/sbin",
- "/usr/bin",
- "/sbin",
- "/bin",
- ]
- ctr = (
- ctr.with_workdir("/")
- .with_exec(["sh", "-c", "curl https://sh.rustup.rs -sSf | sh -s -- -y"])
- .with_env_variable("PATH", ":".join(bin_paths))
- .with_exec(["cargo", "new", "--bin", "hello"])
- .with_workdir("/hello")
- .with_exec(["cargo", "run", "-v", "-v"])
- )
- return ctr
|