Accepting request 517264 from home:cyphar:containers:bsc1053532

- Use the upstream Makefile, to ensure that we always include the version and
  commit information in runc. This was confusing users (and Docker).
  bsc#1053532
- Add a backported patch to fix a Makefile bug. This also includes some other
  changes to make the docker-runc.spec mirror the newer runc.

OBS-URL: https://build.opensuse.org/request/show/517264
OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/runc?expand=0&rev=55
This commit is contained in:
Aleksa Sarai 2017-08-16 19:16:32 +00:00 committed by Git OBS Bridge
parent f50f0c9beb
commit 9676cebf63
3 changed files with 129 additions and 9 deletions

View File

@ -0,0 +1,101 @@
From 6581d0f488b3bfa00760cc71c5f1fccfee302b0d Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <asarai@suse.de>
Date: Mon, 14 Aug 2017 00:10:28 +1000
Subject: [PATCH] makefile: drop usage of --install
The "go build -i" invocation may slightly help with incremental
recompilation, but it will cause builds to fail if $GOROOT is not
writeable by the current user. While this does appear to work sometimes,
it's a concern for external build systems where "-i" causes build errors
for no real gain.
Given the size of the runc project, --install is not really giving us
much anyway.
SUSE-Bug: https://bugzilla.opensuse.org/show_bug.cgi?id=1053532
SUSE-Backport: https://github.com/opencontainers/runc/pull/1555
Signed-off-by: Aleksa Sarai <asarai@suse.de>
---
Makefile | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 6781ac74e8a0..dc13d2e5296e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
localtest localunittest localintegration \
test unittest integration
+GO := go
+
SOURCES := $(shell find . 2>&1 | grep -E '.*\.(c|h|go)$$')
PREFIX := $(DESTDIR)/usr/local
BINDIR := $(PREFIX)/sbin
@@ -27,18 +29,18 @@ SHELL := $(shell command -v bash 2>/dev/null)
.DEFAULT: runc
runc: $(SOURCES)
- go build -i $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
+ $(GO) build $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
all: runc recvtty
recvtty: contrib/cmd/recvtty/recvtty
contrib/cmd/recvtty/recvtty: $(SOURCES)
- go build -i $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
+ $(GO) build $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
static: $(SOURCES)
- CGO_ENABLED=1 go build -i $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o runc .
- CGO_ENABLED=1 go build -i $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
+ CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o runc .
+ CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
release:
@flag_list=(seccomp selinux apparmor static); \
@@ -62,15 +64,15 @@ release:
CGO_ENABLED=1; \
}; \
echo "Building target: $$output"; \
- go build -i $(EXTRA_FLAGS) -ldflags "$$ldflags $(EXTRA_LDFLAGS)" -tags "$$tags" -o "$$output" .; \
+ $(GO) build $(EXTRA_FLAGS) -ldflags "$$ldflags $(EXTRA_LDFLAGS)" -tags "$$tags" -o "$$output" .; \
done
dbuild: runcimage
docker run --rm -v $(CURDIR):/go/src/$(PROJECT) --privileged $(RUNC_IMAGE) make clean all
lint:
- go vet $(allpackages)
- go fmt $(allpackages)
+ $(GO) vet $(allpackages)
+ $(GO) fmt $(allpackages)
man:
man/md2man-all.sh
@@ -88,7 +90,7 @@ unittest: runcimage
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localunittest
localunittest: all
- go test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v $(allpackages)
+ $(GO) test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v $(allpackages)
integration: runcimage
docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localintegration
@@ -133,10 +135,10 @@ clean:
validate:
script/validate-gofmt
- go vet $(allpackages)
+ $(GO) vet $(allpackages)
ci: validate localtest
# memoize allpackages, so that it's executed only once and only if used
-_allpackages = $(shell go list ./... | grep -v vendor)
+_allpackages = $(shell $(GO) list ./... | grep -v vendor)
allpackages = $(if $(__allpackages),,$(eval __allpackages := $$(_allpackages)))$(__allpackages)
--
2.14.0

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Sun Aug 13 14:25:32 UTC 2017 - asarai@suse.com
- Use the upstream Makefile, to ensure that we always include the version
information in runc. This was confusing users (and Docker). bsc#1053532
- Add a backported patch to fix a Makefile bug.
https://github.com/opencontainers/runc/pull/1555
+ bsc1053532-0001-makefile-drop-usage-of-install.patch
-------------------------------------------------------------------
Thu Aug 10 17:14:02 UTC 2017 - asarai@suse.com

