From 505a48d573e3a6fd3956f8651712292f823c4c00 Mon Sep 17 00:00:00 2001 From: Jackie Huang Date: Fri, 2 Jul 2021 17:36:19 +0800 Subject: [PATCH] cri-tools: add the recipe for stx 5.0 * cri-tools is required by containerd for stx 5.0 (in centos, it's not a seperate package, it's included in containerd package) * the original recipe is copied from master branch of meta-virtualization * inherit stx-metadata to install config files from stx 'integ' repo. Story: 2008952 Task: 42576 Signed-off-by: Jackie Huang Change-Id: I64720f4e09e20cf7fd4ab44e80777d3955d2fc58 --- ...ronmental-CGO-settings-and-pass-dont.patch | 49 +++++++++++ .../cri-tools/cri-tools_git.bb | 85 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 meta-stx-virt/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch create mode 100644 meta-stx-virt/recipes-containers/cri-tools/cri-tools_git.bb diff --git a/meta-stx-virt/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch b/meta-stx-virt/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch new file mode 100644 index 0000000..189d905 --- /dev/null +++ b/meta-stx-virt/recipes-containers/cri-tools/cri-tools/0001-build-allow-environmental-CGO-settings-and-pass-dont.patch @@ -0,0 +1,49 @@ +From 28ee02687339b657a7aa93570015a6751c824e2d Mon Sep 17 00:00:00 2001 +From: Bruce Ashfield +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 +--- + src/import/Makefile | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: cri-tools-1.21.0+gitde32df077e6b0e9e31ce367dfc34c1b6b46e30fa/src/import/Makefile +=================================================================== +--- cri-tools-1.21.0+gitde32df077e6b0e9e31ce367dfc34c1b6b46e30fa.orig/src/import/Makefile ++++ cri-tools-1.21.0+gitde32df077e6b0e9e31ce367dfc34c1b6b46e30fa/src/import/Makefile +@@ -74,7 +74,8 @@ + @$(MAKE) -B $(CRICTL) + + $(CRICTL): +- CGO_ENABLED=0 $(GO_BUILD) -o $@ \ ++ $(GO_BUILD) -o $@ \ ++ -a -pkgdir dontusecurrentpkgs \ + -ldflags '$(GO_LDFLAGS)' \ + -trimpath \ + -tags '$(BUILDTAGS)' \ diff --git a/meta-stx-virt/recipes-containers/cri-tools/cri-tools_git.bb b/meta-stx-virt/recipes-containers/cri-tools/cri-tools_git.bb new file mode 100644 index 0000000..69f7de5 --- /dev/null +++ b/meta-stx-virt/recipes-containers/cri-tools/cri-tools_git.bb @@ -0,0 +1,85 @@ +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 = "de32df077e6b0e9e31ce367dfc34c1b6b46e30fa" +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.21.0+git${SRCREV_cri-tools}" + +RPROVIDES_${PN} += "crictl" +PACKAGES =+ "${PN}-critest" + +inherit go +inherit goarch +inherit pkgconfig +inherit stx-metadata + +STX_REPO = "integ" +STX_SUBPATH = "kubernetes/containerd/centos/files" + +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/build/bin/* ${D}/${bindir} + + install -d ${D}/${sysconfdir} + install -m 644 ${STX_METADATA_PATH}/crictl.yaml ${D}/${sysconfdir}/crictl.yaml +} + +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).*"