Skip to contentSkip to conversation

cni: remove unnecessary GO settings

PATCH In review Chen Qi 2 participants 4 messages Aug 12, 2019

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH v2 1/3 cni: remove unnecessary GO settings

These settings are either in go.bbclass or duplicate, thus removing them.

Keep only CGO_ENABLED and GOPATH to easier manipulation while upgrading cni.

---
 recipes-networking/cni/cni_git.bb | 18 ------------------
 1 file changed, 18 deletions(-)
recipes-networking/cni/cni_git.bb +0 -18
index d07154b..266ee69 100644
@@ -29,18 +29,6 @@ inherit go
 inherit goarch
 
 do_compile() {
-	export GOARCH="${TARGET_GOARCH}"
-	export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
-	export GOPATH="${S}/src/import:${S}/src/import/vendor"
-
-	# Pass the needed cflags/ldflags so that cgo
-	# can find the needed headers files and libraries
-	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}"
-
 	# link fixups for compilation
 	rm -f ${S}/src/import/vendor/src
 	mkdir -p ${S}/src/import/vendor/
@@ -56,13 +44,7 @@ do_compile() {
 	ln -sf ${WORKDIR}/plugins ${S}/src/import/vendor/github.com/containernetworking/plugins
 
 	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}"
 
 	cd ${S}/src/import/vendor/github.com/containernetworking/cni/libcni
 	go build
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 3/3 cni: build more plugins

Also build plugins under ipam. Other distros default to contain these plugins.

---
 recipes-networking/cni/cni_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
recipes-networking/cni/cni_git.bb +1 -1
index 495b9c1..5348b95 100644
@@ -53,7 +53,7 @@ do_compile() {
 	${GO} build
 
 	cd ${S}/src/import/vendor/github.com/containernetworking/plugins/
-	PLUGINS="$(ls -d plugins/meta/*; ls -d plugins/main/* | grep -v windows)"
+	PLUGINS="$(ls -d plugins/meta/*; ls -d plugins/ipam/*; ls -d plugins/main/* | grep -v windows)"
 	mkdir -p ${WORKDIR}/plugins/bin/
 	for p in $PLUGINS; do
 	    plugin="$(basename "$p")"
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 2/3 cni: fix problem about cross compilation

In reply to Chen Qi

When setting up k8s, the following error appeared, failing to setup coredns pod.

NetworkPlugin cni failed to set up pod "coredns-5f7fc64c95-4nnfq_kube-system" network: fork/exec /opt/cni/bin/loopback: no such file or directory

This is because the binary, /opt/cni/bin/loopback, has wrong interpreter.

So fix do_compile to use ${GO} instead of go to fix this problem.

---
 recipes-networking/cni/cni_git.bb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
recipes-networking/cni/cni_git.bb +3 -3
index 266ee69..495b9c1 100644
@@ -47,10 +47,10 @@ do_compile() {
 	export CGO_ENABLED="1"
 
 	cd ${S}/src/import/vendor/github.com/containernetworking/cni/libcni
-	go build
+	${GO} build
 
 	cd ${S}/src/import/vendor/github.com/containernetworking/cni/cnitool
-	go build
+	${GO} build
 
 	cd ${S}/src/import/vendor/github.com/containernetworking/plugins/
 	PLUGINS="$(ls -d plugins/meta/*; ls -d plugins/main/* | grep -v windows)"
@@ -58,7 +58,7 @@ do_compile() {
 	for p in $PLUGINS; do
 	    plugin="$(basename "$p")"
 	    echo "building: $p"
-	    go build -o ${WORKDIR}/plugins/bin/$plugin github.com/containernetworking/plugins/$p
+	    ${GO} build -o ${WORKDIR}/plugins/bin/$plugin github.com/containernetworking/plugins/$p
 	done
 }
 
Signature · 1 line
2.17.1
#3 lore raw
In reply to Chen Qi

v2 is staged for testing. See my master-next branch for details.

Bruce

Quoted 64 lines · Chen Qi

These settings are either in go.bbclass or duplicate, thus removing them.

Keep only CGO_ENABLED and GOPATH to easier manipulation while upgrading cni.

---
 recipes-networking/cni/cni_git.bb | 18 ------------------
 1 file changed, 18 deletions(-)
recipes-networking/cni/ renamed from recipes-networking/cni/cni_git.bb +0 -0

cni_git.bb
index d07154b..266ee69 100644

recipes-networking/cni/cni_git.bb +0 -14
@@ -29,18 +29,6 @@ inherit go
 inherit goarch
 
 do_compile() {
-       export GOARCH="${TARGET_GOARCH}"
-       export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
-       export GOPATH="${S}/src/import:${S}/src/import/vendor"
-
-       # Pass the needed cflags/ldflags so that cgo
-       # can find the needed headers files and libraries
-       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}"
-
        # link fixups for compilation
        rm -f ${S}/src/import/vendor/src
        mkdir -p ${S}/src/import/vendor/
@@ -56,13 +44,7 @@ do_compile() {
        ln -sf ${WORKDIR}/plugins ${S}/src/import/vendor/

github.com/containernetworking/plugins

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"

recipes-networking/cni/cni_git.bb +0 -5
-
-       # 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}"
 
        cd ${S}/src/import/vendor/

github.com/containernetworking/cni/libcni
go build
--
2.17.1

--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II