Skip to content

Commit 48c86c4

Browse files
nirmannarangprabhav-thali
authored andcommitted
Added support for Rhel 8 and SLES 15 for s390x
Added Dockerfile for rhel-8 and sles-15. Added spec files rpm/SPECS/checkpolicy.spec, rpm/SPECS/policycoreutils.spec for sles-15 support. Modified rpm/SPECS/docker-ce.spec for adding support for sles-15 with btrfs support. Modified rpm/Makefile to add support for sles-15 and rhel-8. Signed-off-by: Nirman Narang <[email protected]> updates policycoreutils to 3.3 Refactor SLES_RELEASE and install git 2.x on RHEL-7 Signed-off-by: Prabhav Thali <[email protected]> rhel9
1 parent 870786d commit 48c86c4

File tree

8 files changed

+252
-6
lines changed

8 files changed

+252
-6
lines changed

rpm/Makefile

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docke
1212
SCAN_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) && git rev-parse --short HEAD)
1313

1414
ifdef BUILD_IMAGE
15-
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
15+
BUILD_IMAGE_FLAG=--build-arg BUILD_IMAGE=$(BUILD_IMAGE)
1616
endif
1717
BUILD?=DOCKER_BUILDKIT=1 \
1818
docker build \
@@ -57,12 +57,22 @@ RUN?=docker run --rm \
5757
$(RUN_FLAGS) \
5858
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
5959

60+
RUN_SLES?=docker run --rm \
61+
-e PLATFORM \
62+
-v $(CURDIR)/rpmbuild/SOURCES:/usr/src/packages/SOURCES:ro \
63+
-v $(CURDIR)/rpmbuild/$@/RPMS:/usr/src/packages/RPMS \
64+
-v $(CURDIR)/rpmbuild/$@/SRPMS:/usr/src/packages/SRPMS \
65+
$(RUN_FLAGS) \
66+
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
67+
6068
FEDORA_RELEASES ?= fedora-36 fedora-35 fedora-34
6169
CENTOS_RELEASES ?= centos-7 centos-8 centos-9
6270
ifeq ($(ARCH),s390x)
63-
RHEL_RELEASES ?= rhel-7
71+
RHEL_RELEASES ?= rhel-7 rhel-8 rhel-9
72+
SLES_RELEASES ?= sles-15
6473
else
6574
RHEL_RELEASES ?=
75+
SLES_RELEASES ?=
6676
endif
6777

6878
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
@@ -79,7 +89,7 @@ clean: ## remove build artifacts
7989
-docker builder prune -f --filter until=24h
8090

8191
.PHONY: rpm
82-
rpm: fedora centos ## build all rpm packages
92+
rpm: fedora centos rhel sles ## build all rpm packages
8393

8494
.PHONY: fedora
8595
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -90,9 +100,15 @@ centos-8 centos-9: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
90100
.PHONY: centos
91101
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
92102

103+
.PHONY: rhel-8 rhel-9
104+
rhel-8 rhel-9: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
105+
93106
.PHONY: rhel
94107
rhel: $(RHEL_RELEASES) ## build all rhel rpm packages
95108

109+
.PHONY: sles
110+
sles: $(SLES_RELEASES) ## build all sles rpm packages
111+
96112
.PHONY: $(DISTROS)
97113
$(DISTROS): sources
98114
@echo "== Building packages for $@ =="
@@ -101,6 +117,14 @@ $(DISTROS): sources
101117
$(RUN)
102118
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
103119

120+
.PHONY: $(SLES_RELEASES)
121+
$(SLES_RELEASES): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz
122+
@echo "== Building packages for $@ =="
123+
mkdir -p "rpmbuild/$@"
124+
$(BUILD)
125+
$(RUN_SLES)
126+
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
127+
104128
.PHONY: sources
105129
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz
106130