View File

@ -14,8 +14,13 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# nodebuginfo
# We don't include a git_version in the "upstream" runc package, because we
# only package released versions (unlike docker-runc).
%define git_version %{nil}
%define go_tool go
%define _version 1.0.0rc4
%define project github.com/opencontainers/runc
@ -50,6 +55,8 @@ BuildRequires: golang(API) = 1.7
BuildRequires: libseccomp-devel
%endif
BuildRequires: libselinux-devel
# SUSE-FIX-UPSTREAM: Backport of https://github.com/opencontainers/runc/pull/1555. bsc#1053532
Patch100: bsc1053532-0001-makefile-drop-usage-of-install.patch
Recommends: criu
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -78,26 +85,28 @@ Test package for runc. It contains the source code and the tests.
%prep
%setup -q -n %{name}-v%{_version}
# bsc#1053532
%patch100 -p1
%build
# Do not use symlinks. If you want to run the unit tests for this package at
# some point during the build and you need to directly use go list directly it
# will get confused by symlinks.
export GOPATH=${HOME}/go:${HOME}/go/src/%project/Godeps/_workspace
export GOPATH=${HOME}/go
mkdir -pv $HOME/go/src/%project
rm -rf $HOME/go/src/%project/*
cp -av * $HOME/go/src/%project
# Build all features.
export BUILDTAGS="apparmor selinux"
export BUILDFLAGS="-gccgoflags=-Wl,--add-needed -Wl,--no-as-needed -static-libgo -ldl -lselinux -lapparmor"
# Additionally enable seccomp.
%if 0%{?with_libseccomp}
export BUILDTAGS="$BUILDTAGS seccomp"
export BUILDFLAGS="$BUILDFLAGS -lseccomp"
export EXTRA_BUILDTAGS+="seccomp"
export EXTRA_GCCFLAGS+="-lseccomp"
%endif
# Build all features.
export BUILDTAGS="apparmor selinux $EXTRA_BUILDTAGS"
export BUILDFLAGS="-buildmode=pie -gccgoflags='-Wl,--add-needed -Wl,--no-as-needed -static-libgo -ldl -lselinux -lapparmor $EXTRA_GCCFLAGS'"
(cat <<EOF
export GOPATH="$GOPATH"
export BUILDTAGS="$BUILDTAGS"
@ -107,7 +116,8 @@ EOF
source ./.runc_build_env
# Build runc.
%go_tool build -buildmode=pie "$BUILDFLAGS" -tags "$BUILDTAGS" -x -o %{name}-%{version} %{project}
make -C "$HOME/go/src/%project" EXTRA_FLAGS="-x $BUILDFLAGS" BUILDTAGS="$BUILDTAGS" COMMIT_NO="%{git_version}" runc
mv "$HOME/go/src/%project/runc" %{name}-%{version}
# Build man pages, this can only be done on arches where we can build go-md2man.
man/md2man-all.sh
@ -128,7 +138,7 @@ PKG_LIST=$(go list ./... \
| grep -v 'github.com/seccomp/libseccomp-golang$' \
%endif
)
%go_tool test -buildmode=pie "$BUILDFLAGS" -tags "$BUILDTAGS" -timeout 3m -v $PKG_LIST
%go_tool test -buildmode=pie -tags "$BUILDTAGS" -timeout 3m -v $PKG_LIST
%install
source ./.runc_build_env