diff options
author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-02-10 10:09:25 -0500 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2021-02-10 10:09:25 -0500 |
commit | 2a919ae202f659411a8142d3d95bee4c5314fc74 (patch) | |
tree | f67893a2c67591ea97a4b6e9f6f253f93070df09 | |
parent | 4ede0acf4450715ea11c3000bd0cbea0bc6b0f49 (diff) | |
download | meta-virtualization-2a919ae202f659411a8142d3d95bee4c5314fc74.tar.gz |
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>
-rw-r--r-- | recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch | 52 | ||||
-rw-r--r-- | recipes-containers/cri-tools/cri-tools_git.bb | 78 |
2 files changed, 130 insertions, 0 deletions
diff --git a/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch b/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch new file mode 100644 index 00000000..5772c1ae --- /dev/null +++ b/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch | |||
@@ -0,0 +1,52 @@ | |||
1 | From 28ee02687339b657a7aa93570015a6751c824e2d Mon Sep 17 00:00:00 2001 | ||
2 | From: Bruce Ashfield <bruce.ashfield@gmail.com> | ||
3 | Date: Wed, 10 Feb 2021 09:58:24 -0500 | ||
4 | Subject: [PATCH] build: allow environmental CGO settings and pass | ||
5 | dontusecurrentpkgs | ||
6 | |||
7 | The build system already knows whether or not we want to use CGO, | ||
8 | so we remove the hardcoded variant so our exported environment | ||
9 | variable will control the enablement. | ||
10 | |||
11 | Since our oe-core go infrastructure insists on both -pie and static | ||
12 | builds (for the most part), and that is not recommended by many | ||
13 | packages, we end up with errors like: | ||
14 | |||
15 | 1.20.0+gitec9e336fd8c21c4bab89a6aed2c4a138c8cfae75/src/import/_output/crictl \ | ||
16 | -ldflags '-X github.com/kubernetes-sigs/cri-tools/pkg/version.Version=1.20.0' \ | ||
17 | -tags '' \ | ||
18 | github.com/kubernetes-sigs/cri-tools/cmd/crictl | ||
19 | # github.com/kubernetes-sigs/cri-tools/cmd/crictl | ||
20 | cannot find package runtime/cgo (using -importcfg) | ||
21 | /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: | ||
22 | cannot open file : open : no such file or directory | ||
23 | |||
24 | In a similar manner to: | ||
25 | |||
26 | https://www.yoctoproject.org/pipermail/meta-virtualization/2019-March/004084.html | ||
27 | |||
28 | We introduce '-a -pkgdir dontusecurrentpkgs' to mask/fix the problem, | ||
29 | and continue to work towards non-static builds. | ||
30 | |||
31 | Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> | ||
32 | --- | ||
33 | src/import/Makefile | 3 ++- | ||
34 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
35 | |||
36 | diff --git a/Makefile b/Makefile | ||
37 | index acf0fc0..130988c 100644 | ||
38 | --- a/src/import/Makefile | ||
39 | +++ b/src/import/Makefile | ||
40 | @@ -63,7 +63,8 @@ critest: | ||
41 | $(PROJECT)/cmd/critest | ||
42 | |||
43 | crictl: | ||
44 | - CGO_ENABLED=0 $(GO_BUILD) -o $(CURDIR)/_output/crictl$(BIN_EXT) \ | ||
45 | + $(GO_BUILD) -o $(CURDIR)/_output/crictl$(BIN_EXT) \ | ||
46 | + -a -pkgdir dontusecurrentpkgs \ | ||
47 | -ldflags '$(GO_LDFLAGS)' \ | ||
48 | -tags '$(BUILDTAGS)' \ | ||
49 | $(PROJECT)/cmd/crictl | ||
50 | -- | ||
51 | 2.19.1 | ||
52 | |||
diff --git a/recipes-containers/cri-tools/cri-tools_git.bb b/recipes-containers/cri-tools/cri-tools_git.bb new file mode 100644 index 00000000..17ddbd02 --- /dev/null +++ b/recipes-containers/cri-tools/cri-tools_git.bb | |||
@@ -0,0 +1,78 @@ | |||
1 | HOMEPAGE = "https://github.com/kubernetes-sigs/cri-tools" | ||
2 | SUMMARY = "CLI and validation tools for Kubelet Container Runtime Interface (CRI)" | ||
3 | DESCRIPTION = "What is the scope of this project? \ | ||
4 | \ | ||
5 | cri-tools aims to provide a series of debugging and validation tools for \ | ||
6 | Kubelet CRI, which includes: \ | ||
7 | \ | ||
8 | * crictl: CLI for kubelet CRI. \ | ||
9 | * critest: validation test suites for kubelet CRI. \ | ||
10 | \ | ||
11 | What is not in scope for this project? \ | ||
12 | \ | ||
13 | * Building a new kubelet container runtime based on CRI. \ | ||
14 | * Managing pods/containers for CRI-compatible runtimes by end-users, e.g. \ | ||
15 | pods created by crictl may be removed automatically by kubelet because of \ | ||
16 | non-exist on the kube-apiserver. \ | ||
17 | " | ||
18 | |||
19 | SRCREV_cri-tools = "ec9e336fd8c21c4bab89a6aed2c4a138c8cfae75" | ||
20 | SRC_URI = "\ | ||
21 | git://github.com/kubernetes-sigs/cri-tools.git;branch=master;name=cri-tools \ | ||
22 | file://0001-build-allow-environmental-CGO-settings-and-pass-dont.patch \ | ||
23 | " | ||
24 | |||
25 | LICENSE = "Apache-2.0" | ||
26 | LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" | ||
27 | |||
28 | GO_IMPORT = "import" | ||
29 | |||
30 | PV = "1.20.0+git${SRCREV_cri-tools}" | ||
31 | |||
32 | RPROVIDES_${PN} += "crictl" | ||
33 | PACKAGES =+ "${PN}-critest" | ||
34 | |||
35 | inherit go | ||
36 | inherit goarch | ||
37 | inherit pkgconfig | ||
38 | |||
39 | EXTRA_OEMAKE="BUILDTAGS=''" | ||
40 | |||
41 | do_compile() { | ||
42 | # link fixups for compilation | ||
43 | rm -f ${S}/src/import/vendor/src | ||
44 | ln -sf ./ ${S}/src/import/vendor/src | ||
45 | |||
46 | export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go" | ||
47 | cd ${S}/src/import | ||
48 | |||
49 | # Build the target binaries | ||
50 | export GOARCH="${TARGET_GOARCH}" | ||
51 | # Pass the needed cflags/ldflags so that cgo can find the needed headers files and libraries | ||
52 | export CGO_ENABLED="1" | ||
53 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
54 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
55 | export CFLAGS="" | ||
56 | export LDFLAGS="" | ||
57 | export CC="${CC}" | ||
58 | export LD="${LD}" | ||
59 | export GOBIN="" | ||
60 | |||
61 | oe_runmake crictl | ||
62 | } | ||
63 | |||
64 | do_install() { | ||
65 | install -d ${D}${bindir} | ||
66 | install -m 755 -D ${S}/src/import/_output/* ${D}/${bindir} | ||
67 | } | ||
68 | |||
69 | FILES_${PN}-critest = "${bindir}/critest" | ||
70 | |||
71 | # don't clobber hooks.d | ||
72 | ALLOW_EMPTY_${PN} = "1" | ||
73 | |||
74 | INSANE_SKIP_${PN} += "ldflags already-stripped textrel" | ||
75 | |||
76 | deltask compile_ptest_base | ||
77 | |||
78 | COMPATIBLE_HOST = "^(?!(qemu)?mips).*" | ||