containerd: uprev to v1.0.2

Uprev containerd to v1.0.2 for compatibility with recent docker (18.04+)
builds.

With this uprev we also significantly restructure the build to use more
of the latest oe-core go build infrastructure, but non-standard parts of
the build remain.

We also allow containerd to be build with CGO enabled to avoid linkage
errors with the oe provided go build infrastructure.

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
This commit is contained in:
Bruce Ashfield 2018-04-02 00:43:50 -04:00
parent f5fbfa8ac4
commit 935e3d969e
3 changed files with 65 additions and 29 deletions

View File

@ -1,9 +1,11 @@
SRCREV = "cfd04396dc68220d1cecbe686a6cc3aa5ce3667c"
SRC_URI = "git://github.com/containerd/containerd;nobranch=1 \
file://0001-containerd-shim-build-with-CGO.patch \
"
include containerd.inc include containerd.inc
SRCREV = "0ac3cd1be170d180b2baed755e8f0da547ceb267" CONTAINERD_VERSION = "v1.0.2"
SRC_URI = "git://github.com/docker/containerd.git;nobranch=1 \
"
CONTAINERD_VERSION = "0.2.2"
PROVIDES += "virtual/containerd" PROVIDES += "virtual/containerd"
RPROVIDES_${PN} = "virtual/containerd" RPROVIDES_${PN} = "virtual/containerd"

View File

@ -6,7 +6,7 @@ DESCRIPTION = "containerd is a daemon to control runC, built for performance and
# Apache-2.0 for containerd # Apache-2.0 for containerd
LICENSE = "Apache-2.0" LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE.code;md5=aadc30f9c14d876ded7bedc0afd2d3d7" LIC_FILES_CHKSUM = "file://src/import/LICENSE.code;md5=aadc30f9c14d876ded7bedc0afd2d3d7"
SRC_URI += "file://containerd.service" SRC_URI += "file://containerd.service"
@ -17,6 +17,8 @@ PV = "${CONTAINERD_VERSION}+git${SRCREV}"
inherit go inherit go
inherit goarch inherit goarch
GO_IMPORT = "import"
RRECOMMENDS_${PN} = "lxc docker" RRECOMMENDS_${PN} = "lxc docker"
CONTAINERD_PKG="github.com/containerd/containerd" CONTAINERD_PKG="github.com/containerd/containerd"
@ -25,30 +27,35 @@ INSANE_SKIP_${PN} += "ldflags"
do_configure[noexec] = "1" do_configure[noexec] = "1"
do_compile() { do_compile() {
# Set GOPATH. See 'PACKAGERS.md'. Don't rely on export GOARCH="${TARGET_GOARCH}"
# docker to download its dependencies but rather
# use dependencies packaged independently.
cd ${S}
rm -rf .gopath
mkdir -p .gopath/src/"$(dirname "${CONTAINERD_PKG}")"
ln -sf ../../../.. .gopath/src/"${CONTAINERD_PKG}"
export GOPATH="${WORKDIR}/git/" # link fixups for compilation
export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" rm -f ${S}/src/import/vendor/src
ln -sf ./ ${S}/src/import/vendor/src
# Pass the needed cflags/ldflags so that cgo mkdir -p ${S}/src/import/vendor/src/github.com/containerd/containerd/
# can find the needed headers files and libraries # without this, the stress test parts of the build fail
export GOARCH="${TARGET_GOARCH}" cp ${S}/src/import/*.go ${S}/src/import/vendor/src/github.com/containerd/containerd
export CGO_ENABLED="1"
export CFLAGS=""
export LDFLAGS=""
export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export GO_GCFLAGS=""
export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
oe_runmake static for c in content errdefs fs images mount snapshots linux api runtimes defaults progress \
protobuf reference diff platforms runtime remotes version archive dialer gc metadata \
metrics filters identifiers labels leases plugin server services \
cmd cio containers namespaces oci events log reaper sys rootfs; do
ln -sfn ${S}/src/import/${c} ${S}/src/import/vendor/github.com/containerd/containerd/${c}
done
export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export BUILDTAGS="no_btrfs static_build netgo"
cd ${S}/src/import
oe_runmake binaries
} }
# Note: disabled for now, since docker is launching containerd # Note: disabled for now, since docker is launching containerd
@ -59,9 +66,9 @@ do_compile() {
do_install() { do_install() {
mkdir -p ${D}/${bindir} mkdir -p ${D}/${bindir}
cp ${S}/bin/containerd ${D}/${bindir}/containerd cp ${S}/src/import/bin/containerd ${D}/${bindir}/containerd
cp ${S}/bin/containerd-shim ${D}/${bindir}/containerd-shim cp ${S}/src/import/bin/containerd-shim ${D}/${bindir}/containerd-shim
cp ${S}/bin/ctr ${D}/${bindir}/containerd-ctr cp ${S}/src/import/bin/ctr ${D}/${bindir}/containerd-ctr
ln -sf containerd ${D}/${bindir}/docker-containerd ln -sf containerd ${D}/${bindir}/docker-containerd
ln -sf containerd-shim ${D}/${bindir}/docker-containerd-shim ln -sf containerd-shim ${D}/${bindir}/docker-containerd-shim
@ -78,3 +85,4 @@ do_install() {
FILES_${PN} += "${systemd_system_unitdir}/*" FILES_${PN} += "${systemd_system_unitdir}/*"
INHIBIT_PACKAGE_STRIP = "1" INHIBIT_PACKAGE_STRIP = "1"
INSANE_SKIP_${PN} += "ldflags already-stripped"

View File

@ -0,0 +1,26 @@
From a1d2db9037b1302c4ce4cfc170a4fa443f68e594 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Thu, 29 Mar 2018 15:48:41 -0400
Subject: [PATCH] containerd-shim: build with CGO
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/import/Makefile b/src/import/Makefile
index 9d8cf8a18fbc..1dff4e3c2043 100644
--- a/src/import/Makefile
+++ b/src/import/Makefile
@@ -134,7 +134,7 @@ bin/%: cmd/% FORCE
bin/containerd-shim: cmd/containerd-shim FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220
@echo "$(WHALE) bin/containerd-shim"
- @CGO_ENABLED=0 go build -o bin/containerd-shim ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim
+ @go build -o bin/containerd-shim ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim
binaries: $(BINARIES) ## build binaries
@echo "$(WHALE) $@"
--
2.4.0.53.g8440f74