Skip to content

Commit 7e1d909

Browse files
committed
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]>
1 parent 8768000 commit 7e1d909

File tree

6 files changed

+180
-5
lines changed

6 files changed

+180
-5
lines changed

rpm/Makefile

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

1212
ifdef BUILD_IMAGE
13-
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
13+
BUILD_IMAGE_FLAG=--build-arg BUILD_IMAGE=$(BUILD_IMAGE)
1414
endif
1515
BUILD?=DOCKER_BUILDKIT=1 \
1616
docker build \
@@ -50,15 +50,26 @@ RUN?=docker run --rm \
5050
$(RUN_FLAGS) \
5151
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
5252

53+
RUN_SLES?=docker run --rm \
54+
-e PLATFORM \
55+
-v $(CURDIR)/rpmbuild/SOURCES:/usr/src/packages/SOURCES:ro \
56+
-v $(CURDIR)/rpmbuild/$@/RPMS:/usr/src/packages/RPMS \
57+
-v $(CURDIR)/rpmbuild/$@/SRPMS:/usr/src/packages/SRPMS \
58+
$(RUN_FLAGS) \
59+
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
60+
5361
FEDORA_RELEASES ?= fedora-34 fedora-33
5462
CENTOS_RELEASES ?= centos-7 centos-8
5563
ifeq ($(ARCH),s390x)
56-
RHEL_RELEASES ?= rhel-7
64+
RHEL_RELEASES ?= rhel-7 rhel-8
65+
SLES_RELEASES ?= sles-15
5766
else
5867
RHEL_RELEASES ?=
68+
SLES_RELEASES ?=
5969
endif
6070

61-
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
71+
72+
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
6273
BUNDLES := $(patsubst %,rpmbuild/bundles-ce-%-$(DPKG_ARCH).tar.gz,$(DISTROS))
6374

6475
.PHONY: help
@@ -72,7 +83,7 @@ clean: ## remove build artifacts
7283
-docker builder prune -f --filter until=24h
7384

7485
.PHONY: rpm
75-
rpm: fedora centos ## build all rpm packages
86+
rpm: fedora centos rhel sles ## build all rpm packages
7687

7788
.PHONY: fedora
7889
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -83,9 +94,15 @@ centos-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
8394
.PHONY: centos
8495
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
8596

97+
.PHONY: rhel-8
98+
rhel-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
99+
86100
.PHONY: rhel
87101
rhel: $(RHEL_RELEASES) ## build all rhel rpm packages
88102