rpm/SPECS/docker-ce.spec

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,41 @@ Packager: Docker <[email protected]>
2020
Requires: /usr/sbin/groupadd
2121
Requires: docker-ce-cli
2222
Requires: docker-ce-rootless-extras
23+
%if 0%{?suse_version}
24+
Requires: container-selinux
25+
Requires: libseccomp2
26+
Requires: libcgroup-devel
27+
%else
2328
Requires: container-selinux >= 2:2.74
2429
Requires: libseccomp >= 2.3
25-
Requires: systemd
26-
Requires: iptables
2730
%if %{undefined rhel} || 0%{?rhel} < 9
2831
# Libcgroup is no longer available in RHEL/CentOS >= 9 distros.
2932
Requires: libcgroup
3033
%endif
34+
%endif
35+
Requires: systemd
36+
Requires: iptables
3137
Requires: containerd.io >= 1.6.4
3238
Requires: tar
3339
Requires: xz
3440

3541
BuildRequires: bash
42+
%if 0%{?suse_version}
43+
BuildRequires: btrfsprogs
44+
%else
3645
%{?_with_btrfs:BuildRequires: btrfs-progs-devel}
46+
%endif
3747
BuildRequires: ca-certificates
3848
BuildRequires: cmake
3949
BuildRequires: device-mapper-devel
4050
BuildRequires: gcc
4151
BuildRequires: git
4252
BuildRequires: glibc-static
53+
%if 0%{?suse_version}
54+
BuildRequires: libarchive13
55+
%else
4356
BuildRequires: libarchive
57+
%endif
4458
BuildRequires: libseccomp-devel
4559
BuildRequires: libselinux-devel
4660
BuildRequires: libtool

rpm/SPECS/policycoreutils.spec

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Name: policycoreutils
2+
Version: 3.4
3+
Release: 1%{?dist}
4+
Group: System Environment/Base
5+
Summary: SELinux policy core utilities
6+
License: GPLv2
7+
%description
8+
9+
%configure
10+
11+
BuildRequires: gzip
12+
BuildRequires: make
13+
BuildRequires: gcc7
14+
BuildRequires: flex
15+
BuildRequires: libbz2-devel
16+
BuildRequires: pcre2-devel
17+
BuildRequires: audit-devel
18+
BuildRequires: gettext
19+
BuildRequires: bison
20+
BuildRequires: wget
21+
BuildRequires: tar
22+
23+
%install
24+
wget https://github.com/SELinuxProject/selinux/releases/download/3.4/libsepol-3.4.tar.gz
25+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
26+
tar -xvf libsepol-3.4.tar.gz
27+
cd libsepol-3.4
28+
make CC=gcc
29+
make install
30+
cd ..
31+
wget https://github.com/SELinuxProject/selinux/releases/download/3.4/libselinux-3.4.tar.gz
32+
tar -xvf libselinux-3.4.tar.gz
33+
cd libselinux-3.4
34+
make CC=gcc
35+
make install
36+
cd ..
37+
wget https://github.com/SELinuxProject/selinux/releases/download/3.4/libsemanage-3.4.tar.gz
38+
tar -xvf libsemanage-3.4.tar.gz
39+
cd libsemanage-3.4
40+
make CC=gcc
41+
make install
42+
cd ..
43+
wget https://github.com/SELinuxProject/selinux/releases/download/3.4/policycoreutils-3.4.tar.gz
44+
tar -xvf policycoreutils-3.4.tar.gz
45+
cd policycoreutils-3.4
46+
make CC=gcc
47+
make install
48+
%files

