cri: introduce cri-tools

Based on the original recipe from Tim Orling, we introduce a recipe
for critools so we can interact diretly with cri based runtimes.

We do the normal go manipulations to get this cross building,
with the following specific tweak/patch:

   The build system already knows whether or not we want to use CGO,
   so we remove the hardcoded variant so our exported environment
   variable will control the enablement.

   Since our oe-core go infrastructure insists on both -pie and static
   builds (for the most part), and that is not recommended by many
   packages, we end up with errors like:

      1.20.0+gitec9e336fd8c21c4bab89a6aed2c4a138c8cfae75/src/import/_output/crictl \
           -ldflags '-X github.com/kubernetes-sigs/cri-tools/pkg/version.Version=1.20.0' \
           -tags '' \
           github.com/kubernetes-sigs/cri-tools/cmd/crictl
       # github.com/kubernetes-sigs/cri-tools/cmd/crictl
       cannot find package runtime/cgo (using -importcfg)
       /work/cortexa72-poky-linux/cri-tools/1.20.0+gitec9e336fd8c21c4bab89a6aed2c4a138c8cfae75-r0/recipe-sysroot-native/usr/lib/aarch64-poky-linux/go/pkg/tool/linux_amd64/link:
       cannot open file : open : no such file or directory

   In a similar manner to:

   https://www.yoctoproject.org/pipermail/meta-virtualization/2019-March/004084.html

   We introduce '-a -pkgdir dontusecurrentpkgs' to mask/fix the problem,
   and continue to work towards non-static builds.

% root@qemux86-64:~# crictl --version
crictl version 1.20.0-dirty

Signed-off-by: Tim Orling <ticotimo@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2021-02-10 10:09:25 -05:00
parent 4ede0acf44
commit 2a919ae202
2 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,52 @@
From 28ee02687339b657a7aa93570015a6751c824e2d Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Wed, 10 Feb 2021 09:58:24 -0500
Subject: [PATCH] build: allow environmental CGO settings and pass
dontusecurrentpkgs
The build system already knows whether or not we want to use CGO,
so we remove the hardcoded variant so our exported environment
variable will control the enablement.
Since our oe-core go infrastructure insists on both -pie and static
builds (for the most part), and that is not recommended by many
packages, we end up with errors like:
1.20.0+gitec9e336fd8c21c4bab89a6aed2c4a138c8cfae75/src/import/_output/crictl \
-ldflags '-X github.com/kubernetes-sigs/cri-tools/pkg/version.Version=1.20.0' \
-tags '' \
github.com/kubernetes-sigs/cri-tools/cmd/crictl
# github.com/kubernetes-sigs/cri-tools/cmd/crictl
cannot find package runtime/cgo (using -importcfg)
/work/cortexa72-poky-linux/cri-tools/1.20.0+gitec9e336fd8c21c4bab89a6aed2c4a138c8cfae75-r0/recipe-sysroot-native/usr/lib/aarch64-poky-linux/go/pkg/tool/linux_amd64/link:
cannot open file : open : no such file or directory
In a similar manner to:
https://www.yoctoproject.org/pipermail/meta-virtualization/2019-March/004084.html
We introduce '-a -pkgdir dontusecurrentpkgs' to mask/fix the problem,
and continue to work towards non-static builds.
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
src/import/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index acf0fc0..130988c 100644
--- a/src/import/Makefile
+++ b/src/import/Makefile
@@ -63,7 +63,8 @@ critest:
$(PROJECT)/cmd/critest
crictl:
- CGO_ENABLED=0 $(GO_BUILD) -o $(CURDIR)/_output/crictl$(BIN_EXT) \
+ $(GO_BUILD) -o $(CURDIR)/_output/crictl$(BIN_EXT) \
+ -a -pkgdir dontusecurrentpkgs \
-ldflags '$(GO_LDFLAGS)' \
-tags '$(BUILDTAGS)' \
$(PROJECT)/cmd/crictl
--
2.19.1

View File

@ -0,0 +1,78 @@
HOMEPAGE = "https://github.com/kubernetes-sigs/cri-tools"
SUMMARY = "CLI and validation tools for Kubelet Container Runtime Interface (CRI)"
DESCRIPTION = "What is the scope of this project? \
\
cri-tools aims to provide a series of debugging and validation tools for \
Kubelet CRI, which includes: \
\
* crictl: CLI for kubelet CRI. \
* critest: validation test suites for kubelet CRI. \
\
What is not in scope for this project? \
\
* Building a new kubelet container runtime based on CRI. \
* Managing pods/containers for CRI-compatible runtimes by end-users, e.g. \
pods created by crictl may be removed automatically by kubelet because of \
non-exist on the kube-apiserver. \
"
SRCREV_cri-tools = "ec9e336fd8c21c4bab89a6aed2c4a138c8cfae75"
SRC_URI = "\
git://github.com/kubernetes-sigs/cri-tools.git;branch=master;name=cri-tools \
file://0001-build-allow-environmental-CGO-settings-and-pass-dont.patch \
"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
GO_IMPORT = "import"
PV = "1.20.0+git${SRCREV_cri-tools}"
RPROVIDES_${PN} += "crictl"
PACKAGES =+ "${PN}-critest"
inherit go
inherit goarch
inherit pkgconfig
EXTRA_OEMAKE="BUILDTAGS=''"
do_compile() {
# link fixups for compilation
rm -f ${S}/src/import/vendor/src
ln -sf ./ ${S}/src/import/vendor/src
export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
cd ${S}/src/import
# Build the target binaries
export GOARCH="${TARGET_GOARCH}"
# 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 CFLAGS=""
export LDFLAGS=""
export CC="${CC}"
export LD="${LD}"
export GOBIN=""
oe_runmake crictl
}
do_install() {
install -d ${D}${bindir}
install -m 755 -D ${S}/src/import/_output/* ${D}/${bindir}
}
FILES_${PN}-critest = "${bindir}/critest"
# don't clobber hooks.d
ALLOW_EMPTY_${PN} = "1"
INSANE_SKIP_${PN} += "ldflags already-stripped textrel"
deltask compile_ptest_base
COMPATIBLE_HOST = "^(?!(qemu)?mips).*"