Skip to content

Commit 41015c7

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

File tree

7 files changed

+46
-7
lines changed

7 files changed

+46
-7
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Recommends: docker-ce-rootless-extras
2020
Requires: container-selinux
2121
Requires: systemd
2222
Requires: iptables
23+
Requires: nftables
2324
%if %{undefined rhel} || 0%{?rhel} < 9
2425
# Libcgroup is no longer available in RHEL/CentOS >= 9 distros.
2526
Requires: libcgroup
@@ -35,6 +36,9 @@ BuildRequires: gcc
3536
BuildRequires: glibc-static
3637
BuildRequires: libarchive
3738
BuildRequires: libtool
39+
%if 0%{?_no_libnftables} == 0
40+
BuildRequires: nftables-devel
41+
%endif
3842
BuildRequires: make
3943
BuildRequires: pkgconfig
4044
BuildRequires: pkgconfig(systemd)

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

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

61+
no_libnftables=0
62+
case "$DISTRO_NAME" in
63+
rhel*)
64+
# The nftables-devel package is only available in RHEL CRB. For now, build
65+
# with tag "no_libnftables", so dockerd will exec the nft tool, and this
66+
# package is not required. Note that this '--define' is also defined in
67+
# the Dockerfile to install build dependencies.
68+
no_libnftables=1
69+
;;
70+
esac
71+
6172
rpmDefine=(
6273
--define "_version ${GENVER_PKG_VERSION}"
6374
--define "_origversion ${GENVER_VERSION}"
6475
--define "_release ${PKG_RPM_RELEASE:-${GENVER_RPM_RELEASE}}"
6576
--define "_commit ${GENVER_COMMIT_SHORT}"
77+
--define "_no_libnftables ${no_libnftables}"
6678
)
6779

6880
pkgoutput="${OUTDIR}/${DISTRO_RELEASE}/${DISTRO_SUITE}/$(xx-info arch)"
@@ -75,6 +87,9 @@ case "$DISTRO_NAME" in
7587
export DOCKER_BUILDTAGS="exclude_graphdriver_btrfs $DOCKER_BUILDTAGS"
7688
;;
7789
esac
90+
if [ "$no_libnftables" -eq 1 ]; then
91+
export DOCKER_BUILDTAGS="no_libnftables $DOCKER_BUILDTAGS"
92+
fi
7893

7994
set -x
8095

pkg/docker-engine/verify.Dockerfile

Lines changed: 10 additions & 1 deletion
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
@@ -82,6 +83,14 @@ RUN --mount=from=bin,target=/build <<EOT
8283
rpm --install --nodeps $package
8384
)
8485
done
86+
case "$DISTRO_NAME" in
87+
rhel*)
88+
;;
89+
*)
90+
# dockerd requires libnftables.so.1
91+
dnf install -y nftables
92+
;;
93+
esac
8594
set -x
8695
dockerd --version
8796
EOT

0 commit comments

Comments
 (0)