rpm/SPECS/sles_dependencies.spec

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Name: SLES_Dependencies
2+
Version: %{_version}
3+
License: GPLv2
4+
Release: 1%{?dist}
5+
Summary: SLES Dependencies
6+
7+
%description
8+
The file lists the dependencies required for building the rpmbuild-sles-15
9+
10+
BuildRequires: rpm-build
11+
BuildRequires: rpmlint
12+
BuildRequires: pkg-config
13+
BuildRequires: libsystemd0
14+
BuildRequires: systemd-devel
15+
BuildRequires: selinux-tools
16+
BuildRequires: wget
17+
BuildRequires: cmake
18+
BuildRequires: git
19+
BuildRequires: glibc-devel-static
20+
BuildRequires: libseccomp-devel
21+
BuildRequires: libtool
22+
BuildRequires: libarchive-devel
23+
BuildRequires: btrfsprogs
24+
BuildRequires: libbtrfs-devel
25+
BuildRequires: lsb-release
26+
BuildRequires: gzip
27+
BuildRequires: make
28+
BuildRequires: gcc7
29+
BuildRequires: flex
30+
BuildRequires: libbz2-devel
31+
BuildRequires: libsemanage-devel
32+
BuildRequires: libsepol-devel
33+
BuildRequires: gettext
34+
BuildRequires: bison
35+
BuildRequires: tar

rpm/rhel-7/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@ FROM ${BUILD_IMAGE}
99
ENV GOPROXY=direct
1010
ENV GO111MODULE=off
1111
ENV GOPATH=/go
12-
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
12+
ENV PATH $PATH:/usr/local/bin:/usr/local/go/bin:$GOPATH/bin
1313
ENV AUTO_GOPATH 1
1414
ARG DISTRO
1515
ARG SUITE
1616
ENV DISTRO=${DISTRO}
1717
ENV SUITE=${SUITE}
1818
ENV CC=gcc
1919

20+
# Install Git
21+
RUN yum groupinstall -y "Development Tools"; \
22+
yum install -y gettext-devel openssl-devel perl-devel perl-CPAN zlib-devel curl-devel wget; \
23+
wget https://github.com/git/git/archive/refs/tags/v2.26.2.tar.gz; \
24+
tar -xvzf v2.26.2.tar.gz; \
25+
cd git-2.26.2; \
26+
make configure; \
27+
./configure --prefix=/usr/local; \
28+
make install
29+
2030
# In aarch64 (arm64) images, the altarch repo is specified as repository, but
2131
# failing, so replace the URL.
2232
RUN if [ -f /etc/yum.repos.d/CentOS-Sources.repo ]; then sed -i 's/altarch/centos/g' /etc/yum.repos.d/CentOS-Sources.repo; fi

