123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263 |
- 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(), f'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.")
- repo_path = str(Path(__file__).parent.parent.parent)
- this_path = os.path.join(repo_path, "packaging/dag")
- ctr = (
- ctr.with_file(f"cmake-{machine}.sha256", client.host().file(f"{this_path}/cmake-{machine}.sha256"))
- .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.")
- repo_path = str(Path(__file__).parent.parent.parent)
- this_path = os.path.join(repo_path, "packaging/dag")
- ctr = (
- ctr.with_file(f"cmake-{machine}.sha256", client.host().file(f"{this_path}/cmake-{machine}.sha256"))
- .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
|