Skip to content

Commit 6b252b1

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 6b252b1

File tree

7 files changed

+233
-5
lines changed

7 files changed

+233
-5
lines changed

rpm/Makefile

Lines changed: 30 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 \
@@ -42,6 +42,14 @@ RPMBUILD_FLAGS?=-ba\
4242

4343
# Additional flags may be necessary at some point
4444
RUN_FLAGS=
45+
RUN_SLES?=docker run --rm \
46+
-e PLATFORM \
47+
-v $(CURDIR)/rpmbuild/SOURCES:/usr/src/packages/SOURCES:ro \
48+
-v $(CURDIR)/rpmbuild/$@/RPMS:/usr/src/packages/RPMS \
49+
-v $(CURDIR)/rpmbuild/$@/SRPMS:/usr/src/packages/SRPMS \
50+
$(RUN_FLAGS) \
51+
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
52+
4553
RUN?=docker run --rm \
4654
-e PLATFORM \
4755
-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES:ro \
@@ -50,15 +58,19 @@ RUN?=docker run --rm \
5058
$(RUN_FLAGS) \
5159
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
5260

53-
FEDORA_RELEASES ?= fedora-34 fedora-33
61+
FEDORA_RELEASES ?= fedora-35 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

71+
6172
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
73+
6274
BUNDLES := $(patsubst %,rpmbuild/bundles-ce-%-$(DPKG_ARCH).tar.gz,$(DISTROS))
6375

6476
.PHONY: help
@@ -72,7 +84,7 @@ clean: ## remove build artifacts
7284
-docker builder prune -f --filter until=24h
7385

7486
.PHONY: rpm
75-
rpm: fedora centos ## build all rpm packages
87+
rpm: fedora centos rhel sles ## build all rpm packages
7688

7789
.PHONY: fedora
7890
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -83,9 +95,15 @@ centos-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
8395
.PHONY: centos
8496
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
8597

98+
.PHONY: rhel-8
99+
rhel-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
100+
86101
.PHONY: rhel
87102
rhel: $(RHEL_RELEASES) ## build all rhel rpm packages
88103

104+
.PHONY: sles
105+
sles: $(SLES_RELEASES) ## build all sles rpm packages
106+
89107
.PHONY: $(DISTROS)
90108
$(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz
91109
@echo "== Building packages for $@ =="
@@ -94,6 +112,14 @@ $(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCE
94112
$(RUN)
95113
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
96114

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

rpm/SPECS/checkpolicy.spec

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

rpm/SPECS/sles_dependencies.spec

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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: device-mapper-devel
19+
BuildRequires: git
20+
BuildRequires: glibc-devel-static
21+
BuildRequires: libseccomp-devel
22+
BuildRequires: libtool
23+
BuildRequires: libarchive-devel
24+
BuildRequires: btrfsprogs
25+
BuildRequires: libbtrfs-devel
26+
BuildRequires: lsb-release
27+
BuildRequires: gzip
28+
BuildRequires: make
29+
BuildRequires: gcc7
30+
BuildRequires: flex
31+
BuildRequires: libbz2-devel
32+
BuildRequires: libsemanage-devel
33+
BuildRequires: libsepol-devel
34+
BuildRequires: gettext
35+
BuildRequires: bison
36+
BuildRequires: tar

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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 rpmbuild -bb /usr/src/packages/SPECS/checkpolicy.spec
29+
RUN rpm -i /usr/src/packages/RPMS/s390x/policycoreutils-3.3-1.s390x.rpm && rpm -i /usr/src/packages/RPMS/s390x/checkpolicy-3.3.62.2-1.s390x.rpm \
30+
&& sles_version=$(lsb_release -r | rev | cut -c1) \
31+
&& opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP$sles_version/security:SELinux.repo" \
32+
&& zypper addrepo $opensuse_repo \
33+
&& zypper --gpg-auto-import-keys refresh && zypper install -y selinux-policy selinux-policy-devel \
34+
&& mkdir -p /root/rpmbuild/ && cp -r /usr/src/packages/* /root/rpmbuild/
35+
36+
# TODO change once we support scan-plugin on other architectures
37+
RUN \
38+
if [ "$(uname -m)" = "x86" ]; then \
39+
rpmbuild /root/rpmbuild/SPECS/*.spec; \
40+
else \
41+
rpmbuild /usr/src/packages/SPECS/docker-c*.spec; \
42+
fi
43+
44+
COPY --from=golang /usr/local/go /usr/local/go
45+
WORKDIR /root/rpmbuild
46+
ENTRYPOINT ["/usr/bin/rpmbuild"]

0 commit comments

Comments
 (0)