rpm/rhel-8/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG GO_IMAGE
2+
ARG DISTRO=rhel
3+
ARG SUITE=8
4+
ARG BUILD_IMAGE=dockereng/${DISTRO}:${SUITE}-s390x
5+
6+
FROM ${GO_IMAGE} AS golang
7+
8+
FROM ${BUILD_IMAGE}
9+
ENV GOPROXY=direct
10+
ENV GO111MODULE=off
11+
ENV GOPATH=/go
12+
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
13+
ENV AUTO_GOPATH 1
14+
ENV DOCKER_BUILDTAGS seccomp selinux exclude_graphdriver_btrfs
15+
ENV RUNC_BUILDTAGS seccomp selinux
16+
ARG DISTRO
17+
ARG SUITE
18+
ENV DISTRO=${DISTRO}
19+
ENV SUITE=${SUITE}
20+
ENV CC=gcc
21+
22+
RUN yum install -y rpm-build rpmlint libarchive yum-utils
23+
COPY SPECS /root/rpmbuild/SPECS
24+
25+
# TODO change once we support scan-plugin on other architectures
26+
RUN \
27+
if [ "$(uname -m)" = "x86_64" ]; then \
28+
yum-builddep -y /root/rpmbuild/SPECS/*.spec; \
29+
else \
30+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \
31+
fi
32+
33+
COPY --from=golang /usr/local/go /usr/local/go
34+
WORKDIR /root/rpmbuild
35+
ENTRYPOINT ["/bin/rpmbuild"]

rpm/rhel-9/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG GO_IMAGE
2+
ARG DISTRO=rhel
3+
ARG SUITE=9
4+
ARG BUILD_IMAGE=dockereng/${DISTRO}:${SUITE}-s390x
5+
6+
FROM ${GO_IMAGE} AS golang
7+
8+
FROM ${BUILD_IMAGE}
9+
ENV GOPROXY=direct
10+
ENV GO111MODULE=off
11+
ENV GOPATH=/go
12+
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
13+
ENV AUTO_GOPATH 1
14+
ENV DOCKER_BUILDTAGS seccomp selinux exclude_graphdriver_btrfs
15+
ENV RUNC_BUILDTAGS seccomp selinux
16+
ARG DISTRO
17+
ARG SUITE
18+
ENV DISTRO=${DISTRO}
19+
ENV SUITE=${SUITE}
20+
ENV CC=gcc
21+
22+
RUN yum install -y rpm-build rpmlint libarchive yum-utils
23+
COPY SPECS /root/rpmbuild/SPECS
24+
25+
# TODO change once we support scan-plugin on other architectures
26+
RUN \
27+
if [ "$(uname -m)" = "x86_64" ]; then \
28+
yum-builddep -y /root/rpmbuild/SPECS/*.spec; \
29+
else \
30+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \
31+
fi
32+
33+
COPY --from=golang /usr/local/go /usr/local/go
34+
WORKDIR /root/rpmbuild
35+
ENTRYPOINT ["/bin/rpmbuild"]

rpm/sles-15/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ARG GO_IMAGE
2+
ARG DISTRO=sles
3+
ARG SUITE=15
4+
ARG BUILD_IMAGE=dockereng/${DISTRO}:${SUITE}-s390x
5+
6+
7+
FROM ${GO_IMAGE} AS golang
8+
9+
FROM ${BUILD_IMAGE}
10+
ENV GOPROXY=direct
11+
ENV GO111MODULE=off
12+
ENV GOPATH=/go
13+
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
14+
ENV AUTO_GOPATH 1
15+
ENV DOCKER_BUILDTAGS seccomp selinux
16+
ENV RUNC_BUILDTAGS seccomp selinux
17+
ARG DISTRO
18+
ARG SUITE
19+
ENV DISTRO=${DISTRO}
20+
ENV SUITE=${SUITE}
21+
ENV CC=gcc
22+
USER root
23+
24+
COPY SPECS /usr/src/packages/SPECS
25+
COPY rpmbuild/SOURCES/ /usr/src/packages/SOURCES/
26+
RUN zypper -n install $(rpmspec --parse /usr/src/packages/SPECS/sles_dependencies.spec | grep BuildRequires | cut -d' ' -f2 | xargs)
27+
RUN rpmbuild -bb /usr/src/packages/SPECS/policycoreutils.spec
28+
RUN rpm -i /usr/src/packages/RPMS/s390x/policycoreutils-3.4-1.s390x.rpm \
29+
&& sles_version=$(lsb_release -r | rev | cut -c1) \
30+
&& opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP$sles_version/security:SELinux.repo" \
31+
&& zypper addrepo $opensuse_repo \
32+
&& zypper --gpg-auto-import-keys refresh && zypper install -y selinux-policy selinux-policy-devel device-mapper-devel \
33+
&& mkdir -p /root/rpmbuild/ && cp -r /usr/src/packages/* /root/rpmbuild/
34+
35+
# TODO change once we support scan-plugin on other architectures
36+
RUN \
37+
if [ "$(uname -m)" = "x86" ]; then \
38+
rpmbuild /root/rpmbuild/SPECS/*.spec; \
39+
else \
40+
rpmbuild /usr/src/packages/SPECS/docker-c*.spec; \
41+
fi
42+
43+
COPY --from=golang /usr/local/go /usr/local/go
44+
WORKDIR /root/rpmbuild
45+
ENTRYPOINT ["/usr/bin/rpmbuild"]

0 commit comments

Comments
 (0)