From 935e3d969ef1c0ce2f2a2719c31285be6114c8f9 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Mon, 2 Apr 2018 00:43:50 -0400 Subject: 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 --- .../containerd/containerd-opencontainers_git.bb | 10 ++-- recipes-containers/containerd/containerd.inc | 64 ++++++++++++---------- .../0001-containerd-shim-build-with-CGO.patch | 26 +++++++++ 3 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 recipes-containers/containerd/files/0001-containerd-shim-build-with-CGO.patch diff --git a/recipes-containers/containerd/containerd-opencontainers_git.bb b/recipes-containers/containerd/containerd-opencontainers_git.bb index 37f85472..316eea74 100644 --- a/recipes-containers/containerd/containerd-opencontainers_git.bb +++ b/recipes-containers/containerd/containerd-opencontainers_git.bb @@ -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 -SRCREV = "0ac3cd1be170d180b2baed755e8f0da547ceb267" -SRC_URI = "git://github.com/docker/containerd.git;nobranch=1 \ - " -CONTAINERD_VERSION = "0.2.2" +CONTAINERD_VERSION = "v1.0.2" PROVIDES += "virtual/containerd" RPROVIDES_${PN} = "virtual/containerd" diff --git a/recipes-containers/containerd/containerd.inc b/recipes-containers/containerd/containerd.inc index e7a37192..9f66e46e 100644 --- a/recipes-containers/containerd/containerd.inc +++ b/recipes-containers/containerd/containerd.inc @@ -6,7 +6,7 @@ DESCRIPTION = "containerd is a daemon to control runC, built for performance and # Apache-2.0 for containerd 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" @@ -17,6 +17,8 @@ PV = "${CONTAINERD_VERSION}+git${SRCREV}" inherit go inherit goarch +GO_IMPORT = "import" + RRECOMMENDS_${PN} = "lxc docker" CONTAINERD_PKG="github.com/containerd/containerd" @@ -25,30 +27,35 @@ INSANE_SKIP_${PN} += "ldflags" do_configure[noexec] = "1" do_compile() { - # Set GOPATH. See 'PACKAGERS.md'. Don't rely on - # 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/" - export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" - - # Pass the needed cflags/ldflags so that cgo - # can find the needed headers files and libraries - export GOARCH="${TARGET_GOARCH}" - 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 + export GOARCH="${TARGET_GOARCH}" + + # link fixups for compilation + rm -f ${S}/src/import/vendor/src + ln -sf ./ ${S}/src/import/vendor/src + + mkdir -p ${S}/src/import/vendor/src/github.com/containerd/containerd/ + # without this, the stress test parts of the build fail + cp ${S}/src/import/*.go ${S}/src/import/vendor/src/github.com/containerd/containerd + + 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 @@ -59,9 +66,9 @@ do_compile() { do_install() { mkdir -p ${D}/${bindir} - cp ${S}/bin/containerd ${D}/${bindir}/containerd - cp ${S}/bin/containerd-shim ${D}/${bindir}/containerd-shim - cp ${S}/bin/ctr ${D}/${bindir}/containerd-ctr + cp ${S}/src/import/bin/containerd ${D}/${bindir}/containerd + cp ${S}/src/import/bin/containerd-shim ${D}/${bindir}/containerd-shim + cp ${S}/src/import/bin/ctr ${D}/${bindir}/containerd-ctr ln -sf containerd ${D}/${bindir}/docker-containerd ln -sf containerd-shim ${D}/${bindir}/docker-containerd-shim @@ -78,3 +85,4 @@ do_install() { FILES_${PN} += "${systemd_system_unitdir}/*" INHIBIT_PACKAGE_STRIP = "1" +INSANE_SKIP_${PN} += "ldflags already-stripped" diff --git a/recipes-containers/containerd/files/0001-containerd-shim-build-with-CGO.patch b/recipes-containers/containerd/files/0001-containerd-shim-build-with-CGO.patch new file mode 100644 index 00000000..3b890834 --- /dev/null +++ b/recipes-containers/containerd/files/0001-containerd-shim-build-with-CGO.patch @@ -0,0 +1,26 @@ +From a1d2db9037b1302c4ce4cfc170a4fa443f68e594 Mon Sep 17 00:00:00 2001 +From: Bruce Ashfield +Date: Thu, 29 Mar 2018 15:48:41 -0400 +Subject: [PATCH] containerd-shim: build with CGO + +Signed-off-by: Bruce Ashfield +--- + 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 + -- cgit v1.2.3-54-g00ecf