Skip to content

Commit bedfa65

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 Signed-off-by: Prabhav Thali <[email protected]>
1 parent a4bd67e commit bedfa65

File tree

7 files changed

+232
-4
lines changed

7 files changed

+232
-4
lines changed

rpm/Makefile

Lines changed: 29 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 \
@@ -48,6 +48,14 @@ RPMBUILD_FLAGS?=-ba\
4848

4949
# Additional flags may be necessary at some point
5050
RUN_FLAGS=
51+
RUN_SLES?=docker run --rm \
52+
-e PLATFORM \
53+
-v $(CURDIR)/rpmbuild/SOURCES:/usr/src/packages/SOURCES:ro \
54+
-v $(CURDIR)/rpmbuild/$@/RPMS:/usr/src/packages/RPMS \
55+
-v $(CURDIR)/rpmbuild/$@/SRPMS:/usr/src/packages/SRPMS \
56+
$(RUN_FLAGS) \
57+
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
58+
5159
RUN?=docker run --rm \
5260
-e PLATFORM \
5361
-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES:ro \
@@ -59,12 +67,16 @@ RUN?=docker run --rm \
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

77+
6778
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
79+
6880
BUNDLES := $(patsubst %,rpmbuild/bundles-ce-%-$(DPKG_ARCH).tar.gz,$(DISTROS))
6981

7082
.PHONY: help
@@ -78,7 +90,7 @@ clean: ## remove build artifacts
7890
-docker builder prune -f --filter until=24h
7991

8092
.PHONY: rpm
81-
rpm: fedora centos ## build all rpm packages
93+
rpm: fedora centos rhel sles ## build all rpm packages
8294

8395
.PHONY: fedora
8496
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -89,9 +101,15 @@ centos-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
89101
.PHONY: centos
90102
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
91103

104+
.PHONY: rhel-8
105+
rhel-8: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
106+
92107
.PHONY: rhel
93108
rhel: $(RHEL_RELEASES) ## build all rhel rpm packages
94109

110+
.PHONY: sles
111+
sles: $(SLES_RELEASES) ## build all sles rpm packages
112+
95113
.PHONY: $(DISTROS)
96114
$(DISTROS): sources
97115
@echo "== Building packages for $@ =="
@@ -100,6 +118,14 @@ $(DISTROS): sources
100118
$(RUN)
101119
$(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@"
102120

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

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)