103+
.PHONY: sles
104+
sles: $(SLES_RELEASES) ## build all sles rpm packages
105+
89106
.PHONY: $(DISTROS)
90107
$(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz
91108
@echo "== Building packages for $@ =="
@@ -94,6 +111,14 @@ $(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCE
94111
$(RUN)
95112
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
96113

114+
.PHONY: $(SLES_RELEASES)
115+
$(SLES_RELEASES): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz
116+
@echo "== Building packages for $@ =="
117+
mkdir -p "rpmbuild/$@"
118+
$(BUILD)
119+
$(RUN_SLES)
120+
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
121+
97122
rpmbuild/SOURCES/engine.tgz:
98123
mkdir -p $(@D)
99124
docker run --rm -w /v \

rpm/SPECS/checkpolicy.spec

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Name: checkpolicy
2+
Version: 3.2.61.1
3+
Release: 1%{?dist}
4+
Group: System Environment/Base
5+
Summary: policycoreutils package
6+
License: GPLv2
7+
%description
8+
9+
%configure
10+
11+
%install
12+
wget https://github.com/SELinuxProject/selinux/releases/download/3.2/libsepol-3.2.tar.gz
13+
zypper install -y wget tar gcc7 make gzip bison libsepol-devel flex
14+
tar -xvf libsepol-3.2.tar.gz
15+
cd libsepol-3.2
16+
make CC=gcc
17+
cd ..
18+
wget https://github.com/SELinuxProject/selinux/releases/download/3.2/checkpolicy-3.2.tar.gz
19+
tar -xvf checkpolicy-3.2.tar.gz
20+
cd checkpolicy-3.2
21+
make CC=gcc
22+
%files

rpm/SPECS/docker-ce.spec

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,38 @@ Packager: Docker <[email protected]>
1818
Requires: /usr/sbin/groupadd
1919
Requires: docker-ce-cli
2020
Requires: docker-ce-rootless-extras
21+
%if 0%{?suse_version}
22+
Requires: container-selinux
23+
Requires: libseccomp2
24+
Requires: libcgroup-devel
25+
%else
2126
Requires: container-selinux >= 2:2.74
2227
Requires: libseccomp >= 2.3
28+
Requires: libcgroup
29+
%endif
2330
Requires: systemd
2431
Requires: iptables
25-
Requires: libcgroup
2632
Requires: containerd.io >= 1.4.1
2733
Requires: tar
2834
Requires: xz
2935

3036
BuildRequires: bash
37+
%if 0%{?suse_version}
38+
BuildRequires: btrfsprogs
39+
%else
3140
%{?_with_btrfs:BuildRequires: btrfs-progs-devel}
41+
%endif
3242
BuildRequires: ca-certificates
3343
BuildRequires: cmake
3444
BuildRequires: device-mapper-devel
3545
BuildRequires: gcc
3646
BuildRequires: git
3747
BuildRequires: glibc-static
48+
%if 0%{?suse_version}
49+
BuildRequires: libarchive13
50+
%else
3851
BuildRequires: libarchive
52+
%endif
3953
BuildRequires: libseccomp-devel
4054
BuildRequires: libselinux-devel
4155
BuildRequires: libtool

rpm/SPECS/policycoreutils.spec

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Name: policycoreutils
2+
Version: 3.2
3+
Release: 1%{?dist}
4+
Group: System Environment/Base
5+
Summary: policycoreutils package
6+
License: GPLv2
7+
%description
8+
9+
%configure
10+
11+
%install
12+
wget https://github.com/SELinuxProject/selinux/releases/download/3.2/libsepol-3.2.tar.gz
13+
zypper install -y gzip make gcc7 flex libbz2-devel libsemanage-devel gettext bison wget tar
14+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
15+
tar -xvf libsepol-3.2.tar.gz
16+
cd libsepol-3.2
17+
make CC=gcc
18+
make install
19+
cd ..
20+
wget https://github.com/SELinuxProject/selinux/releases/download/3.2/libselinux-3.2.tar.gz
21+
tar -xvf libselinux-3.2.tar.gz
22+
cd libselinux-3.2
23+
make CC=gcc
24+
make install
25+
cd ..
26+
wget https://github.com/SELinuxProject/selinux/releases/download/3.2/policycoreutils-3.2.tar.gz
27+
tar -xvf policycoreutils-3.2.tar.gz
28+
cd policycoreutils-3.2
29+
make CC=gcc
30+
make install
31+
%files

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/sles-15/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
25+
RUN zypper install -y rpm-build rpmlint pkg-config libsystemd0 systemd-devel selinux-tools wget cmake device-mapper-devel git glibc-devel-static libseccomp-devel libtool libarchive-devel btrfsprogs libbtrfs-devel lsb-release
26+
27+
COPY SPECS /usr/src/packages/SPECS
28+
COPY rpmbuild/SOURCES/ /usr/src/packages/SOURCES/
29+
RUN rpmbuild -bb /usr/src/packages/SPECS/policycoreutils.spec
30+
RUN rpmbuild -bb /usr/src/packages/SPECS/checkpolicy.spec
31+
RUN rpm -i /usr/src/packages/RPMS/s390x/policycoreutils-3.2-1.s390x.rpm && rpm -i /usr/src/packages/RPMS/s390x/checkpolicy-3.2.61.1-1.s390x.rpm \
32+
&& sles_version=$(lsb_release -r | rev | cut -c1) \
33+
&& opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP$sles_version/security:SELinux.repo" \
34+
&& zypper addrepo $opensuse_repo \
35+
&& zypper --gpg-auto-import-keys refresh && zypper install -y selinux-policy selinux-policy-devel \
36+
&& mkdir -p /root/rpmbuild/ && cp -r /usr/src/packages/* /root/rpmbuild/
37+
38+
# TODO change once we support scan-plugin on other architectures
39+
RUN \
40+
if [ "$(uname -m)" = "x86" ]; then \
41+
rpmbuild /root/rpmbuild/SPECS/*.spec; \
42+
else \
43+
rpmbuild /usr/src/packages/SPECS/docker-c*.spec; \
44+
fi
45+
46+
COPY --from=golang /usr/local/go /usr/local/go
47+
WORKDIR /root/rpmbuild
48+
ENTRYPOINT ["/usr/bin/rpmbuild"]

0 commit comments

Comments
 (0)