diff options
-rw-r--r-- | recipes-networking/cni/cni_git.bb | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/recipes-networking/cni/cni_git.bb b/recipes-networking/cni/cni_git.bb new file mode 100644 index 00000000..137ce661 --- /dev/null +++ b/recipes-networking/cni/cni_git.bb | |||
@@ -0,0 +1,93 @@ | |||
1 | HOMEPAGE = "https://github.com/containernetworking/cni" | ||
2 | SUMMARY = "Container Network Interface - networking for Linux containers" | ||
3 | DESCRIPTION = "CNI (Container Network Interface), a Cloud Native Computing \ | ||
4 | Foundation project, consists of a specification and libraries for writing \ | ||
5 | plugins to configure network interfaces in Linux containers, along with a \ | ||
6 | number of supported plugins. CNI concerns itself only with network connectivity \ | ||
7 | of containers and removing allocated resources when the container is deleted. \ | ||
8 | Because of this focus, CNI has a wide range of support and the specification \ | ||
9 | is simple to implement. \ | ||
10 | " | ||
11 | |||
12 | SRCREV_cni = "4b9e11a5266fe50222ed00c5973c6ea4a384a4bb" | ||
13 | SRCREV_plugins = "c238c93b5e7c681f1935ff813b30e82f96f6c367" | ||
14 | SRC_URI = "\ | ||
15 | git://github.com/containernetworking/cni.git;nobranch=1;name=cni \ | ||
16 | git://github.com/containernetworking/plugins.git;nobranch=1;destsuffix=plugins;name=plugins \ | ||
17 | " | ||
18 | |||
19 | LICENSE = "Apache-2.0" | ||
20 | LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc" | ||
21 | |||
22 | GO_IMPORT = "import" | ||
23 | |||
24 | PV = "0.6.0+git${SRCREV_cni}" | ||
25 | |||
26 | inherit go | ||
27 | inherit goarch | ||
28 | |||
29 | do_compile() { | ||
30 | export GOARCH="${TARGET_GOARCH}" | ||
31 | export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" | ||
32 | export GOPATH="${S}/src/import:${S}/src/import/vendor" | ||
33 | |||
34 | # Pass the needed cflags/ldflags so that cgo | ||
35 | # can find the needed headers files and libraries | ||
36 | export CGO_ENABLED="1" | ||
37 | export CFLAGS="" | ||
38 | export LDFLAGS="" | ||
39 | export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
40 | export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
41 | |||
42 | # link fixups for compilation | ||
43 | rm -f ${S}/src/import/vendor/src | ||
44 | ln -sf ./ ${S}/src/import/vendor/src | ||
45 | rm -rf ${S}/src/import/plugins | ||
46 | rm -rf ${S}/src/import/vendor/github.com/containernetworking/plugins | ||
47 | |||
48 | mkdir -p ${S}/src/import/vendor/github.com/containernetworking/cni | ||
49 | |||
50 | ln -sf ../../../../libcni ${S}/src/import/vendor/github.com/containernetworking/cni/libcni | ||
51 | ln -sf ../../../../pkg ${S}/src/import/vendor/github.com/containernetworking/cni/pkg | ||
52 | ln -sf ../../../../cnitool ${S}/src/import/vendor/github.com/containernetworking/cni/cnitool | ||
53 | ln -sf ${WORKDIR}/plugins ${S}/src/import/vendor/github.com/containernetworking/plugins | ||
54 | |||
55 | export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go" | ||
56 | export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go" | ||
57 | |||
58 | # Pass the needed cflags/ldflags so that cgo | ||
59 | # can find the needed headers files and libraries | ||
60 | export CGO_ENABLED="1" | ||
61 | export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
62 | export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}" | ||
63 | |||
64 | cd ${S}/src/import/vendor/github.com/containernetworking/cni/libcni | ||
65 | go build | ||
66 | |||
67 | cd ${S}/src/import/vendor/github.com/containernetworking/cni/cnitool | ||
68 | go build | ||
69 | |||
70 | cd ${S}/src/import/vendor/github.com/containernetworking/plugins/ | ||
71 | PLUGINS="plugins/meta/* plugins/main/*" | ||
72 | mkdir -p ${WORKDIR}/plugins/bin/ | ||
73 | for p in $PLUGINS; do | ||
74 | plugin="$(basename "$p")" | ||
75 | echo "building: $p" | ||
76 | go build -o ${WORKDIR}/plugins/bin/$plugin github.com/containernetworking/plugins/$p | ||
77 | done | ||
78 | } | ||
79 | |||
80 | do_install() { | ||
81 | localbindir="/usr/local/bin" | ||
82 | |||
83 | install -d ${D}${localbindir} | ||
84 | install -d ${D}/${sysconfdir}/cni/net.d | ||
85 | |||
86 | install -m 755 ${S}/src/import/cnitool/cnitool ${D}/${localbindir} | ||
87 | install -m 755 -D ${WORKDIR}/plugins/bin/* ${D}/${localbindir} | ||
88 | } | ||
89 | |||
90 | FILES_${PN} += "/usr/local/bin/*" | ||
91 | |||
92 | INHIBIT_PACKAGE_STRIP = "1" | ||
93 | INSANE_SKIP_${PN} += "ldflags already-stripped" | ||