Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Earthly-based builds #2

Open
wants to merge 8 commits into
base: rv
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
VERSION 0.6

ARG DEFAULT_DISTRO=ubuntu
ARG DEFAULT_RELEASE=22.04

all:
BUILD +pkg --DISTRO=ubuntu --RELEASE=20.04 # focal
BUILD +pkg --DISTRO=ubuntu --RELEASE=22.04 # jammy

BUILD +pkg --DISTRO=centos --RELEASE=7
BUILD +pkg --DISTRO=centos --RELEASE=8

os-one:
ARG --required DISTRO
ARG --required RELEASE
ARG --required TARGETARCH
FROM --platform=${TARGETPLATFORM} ${DISTRO}:${RELEASE}
WORKDIR /build

IF [ "${DISTRO}" = "centos" ]
IF [ "${RELEASE}" = "8" ]
RUN sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
RUN dnf install -y dnf-plugins-core
RUN dnf config-manager --set-enabled powertools
END
RUN yum install -y --setopt=skip_missing_names_on_install=False \
ca-certificates
ELSE
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
wget
END

deps-one:
ARG --required DISTRO
ARG --required RELEASE
ARG --required TARGETARCH
FROM +os-one --DISTRO=${DISTRO} --RELEASE=${RELEASE}

IF [ "${DISTRO}" = "centos" ]
RUN curl -O https://rpm.frrouting.org/repo/frr-stable-repo-1-0.el7.noarch.rpm && \
yum install -y ./frr-stable* && \
yum install -y --setopt=skip_missing_names_on_install=False \
librtr-devel libyang2-devel

RUN yum install -y --setopt=skip_missing_names_on_install=False \
epel-release

RUN yum install -y --setopt=skip_missing_names_on_install=False \
git cmake \
autoconf automake \
libtool make \
rpm-build \
readline-devel \
texinfo \
net-snmp-devel \
groff \
pkgconfig \
json-c-devel \
pam-devel \
bison flex \
c-ares-devel \
libcap-devel \
elfutils-libelf-devel \
libssh libssh-devel \
libunwind-devel \
systemd-devel \
python3 python3-devel python3-sphinx
IF [ "${RELEASE}" = "7" ]
RUN pip3 install pytest
ELSE
RUN yum install -y --setopt=skip_missing_names_on_install=False \
python3-pytest
END

ELSE
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
autoconf automake \
libtool make \
build-essential \
devscripts equivs \
libreadline-dev texinfo \
pkg-config \
libpam0g-dev \
libjson-c-dev \
bison flex \
libc-ares-dev \
python3-dev python3-sphinx \
install-info \
libsnmp-dev \
perl \
libcap-dev \
libelf-dev \
libunwind-dev \
wget
END

# only "new" releases have libyang and librtr
IF [ "${TARGETARCH}" = "arm64" ]
ARG frr_arch="arm8"
ELSE
ARG frr_arch="x86_64"
END

IF [ "${DISTRO}" = "centos" ]

ELSE
IF [ "$DISTRO" = "ubuntu" ] && [ "${RELEASE}" = "20.04" ]
# libyang
ARG yang_base="https://ci1.netdef.org/artifact/LIBYANG-LIBYANGV2/shared/build-12"
ARG yang_pkg="${yang_base}/Ubuntu-${RELEASE}-${frr_arch}-Packages"
RUN wget "${yang_pkg}/libyang2_2.0.7-1~${DISTRO}${RELEASE}u1_${TARGETARCH}.deb" && \
wget "${yang_pkg}/libyang2-dev_2.0.7-1~${DISTRO}${RELEASE}u1_${TARGETARCH}.deb"
# librtr
ARG rtr_base="https://ci1.netdef.org/artifact/RPKI-RTRLIB/shared/build-00149"
ARG rtr_pkg="${rtr_base}/Ubuntu-${RELEASE}-${frr_arch}-Packages"
RUN wget "${rtr_pkg}/librtr-dev_0.8.0_${TARGETARCH}.deb" && \
wget "${rtr_pkg}/librtr0_0.8.0_${TARGETARCH}.deb"
ARG extra_pkgs="./*.deb"
ELSE
ARG extra_pkgs="libyang2-dev librtr-dev"
END
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
${extra_pkgs}

COPY --dir debian ./
RUN mk-build-deps --remove debian/control && \
DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
./frr-build-deps_8.5~dev-1_all.deb
END

pkg-one:
ARG DISTRO=${DEFAULT_DISTRO}
ARG RELEASE=${DEFAULT_RELEASE}
ARG TARGETPLATFORM
FROM +deps-one --DISTRO=${DISTRO} --RELEASE=${RELEASE}
COPY --dir * .
# Append -rv to the frr version
# We do this here so that it's easier to apply the rv-specific patches to new releases
RUN sed -ri 's/^AC_INIT\(\[frr\], \[(.+)\], /AC_INIT([frr], [\1-rv], /' configure.ac && \
grep AC_INIT configure.ac
IF [ "${DISTRO}" = "centos" ]
RUN ./bootstrap.sh && \
./configure && \
make dist
RUN mkdir -p rpmbuild/SOURCES rpmbuild/SPECS && \
cp redhat/*.spec rpmbuild/SPECS/ && \
cp frr*.tar.gz rpmbuild/SOURCES/.
RUN rpmbuild \
--define "_topdir `pwd`/rpmbuild" \
--define "with_babeld 0" \
--define "with_bfdd 1" \
--define "with_bgpvnc 0" \
--define "with_cumulus 0" \
--define "with_eigrpd 1" \
--define "with_fpm 0" \
--define "with_ldpd 0" \
--define "with_multipath 1" \
--define "with_nhrpd 0" \
--define "with_ospfapi 1" \
--define "with_ospfclient 1" \
--define "with_pam 0" \
--define "with_pbrd 0" \
--define "with_pimd 0" \
--define "with_pim6d 0" \
--define "with_vrrpd 0" \
--define "with_rtadv 0" \
--define "with_watchfrr 1" \
--define "with_pathd 0" \
--define "with_privileged_vty 1" \
-ba rpmbuild/SPECS/frr.spec
SAVE ARTIFACT /build/rpmbuild/RPMS/*/*.rpm AS LOCAL \
./dist/${TARGETPLATFORM}/${DISTRO}/${RELEASE}/
ELSE
RUN dpkg-buildpackage -b -rfakeroot -us -uc
SAVE ARTIFACT ../*.deb AS LOCAL \
./dist/${TARGETPLATFORM}/${DISTRO}/${RELEASE}/
END

pkg:
ARG --required DISTRO
ARG --required RELEASE
BUILD +pkg-one \
--platform=linux/amd64 \
--DISTRO=${DISTRO} --RELEASE=${RELEASE}
4 changes: 4 additions & 0 deletions redhat/frr.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
%{!?with_rtadv: %global with_rtadv 1 }
%{!?with_watchfrr: %global with_watchfrr 1 }
%{!?with_pathd: %global with_pathd 1 }
%{!?with_privileged_vty: %global with_privileged_vty 1 }

# user and group
%{!?frr_user: %global frr_user frr }
Expand Down Expand Up @@ -419,6 +420,9 @@ routing state through standard SNMP MIBs.
--enable-pathd \
%else
--disable-pathd \
%endif
%if %{with_privileged_vty}
--enable-privileged-vty \
%endif
--enable-snmp
# end
Expand Down