From ca3f73206d3c29b6a63a4c263fae228d12705e38be885e23f3cca1852f15802f Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <asarai@suse.com>
Date: Fri, 11 Aug 2017 12:09:59 +0000
Subject: [PATCH] - Use -buildmode=pie for tests and binary build. bsc#1048046
 bsc#1051429

This also includes some various improvements to the packaging of runc,
containerd and docker-runc.

OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=197
---
 docker.changes | 11 ++++++++---
 docker.spec    | 12 +++++++-----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/docker.changes b/docker.changes
index 4321e44..27eb52d 100644
--- a/docker.changes
+++ b/docker.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Wed Aug  2 13:37:16 UTC 2017 - asarai@suse.com
+
+- Use -buildmode=pie for tests and binary build. bsc#1048046 bsc#1051429
+
 -------------------------------------------------------------------
 Wed Jul 19 18:12:26 UTC 2017 - jmassaguerpla@suse.com
 
@@ -15,12 +20,12 @@ Wed Jul 19 17:17:04 UTC 2017 - jmassaguerpla@suse.com
 Tue Jul 11 10:50:12 UTC 2017 - jmassaguerpla@suse.com
 
 - add SuSEfirewall2.service to the After clause in docker.service
-  in order to fix bsc#1046024 
+  in order to fix bsc#1046024
 
 -------------------------------------------------------------------
 Fri Jul  7 14:53:59 UTC 2017 - thipp@suse.de
 
-- fix path to docker-runc in systemd service file 
+- fix path to docker-runc in systemd service file
 
 -------------------------------------------------------------------
 Thu Jul  6 14:18:29 UTC 2017 - thipp@suse.de
@@ -38,7 +43,7 @@ unit.
 -------------------------------------------------------------------
 Tue May 30 11:29:45 UTC 2017 - jmassaguerpla@suse.com
 
-- Fix bsc#1032287: missing docker systemd configuration 
+- Fix bsc#1032287: missing docker systemd configuration
 
 -------------------------------------------------------------------
 Mon May 29 11:08:44 UTC 2017 - asarai@suse.com
diff --git a/docker.spec b/docker.spec
index 1cea9e5..1fd56b7 100644
--- a/docker.spec
+++ b/docker.spec
@@ -200,6 +200,8 @@ export DOCKER_GITCOMMIT=%{git_version}
 # Until boo#1038493 is fixed properly we need to do this hack to get the
 # compiled-into-the-binary GOROOT.
 export GOROOT="$(GOROOT= go env GOROOT)"
+# Make sure we always build PIC code. bsc#1048046
+export BUILDFLAGS="-buildmode=pie"
 EOF
 ) > docker_build_env
 . ./docker_build_env
@@ -209,6 +211,7 @@ man/md2man-all.sh
 
 # build the tests binary
 GOPATH=$(pwd)/vendor:$(pwd)/.gopath/ go test \
+	-buildmode=pie \
     -tags "$DOCKER_BUILDTAGS daemon autogen" \
     -c github.com/docker/docker/integration-cli -o tests.main
 
@@ -265,14 +268,13 @@ PKG_LIST=$(go list -e \
 		| grep -v 'github.com/docker/docker/cmd/dockerd$' \
 		| grep -v 'github.com/docker/docker/builder/dockerfile/parser$' \
 		| grep -v 'github.com/docker/docker/man$' \
-%if 0%{?with_libseccomp}
-		| grep -v 'github.com/docker/docker/pkg/integration$')
-%else
 		| grep -v 'github.com/docker/docker/pkg/integration$' \
-		| grep -v 'github.com/docker/docker/profiles/seccomp$')
+%if ! 0%{?with_libseccomp}
+		| grep -v 'github.com/docker/docker/profiles/seccomp$' \
 %endif
+		)
 
-go test -cover -ldflags -w -tags "$DOCKER_BUILDTAGS" -a -test.timeout=10m $PKG_LIST
+go test -buildmode=pie -cover -ldflags -w -tags "$DOCKER_BUILDTAGS" -a -test.timeout=10m $PKG_LIST
 
 %install
 install -d %{buildroot}%{go_contribdir}