Skip to content

Commit e7e1f0e

Browse files
committed
docker-engine: add nftables dependencies
Signed-off-by: CrazyMax <[email protected]>
1 parent 1ff8587 commit e7e1f0e

File tree

7 files changed

+49
-9
lines changed

7 files changed

+49
-9
lines changed

hack/scripts/rpm-builddep.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
arch=$1
1818
specsDir=$2
19+
shift 2
1920

2021
if [[ -z "$arch" ]] || [[ -z "$specsDir" ]]; then
21-
echo "usage: ./rpm-builddep <arch> <specs-dir>" >&2
22+
echo "usage: ./rpm-builddep <arch> <specs-dir> [extra-args...]" >&2
2223
exit 1
2324
fi
2425

@@ -35,4 +36,4 @@ else
3536
fi
3637

3738
set -x
38-
$builddepCmd -y "$specsDir"/*.spec
39+
$builddepCmd "$@" -y "$specsDir"/*.spec

hack/scripts/verify-rpm-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ case "$pkgrelease" in
3737
dnf install -y findutils dnf-plugins-core oraclelinux-release-el9 oracle-epel-release-el9
3838
dnf config-manager --enable ol9_addons ol9_codeready_builder
3939
;;
40-
fedora*)
40+
fedora*|rhel*)
4141
dnf install -y findutils dnf-plugins-core
4242
;;
4343
rockylinux8|almalinux8)

pkg/docker-engine/Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,16 @@ RUN --mount=type=bind,from=scripts,source=rpm-init.sh,target=/usr/local/bin/rpm-
148148
rpm-init $DISTRO_NAME
149149
COPY rpm /root/rpmbuild/SPECS
150150
ARG TARGETPLATFORM
151-
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
152-
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
151+
RUN --mount=type=bind,from=scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep <<EOT
152+
set -e
153+
no_libnftables=0
154+
case "$DISTRO_NAME" in
155+
rhel*)
156+
no_libnftables=1
157+
;;
158+
esac
159+
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS --define "_no_libnftables ${no_libnftables}"
160+
EOT
153161
WORKDIR /root/rpmbuild
154162
ARG NIGHTLY_BUILD
155163
ARG DISTRO_RELEASE
@@ -196,7 +204,7 @@ ARG PKG_REF
196204
ARG NIGHTLY_BUILD
197205
WORKDIR /build
198206
ARG TARGETPLATFORM
199-
RUN xx-apt-get install -y gcc libc6-dev libapparmor-dev libsecret-1-dev libsystemd-dev libudev-dev pkg-config
207+
RUN xx-apt-get install -y gcc libc6-dev libapparmor-dev libnftables-dev libsecret-1-dev libsystemd-dev libudev-dev pkg-config
200208
RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \
201209
--mount=type=bind,source=scripts/check-gomod.sh,target=/usr/local/bin/check-gomod \
202210
--mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \

pkg/docker-engine/deb/control

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Build-Depends: ca-certificates,
1212
debhelper-compat (= 12),
1313
gcc,
1414
libc-dev,
15+
libnftables-dev,
1516
libsystemd-dev,
1617
libtool,
1718
make,
@@ -22,6 +23,7 @@ Architecture: linux-any
2223
Depends: containerd.io (>= 1.7.27),
2324
docker-ce-cli,
2425
iptables,
26+
nftables,
2527
${shlibs:Depends}
2628
Recommends: apparmor,
2729
ca-certificates,

pkg/docker-engine/rpm/docker-ce.spec

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Recommends: docker-ce-rootless-extras
2020
Requires: container-selinux
2121
Requires: systemd
2222
Requires: iptables
23+
%if 0%{?_no_libnftables} == 0
24+
# When dockerd is not linked against libnftables, the nftables package
25+
# is not a hard requirement.
26+
Requires: nftables
27+
%endif
2328
%if %{undefined rhel} || 0%{?rhel} < 9
2429
# Libcgroup is no longer available in RHEL/CentOS >= 9 distros.
2530
Requires: libcgroup
@@ -35,6 +40,9 @@ BuildRequires: gcc
3540
BuildRequires: glibc-static
3641
BuildRequires: libarchive
3742
BuildRequires: libtool
43+
%if 0%{?_no_libnftables} == 0
44+
BuildRequires: nftables-devel
45+
%endif
3846
BuildRequires: make
3947
BuildRequires: pkgconfig
4048
BuildRequires: pkgconfig(systemd)

pkg/docker-engine/scripts/pkg-rpm-build.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@ export GO111MODULE=$(check-gomod)
5858
xx-go --wrap
5959
fix-cc
6060

61+
no_libnftables=0
62+
case "$DISTRO_NAME" in
63+
rhel*)
64+
no_libnftables=1
65+
;;
66+
esac
67+
6168
rpmDefine=(
6269
--define "_version ${GENVER_PKG_VERSION}"
6370
--define "_origversion ${GENVER_VERSION}"
6471
--define "_release ${PKG_RPM_RELEASE:-${GENVER_RPM_RELEASE}}"
65-
--define "_commit ${GENVER_COMMIT_SHORT}"
72+
--define "_commit ${GENVER_COMMIT_SHORT}"\
73+
--define "_no_libnftables ${no_libnftables}"
6674
)
6775

6876
pkgoutput="${OUTDIR}/${DISTRO_RELEASE}/${DISTRO_SUITE}/$(xx-info arch)"
@@ -75,6 +83,9 @@ case "$DISTRO_NAME" in
7583
export DOCKER_BUILDTAGS="exclude_graphdriver_btrfs $DOCKER_BUILDTAGS"
7684
;;
7785
esac
86+
if [ "$no_libnftables" -eq 1 ]; then
87+
export DOCKER_BUILDTAGS="no_libnftables $DOCKER_BUILDTAGS"
88+
fi
7889

7990
set -x
8091

pkg/docker-engine/verify.Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ FROM scratch AS scripts
2828
FROM ${DISTRO_IMAGE} AS base
2929

3030
FROM base AS verify-deb
31+
RUN apt-get update && apt-get install -y libnftables1
3132
COPY --from=xx / /
3233
ARG DISTRO_RELEASE
3334
ARG DISTRO_ID
@@ -48,7 +49,7 @@ RUN --mount=from=bin,target=/build <<EOT
4849
(
4950
set -x
5051
dpkg-deb --info $package
51-
dpkg -i --ignore-depends=containerd.io,docker-ce-cli,iptables --force-depends $package
52+
dpkg -i --ignore-depends=containerd.io,docker-ce-cli,iptables,nftables --force-depends $package
5253
)
5354
done
5455
set -x
@@ -61,8 +62,17 @@ ARG DISTRO_NAME
6162
ARG DISTRO_RELEASE
6263
ARG DISTRO_ID
6364
ARG DISTRO_SUITE
64-
RUN --mount=type=bind,from=scripts,source=verify-rpm-init.sh,target=/usr/local/bin/verify-rpm-init \
65+
RUN --mount=type=bind,from=scripts,source=verify-rpm-init.sh,target=/usr/local/bin/verify-rpm-init <<EOT
66+
set -e
6567
verify-rpm-init $DISTRO_NAME
68+
case "$DISTRO_NAME" in
69+
rhel*)
70+
;;
71+
*)
72+
dnf install -y nftables
73+
;;
74+
esac
75+
EOT
6676
ARG TARGETPLATFORM
6777
RUN --mount=from=bin,target=/build <<EOT
6878
set -e

0 commit comments

Comments
 (0)