From 0b469b4cc53f642716a98639f20f463ced00a818 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Mon, 7 Mar 2022 09:04:41 +0000 Subject: [PATCH] Build for CentOS 9. Signed-off-by: Romain Geissler --- Jenkinsfile | 1 + rpm/Makefile | 6 +++--- rpm/SPECS/docker-ce.spec | 7 ++++++- rpm/centos-8/Dockerfile | 8 ++++---- rpm/centos-9/Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 rpm/centos-9/Dockerfile diff --git a/Jenkinsfile b/Jenkinsfile index d551e9cc7a..6e05c556fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,7 @@ def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME def pkgs = [ [target: "centos-7", image: "centos:7", arches: ["amd64", "aarch64"]], // (EOL: June 30, 2024) [target: "centos-8", image: "quay.io/centos/centos:stream8", arches: ["amd64", "aarch64"]], + [target: "centos-9", image: "quay.io/centos/centos:stream9", arches: ["amd64", "aarch64"]], [target: "debian-buster", image: "debian:buster", arches: ["amd64", "aarch64", "armhf"]], // Debian 10 (EOL: 2024) [target: "debian-bullseye", image: "debian:bullseye", arches: ["amd64", "aarch64", "armhf"]], // Debian 11 (Next stable) [target: "fedora-34", image: "fedora:34", arches: ["amd64", "aarch64"]], // EOL: May 17, 2022 diff --git a/rpm/Makefile b/rpm/Makefile index d7fc055c69..8748478328 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -57,7 +57,7 @@ RUN?=docker run --rm \ rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS) FEDORA_RELEASES ?= fedora-36 fedora-35 fedora-34 -CENTOS_RELEASES ?= centos-7 centos-8 +CENTOS_RELEASES ?= centos-7 centos-8 centos-9 ifeq ($(ARCH),s390x) RHEL_RELEASES ?= rhel-7 else @@ -83,8 +83,8 @@ rpm: fedora centos ## build all rpm packages .PHONY: fedora fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages -.PHONY: centos-8 -centos-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1' +.PHONY: centos-8 centos-9 +centos-8 centos-9: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1' .PHONY: centos centos: $(CENTOS_RELEASES) ## build all centos rpm packages diff --git a/rpm/SPECS/docker-ce.spec b/rpm/SPECS/docker-ce.spec index 718ace7f4e..a8d1fc914d 100644 --- a/rpm/SPECS/docker-ce.spec +++ b/rpm/SPECS/docker-ce.spec @@ -1,7 +1,9 @@ %global debug_package %{nil} # BTRFS is enabled by default, but can be disabled by defining _without_btrfs -%{!?_with_btrfs: %{!?_without_btrfs: %define _with_btrfs 1}} +%if %{undefined _with_btrfs} && %{undefined _without_btrfs} +%define _with_btrfs 1 +%endif Name: docker-ce Version: %{_version} @@ -22,7 +24,10 @@ Requires: container-selinux >= 2:2.74 Requires: libseccomp >= 2.3 Requires: systemd Requires: iptables +%if %{undefined rhel} || 0%{?rhel} < 9 +# Libcgroup is no longer available in RHEL/CentOS >= 9 distros. Requires: libcgroup +%endif Requires: containerd.io >= 1.4.1 Requires: tar Requires: xz diff --git a/rpm/centos-8/Dockerfile b/rpm/centos-8/Dockerfile index b2b506624a..6f8de70b32 100644 --- a/rpm/centos-8/Dockerfile +++ b/rpm/centos-8/Dockerfile @@ -29,16 +29,16 @@ RUN if [ -f /etc/yum.repos.d/CentOS-Stream-PowerTools.repo ]; then sed -i 's/ena # https://forums.centos.org/viewtopic.php?f=54&t=72574, and # https://access.redhat.com/solutions/3720351 RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial -RUN yum install -y rpm-build rpmlint yum-utils +RUN dnf install -y rpm-build rpmlint dnf-plugins-core COPY SPECS /root/rpmbuild/SPECS # TODO change once we support scan-plugin on other architectures RUN \ if [ "$(uname -m)" = "x86_64" ]; then \ - yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \ else \ - yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \ - yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/centos-9/Dockerfile b/rpm/centos-9/Dockerfile new file mode 100644 index 0000000000..4228326018 --- /dev/null +++ b/rpm/centos-9/Dockerfile @@ -0,0 +1,42 @@ +ARG GO_IMAGE +ARG DISTRO=centos +ARG SUITE=9 +ARG BUILD_IMAGE=quay.io/centos/${DISTRO}:stream${SUITE} + +FROM ${GO_IMAGE} AS golang + +FROM ${BUILD_IMAGE} +ENV GOPROXY=direct +ENV GO111MODULE=off +ENV GOPATH=/go +ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin +ENV AUTO_GOPATH 1 +ENV DOCKER_BUILDTAGS exclude_graphdriver_btrfs seccomp selinux +ENV RUNC_BUILDTAGS seccomp selinux +ARG DISTRO +ARG SUITE +ENV DISTRO=${DISTRO} +ENV SUITE=${SUITE} + +# RHEL8 / CentOS 8 changed behavior and no longer "rpm --import" or +# "rpmkeys --import"as part of rpm package's %post scriplet. See +# https://forums.centos.org/viewtopic.php?f=54&t=72574, and +# https://access.redhat.com/solutions/3720351 +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +RUN dnf install -y rpm-build rpmlint dnf-plugins-core +RUN dnf config-manager --set-enabled crb + +COPY SPECS /root/rpmbuild/SPECS + +# TODO change once we support scan-plugin on other architectures +RUN \ + if [ "$(uname -m)" = "x86_64" ]; then \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \ + else \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \ + dnf builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \ + fi + +COPY --from=golang /usr/local/go /usr/local/go +WORKDIR /root/rpmbuild +ENTRYPOINT ["/bin/rpmbuild"]