Skip to content

Commit 95034d5

Browse files
nirmannarangprabhav-thali
authored andcommitted
Adds RHEL 8, RHEL 9 and SLES 15 support 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.4 Refactor SLES_RELEASE Add RHEL 9 Dockerfile Signed-off-by: Prabhav Thali <[email protected]>
1 parent 800eaea commit 95034d5

File tree

7 files changed

+233
-5
lines changed

7 files changed

+233
-5
lines changed

rpm/Makefile

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SCAN_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/scan-cl
1313
BUILDX_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/buildx) && git rev-parse --short HEAD)
1414

1515
ifdef BUILD_IMAGE
16-
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
16+
BUILD_IMAGE_FLAG=--build-arg BUILD_IMAGE=$(BUILD_IMAGE)
1717
endif
1818
BUILD?=DOCKER_BUILDKIT=1 \
1919
docker build \
@@ -58,12 +58,22 @@ RUN?=docker run --rm \
5858
$(RUN_FLAGS) \
5959
rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
6060

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

6979
DISTROS := $(FEDORA_RELEASES) $(CENTOS_RELEASES) $(RHEL_RELEASES)
@@ -80,7 +90,7 @@ clean: ## remove build artifacts
8090
-docker builder prune -f --filter until=24h
8191

8292
.PHONY: rpm
83-
rpm: fedora centos ## build all rpm packages
93+
rpm: fedora centos rhel sles ## build all rpm packages
8494

8595
.PHONY: fedora
8696
fedora: $(FEDORA_RELEASES) ## build all fedora rpm packages
@@ -91,9 +101,15 @@ centos-8 centos-9: RPMBUILD_EXTRA_FLAGS=--define '_without_btrfs 1'
91101
.PHONY: centos
92102
centos: $(CENTOS_RELEASES) ## build all centos rpm packages
93103

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

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

121+
.PHONY: $(SLES_RELEASES)
122+
$(SLES_RELEASES): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.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+
105129
.PHONY: sources
106130
sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz
107131

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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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: gettext
32+
BuildRequires: bison
33+
BuildRequires: tar

rpm/rhel-8/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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=https://proxy.golang.org|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 exclude_graphdriver_btrfs
15+
ARG DISTRO
16+
ARG SUITE
17+
ENV DISTRO=${DISTRO}
18+
ENV SUITE=${SUITE}
19+
20+
RUN yum install -y rpm-build rpmlint libarchive yum-utils
21+
COPY SPECS /root/rpmbuild/SPECS
22+
23+
# TODO change once we support scan-plugin on other architectures
24+
RUN \
25+
if [ "$(uname -m)" = "x86_64" ]; then \
26+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \
27+
else \
28+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \
29+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \
30+
fi
31+
32+
COPY --from=golang /usr/local/go /usr/local/go
33+
WORKDIR /root/rpmbuild
34+
ENTRYPOINT ["/bin/rpmbuild"]

rpm/rhel-9/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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=https://proxy.golang.org|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 exclude_graphdriver_btrfs
15+
ARG DISTRO
16+
ARG SUITE
17+
ENV DISTRO=${DISTRO}
18+
ENV SUITE=${SUITE}
19+
20+
RUN yum install -y rpm-build rpmlint libarchive yum-utils
21+
COPY SPECS /root/rpmbuild/SPECS
22+
23+
# TODO change once we support scan-plugin on other architectures
24+
RUN \
25+
if [ "$(uname -m)" = "x86_64" ]; then \
26+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \
27+
else \
28+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \
29+
yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \
30+
fi
31+
32+
COPY --from=golang /usr/local/go /usr/local/go
33+
WORKDIR /root/rpmbuild
34+
ENTRYPOINT ["/bin/rpmbuild"]

rpm/sles-15/Dockerfile

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

0 commit comments

Comments
 (0)