runc: add PACKAGECONFIG to allow building as static or not

Add a new PACKAGECONFIG, static, which when enabled will build
runc as static. Default to enable it.

We need this because we should allow users to build runc as not
static so that when docker's cgroup driver is set to systemd,
we don't get error.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Chen Qi 2019-08-07 09:14:44 +08:00 committed by Bruce Ashfield
parent 7de3818804
commit 0ca391c1c2
5 changed files with 45 additions and 25 deletions

View File

@ -0,0 +1,35 @@
From d2c47a973f354ffd505bb4e809c59e57b543726d Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Tue, 6 Aug 2019 19:01:45 +0800
Subject: [PATCH] Makefile: respect GOBUILDFLAGS for runc and remove recvtty
from static
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 0f26a1c8..a0c6b40b 100644
--- a/src/import/Makefile
+++ b/src/import/Makefile
@@ -30,7 +30,7 @@ SHELL := $(shell command -v bash 2>/dev/null)
.DEFAULT: runc
runc: $(SOURCES)
- $(GO) build -buildmode=pie $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
+ $(GO) build $(GOBUILDFLAGS) $(EXTRA_FLAGS) -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -tags "$(BUILDTAGS)" -o runc .
all: runc recvtty
@@ -41,7 +41,6 @@ contrib/cmd/recvtty/recvtty: $(SOURCES)
static: $(SOURCES)
CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo static_build" -installsuffix netgo -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) netgo osusergo static_build" -installsuffix netgo -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
release:
script/release.sh -r release/$(VERSION) -v $(VERSION)
--
2.17.1

View File

@ -1,22 +0,0 @@
From a9a2b9e72027d0b2357f6dfe8b154762aaa8dd02 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Thu, 19 Apr 2018 16:39:41 -0400
Subject: [PATCH] build: drop recvtty and use GOBUILDFLAGS
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Index: git/src/import/Makefile
===================================================================
--- git.orig/src/import/Makefile
+++ git/src/import/Makefile
@@ -41,7 +41,6 @@
static: $(SOURCES)
CGO_ENABLED=1 $(GO) build $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo static_build" -installsuffix netgo -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) netgo osusergo static_build" -installsuffix netgo -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION} $(EXTRA_LDFLAGS)" -o contrib/cmd/recvtty/recvtty ./contrib/cmd/recvtty
release:
script/release.sh -r release/$(VERSION) -v $(VERSION)

View File

@ -5,7 +5,7 @@ include runc.inc
SRCREV_runc-docker = "425e105d5a03fabd737a126ad93d62a9eeede87f" SRCREV_runc-docker = "425e105d5a03fabd737a126ad93d62a9eeede87f"
SRC_URI = "git://github.com/opencontainers/runc;nobranch=1;name=runc-docker \ SRC_URI = "git://github.com/opencontainers/runc;nobranch=1;name=runc-docker \
file://0001-runc-Add-console-socket-dev-null.patch \ file://0001-runc-Add-console-socket-dev-null.patch \
file://0001-build-drop-recvtty-and-use-GOBUILDFLAGS.patch \ file://0001-Makefile-respect-GOBUILDFLAGS-for-runc-and-remove-re.patch \
file://0001-runc-docker-SIGUSR1-daemonize.patch \ file://0001-runc-docker-SIGUSR1-daemonize.patch \
" "

View File

@ -3,5 +3,6 @@ include runc.inc
SRCREV = "652297c7c7e6c94e8d064ad5916c32891a6fd388" SRCREV = "652297c7c7e6c94e8d064ad5916c32891a6fd388"
SRC_URI = " \ SRC_URI = " \
git://github.com/opencontainers/runc;branch=master \ git://github.com/opencontainers/runc;branch=master \
file://0001-Makefile-respect-GOBUILDFLAGS-for-runc-and-remove-re.patch \
" "
RUNC_VERSION = "1.0.0-rc8" RUNC_VERSION = "1.0.0-rc8"

View File

@ -14,8 +14,10 @@ inherit go
inherit goarch inherit goarch
inherit pkgconfig inherit pkgconfig
PACKAGECONFIG ??= "" PACKAGECONFIG ??= "static"
PACKAGECONFIG[seccomp] = "seccomp,,libseccomp" PACKAGECONFIG[seccomp] = "seccomp,,libseccomp"
# This PACKAGECONFIG serves the purpose of whether building runc as static or not
PACKAGECONFIG[static] = ""
PROVIDES += "virtual/runc" PROVIDES += "virtual/runc"
RPROVIDES_${PN} = "virtual/runc" RPROVIDES_${PN} = "virtual/runc"
@ -54,7 +56,11 @@ do_compile() {
export CFLAGS="" export CFLAGS=""
export LDFLAGS="" export LDFLAGS=""
if ${@bb.utils.contains('PACKAGECONFIG', 'static', 'true', 'false', d)}; then
oe_runmake static oe_runmake static
else
oe_runmake runc
fi
} }
do_install() { do_install() {