Skip to content

Commit b3e6320

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]>
1 parent a4bd67e commit b3e6320

File tree

8 files changed

+241
-5
lines changed

8 files changed

+241
-5
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 \
@@ -56,12 +56,22 @@ RUN?=docker run --rm \
5656
$(RUN_FLAGS) \
5757
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
5858

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

6777
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
@@ -78,7 +88,7 @@ clean: ## remove build artifacts
7888
-docker builder prune -f --filter until=24h
7989

8090
.PHONY: rpm
81-
rpm: fedora centos ## build all rpm packages
91+
rpm: fedora centos rhel sles ## build all rpm packages
8292

8393
.PHONY: fedora
8494
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -89,9 +99,15 @@ centos-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
8999
.PHONY: centos
90100
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
91101

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

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

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

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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
ENV DOCKER_BUILDTAGS seccomp selinux
1515
ENV RUNC_BUILDTAGS seccomp selinux
@@ -19,6 +19,16 @@ ENV DISTRO=${DISTRO}
1919
ENV SUITE=${SUITE}
2020
ENV CC=gcc
2121

22+
# Install Git
23+
RUN yum groupinstall -y "Development Tools"; \
24+
yum install -y gettext-devel openssl-devel perl-devel perl-CPAN zlib-devel curl-devel wget; \
25+
wget https://github.com/git/git/archive/refs/tags/v2.35.2.tar.gz; \
26+
tar -xvzf v2.35.2.tar.gz; \
27+
cd git-2.35.2; \
28+
make configure; \
29+
./configure --prefix=/usr/local; \
30+
make install
31+
2232
# In aarch64 (arm64) images, the altarch repo is specified as repository, but
2333
# failing, so replace the URL.
2434
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/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)