From c80d82a98dd53db46ac1f35554f0107fb7d858df Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Tue, 6 Dec 2016 14:14:01 -0800 Subject: [PATCH 1/2] change dep for docker-selinux in centos-7+ Use the policy files provided by CentOS for docker by depending on docker-selinux. Signed-off-by: Andrew Hsu --- hack/make/.build-rpm/docker-engine.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hack/make/.build-rpm/docker-engine.spec b/hack/make/.build-rpm/docker-engine.spec index 88836f4ca9..9dbdc9105b 100644 --- a/hack/make/.build-rpm/docker-engine.spec +++ b/hack/make/.build-rpm/docker-engine.spec @@ -86,7 +86,11 @@ Requires: device-mapper >= 1.02.90-2 # RE: rhbz#1195804 - ensure min NVR for selinux-policy %if 0%{?with_selinux} Requires: selinux-policy >= %{selinux_policyver} +%if 0%{?centos} >= 7 +Requires(pre): docker-selinux +%else Requires(pre): %{name}-selinux >= %{version}-%{release} +%endif # centos 7+ %endif # with_selinux # conflicting packages From f9bc32067d42d6da025b81d81907fde85442f34d Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Sun, 4 Dec 2016 14:22:19 -0800 Subject: [PATCH 2/2] only build selinux rpm if we have policy dir Signed-off-by: Andrew Hsu --- .../docker-engine-selinux/LICENSE | 0 .../docker-engine-selinux/Makefile | 0 .../docker-engine-selinux/docker.fc | 0 .../docker-engine-selinux/docker.if | 0 .../docker-engine-selinux/docker.te | 0 .../docker-engine-selinux/docker_selinux.8.gz | Bin hack/make/build-rpm | 14 +++++++------- 7 files changed, 7 insertions(+), 7 deletions(-) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/LICENSE (100%) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/Makefile (100%) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/docker.fc (100%) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/docker.if (100%) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/docker.te (100%) rename contrib/{selinux => selinux-fedora-23}/docker-engine-selinux/docker_selinux.8.gz (100%) diff --git a/contrib/selinux/docker-engine-selinux/LICENSE b/contrib/selinux-fedora-23/docker-engine-selinux/LICENSE similarity index 100% rename from contrib/selinux/docker-engine-selinux/LICENSE rename to contrib/selinux-fedora-23/docker-engine-selinux/LICENSE diff --git a/contrib/selinux/docker-engine-selinux/Makefile b/contrib/selinux-fedora-23/docker-engine-selinux/Makefile similarity index 100% rename from contrib/selinux/docker-engine-selinux/Makefile rename to contrib/selinux-fedora-23/docker-engine-selinux/Makefile diff --git a/contrib/selinux/docker-engine-selinux/docker.fc b/contrib/selinux-fedora-23/docker-engine-selinux/docker.fc similarity index 100% rename from contrib/selinux/docker-engine-selinux/docker.fc rename to contrib/selinux-fedora-23/docker-engine-selinux/docker.fc diff --git a/contrib/selinux/docker-engine-selinux/docker.if b/contrib/selinux-fedora-23/docker-engine-selinux/docker.if similarity index 100% rename from contrib/selinux/docker-engine-selinux/docker.if rename to contrib/selinux-fedora-23/docker-engine-selinux/docker.if diff --git a/contrib/selinux/docker-engine-selinux/docker.te b/contrib/selinux-fedora-23/docker-engine-selinux/docker.te similarity index 100% rename from contrib/selinux/docker-engine-selinux/docker.te rename to contrib/selinux-fedora-23/docker-engine-selinux/docker.te diff --git a/contrib/selinux/docker-engine-selinux/docker_selinux.8.gz b/contrib/selinux-fedora-23/docker-engine-selinux/docker_selinux.8.gz similarity index 100% rename from contrib/selinux/docker-engine-selinux/docker_selinux.8.gz rename to contrib/selinux-fedora-23/docker-engine-selinux/docker_selinux.8.gz diff --git a/hack/make/build-rpm b/hack/make/build-rpm index 18ff488587..69e20cb8fb 100644 --- a/hack/make/build-rpm +++ b/hack/make/build-rpm @@ -132,13 +132,12 @@ set -e --define '_experimental ${DOCKER_EXPERIMENTAL:-0}' \ ${rpmName}.spec EOF - # selinux policy referencing systemd things won't work on non-systemd versions - # of centos or rhel, which we don't support anyways - if [ "${suite%.*}" -gt 6 ] && [[ "$version" != opensuse* ]]; then - selinuxDir="selinux" - if [ -d "./contrib/selinux-$version" ]; then - selinuxDir="selinux-${version}" - fi + + # by default do not create selinux rpm + # if there exists a selinux policy dir specifically for distro version + # then build a selinux rpm with the policy in the policy dir + if [ -d "./contrib/selinux-$version" ]; then + selinuxDir="selinux-${version}" cat >> "$DEST/$version/Dockerfile.build" <<-EOF RUN tar -cz -C /usr/src/${rpmName}/contrib/${selinuxDir} -f /root/rpmbuild/SOURCES/${rpmName}-selinux.tar.gz ${rpmName}-selinux RUN rpmbuild -ba \ @@ -149,6 +148,7 @@ set -e ${rpmName}-selinux.spec EOF fi + tempImage="docker-temp/build-rpm:$version" ( set -x && docker build -t "$tempImage" -f $DEST/$version/Dockerfile.build . ) docker run --rm "$tempImage" bash -c 'cd /root/rpmbuild && tar -c *RPMS' | tar -xvC "$DEST/$version"