blob: 88f9b483d3b8d49f3672f9ff24b762056712a313 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
HOMEPAGE = "https://github.com/containernetworking/cni"
SUMMARY = "Container Network Interface - networking for Linux containers"
DESCRIPTION = "CNI (Container Network Interface), a Cloud Native Computing \
Foundation project, consists of a specification and libraries for writing \
plugins to configure network interfaces in Linux containers, along with a \
number of supported plugins. CNI concerns itself only with network connectivity \
of containers and removing allocated resources when the container is deleted. \
Because of this focus, CNI has a wide range of support and the specification \
is simple to implement. \
"
SRCREV_cni = "1d67f89a2e3cfc3c22da74d4f8490e65ca4a819c"
SRCREV_plugins = "9b3772e1a7abf93cbb7c6526a28bc0d27b830e02"
SRCREV_flannel_plugin = "5d45388ab25791ec961585d921d1a42d3cbcc139"
SRCREV_FORMAT = "cni_plugins"
SRC_URI = "\
git://github.com/containernetworking/cni.git;branch=main;name=cni;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX} \
"
SRC_URI += "git://github.com/containernetworking/plugins.git;branch=main;destsuffix=${GO_SRCURI_DESTSUFFIX}/src/github.com/containernetworking/plugins;name=plugins;protocol=https"
SRC_URI += "git://github.com/flannel-io/cni-plugin;branch=main;name=flannel_plugin;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX}/src/github.com/containernetworking/plugins/plugins/meta/flannel"
include go-mod-git.inc
include go-mod-cache.inc
DEPENDS = " \
rsync-native \
"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
GO_IMPORT = "import"
PV = "v1.3.0+git"
CNI_VERSION = "v1.3.0"
# go-mod-discovery configuration
# The CNI repo has minimal dependencies. The plugins repo is a separate module
# with its own dependencies, so we need to discover both.
# Primary discovery is for the CNI main repo:
GO_MOD_DISCOVERY_BUILD_TARGET = "./..."
GO_MOD_DISCOVERY_GIT_REPO = "https://github.com/containernetworking/cni.git"
GO_MOD_DISCOVERY_GIT_REF = "${SRCREV_cni}"
# Secondary discovery for the plugins repo - we'll run this manually and merge
# For now, the plugins repo uses its vendor directory
inherit go
inherit goarch
inherit go-mod-discovery
BB_GIT_SHALLOW = "1"
# https://github.com/llvm/llvm-project/issues/53999
TOOLCHAIN = "gcc"
do_compile() {
mkdir -p ${S}/src/github.com/containernetworking
ln -sfr ${S}/src/import ${S}/src/github.com/containernetworking/cni
# Fixes: cannot find package "github.com/containernetworking/plugins/plugins/meta/bandwidth" in any of:
# we can't clone the plugin source directly to where it belongs because
# there seems to be an issue in the relocation code from UNPACKDIR to S
# and our LICENSE file is never found.
# This symbolic link arranges for the code to be available where go will
# search during the build
ln -sfr ${S}/src/import/src/github.com/containernetworking/plugins ${B}/src/github.com/containernetworking
cd ${B}/src/import
export GOPATH="${S}/src/import/.gopath:${STAGING_DIR_TARGET}/${prefix}/local/go"
export GOMODCACHE="${S}/pkg/mod"
export CGO_ENABLED="1"
export GOSUMDB="off"
export GOTOOLCHAIN="local"
export GOPROXY="off"
cd ${B}/src/github.com/containernetworking/cni/libcni
${GO} build -trimpath ${GOBUILDFLAGS}
cd ${B}/src/github.com/containernetworking/cni/cnitool
${GO} build -trimpath ${GOBUILDFLAGS}
cd ${B}/src/import/src/github.com/containernetworking/plugins
# Build plugins from the plugins repo (excludes flannel which is a separate module)
# Exclude flannel from this loop - it's from a different repo with a different module path
PLUGINS="$(ls -d plugins/meta/* | grep -v flannel; ls -d plugins/ipam/*; ls -d plugins/main/* | grep -v windows)"
mkdir -p ${B}/plugins/bin/
for p in $PLUGINS; do
plugin="$(basename "$p")"
echo "building: $p"
${GO} build -trimpath ${GOBUILDFLAGS} -ldflags '-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${CNI_VERSION}' -o ${B}/plugins/bin/$plugin github.com/containernetworking/plugins/$p
done
# Build flannel separately - it's from flannel-io/cni-plugin repo with its own module
# The source was fetched to plugins/meta/flannel but module path is github.com/flannel-io/cni-plugin
echo "building: flannel (from flannel-io/cni-plugin)"
cd ${B}/src/import/src/github.com/containernetworking/plugins/plugins/meta/flannel
# Flannel has its own go.mod/go.sum but its dependencies (containernetworking/cni
# and containernetworking/plugins) are already available in the plugins vendor directory.
# Remove go.mod/go.sum so Go treats this as a plain package within the plugins module
# and uses the vendor directory for dependencies.
rm -f go.mod go.sum
# Build from the plugins directory context so -mod=vendor finds deps in plugins/vendor
cd ${B}/src/import/src/github.com/containernetworking/plugins
${GO} build -trimpath ${GOBUILDFLAGS} -o ${B}/plugins/bin/flannel ./plugins/meta/flannel
}
do_compile[cleandirs] = "${B}/plugins"
do_install() {
localbindir="${libexecdir}/cni/"
install -d ${D}${localbindir}
install -d ${D}/${sysconfdir}/cni/net.d
install -m 755 ${S}/src/import/cnitool/cnitool ${D}/${localbindir}
install -m 755 -D ${B}/plugins/bin/* ${D}/${localbindir}
# make cnitool more available on the path
install -d ${D}${bindir}
ln -sr ${D}/${localbindir}/cnitool ${D}/${bindir}
# Parts of k8s expect the cni binaries to be available in /opt/cni
install -d ${D}/opt/cni
ln -sf ${libexecdir}/cni/ ${D}/opt/cni/bin
}
PACKAGECONFIG ?= "ca-certs"
PACKAGECONFIG[ca-certs] = ",,,ca-certificates"
FILES:${PN} += "${libexecdir}/cni/* /opt/cni/bin"
INSANE_SKIP:${PN} += "ldflags already-stripped"
deltask compile_ptest_base
RRECOMMENDS:${PN} += "iptables iproute2"
|