-
Notifications
You must be signed in to change notification settings - Fork 0
/
containernetworking-cni.spec
302 lines (262 loc) · 11 KB
/
containernetworking-cni.spec
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
%if 0%{?fedora}
%global with_devel 1
%global with_bundled 0
%global with_debug 1
%global with_check 0
%global with_unit_test 1
%else
%global with_devel 0
%global with_bundled 1
%global with_debug 0
%global with_check 0
%global with_unit_test 0
%endif
%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif
%if ! 0%{?gobuild:1}
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
%endif
%global provider github
%global provider_tld com
%global project containernetworking
%global repo cni
# https://github.com/containernetworking/cni
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
%global commit 0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
%global shortcommit %(c=%{commit}; echo ${c:0:7})
####################################
Name: containernetworking-cni
Version: 0.5.1
Release: 1%{?dist}
Summary: Libraries for writing CNI plugin
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
####################################
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
####################################
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
BuildRequires: go-md2man
%if ! 0%{?with_bundled}
BuildRequires: go-bindata
BuildRequires: golang(github.com/vishvananda/netlink)
BuildRequires: golang(github.com/coreos/go-systemd/activation)
BuildRequires: golang(github.com/d2g/dhcp4)
BuildRequires: golang(github.com/d2g/dhcp4client)
BuildRequires: golang(github.com/vishvananda/netlink)
BuildRequires: golang(golang.org/x/sys/unix)
BuildRequires: golang(github.com/coreos/go-iptables/iptables)
%endif
%description
The CNI (Container Network Interface) 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.
####################################
%if 0%{?with_devel}
%package devel
Summary: %{summary}
BuildArch: noarch
%if 0%{?with_check} && ! 0%{?with_bundled}
BuildRequires: golang(github.com/coreos/go-iptables/iptables)
BuildRequires: golang(github.com/vishvananda/netlink)
BuildRequires: golang(golang.org/x/sys/unix)
%endif
Requires: golang(github.com/coreos/go-iptables/iptables)
Requires: golang(github.com/vishvananda/netlink)
Requires: golang(golang.org/x/sys/unix)
Provides: golang(%{import_path}/libcni) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/invoke) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/invoke/fakes) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/ip) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/ipam) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/ns) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/skel) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/testutils) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/types) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/types/020) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/types/current) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/utils) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/utils/hwaddr) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/utils/sysctl) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/version) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/version/legacy_examples) = %{version}-%{release}
Provides: golang(%{import_path}/pkg/version/testhelpers) = %{version}-%{release}
Provides: golang(%{import_path}/plugins/ipam/host-local/backend) = %{version}-%{release}
Provides: golang(%{import_path}/plugins/ipam/host-local/backend/allocator) = %{version}-%{release}
Provides: golang(%{import_path}/plugins/ipam/host-local/backend/disk) = %{version}-%{release}
Provides: golang(%{import_path}/plugins/ipam/host-local/backend/testing) = %{version}-%{release}
Provides: golang(%{import_path}/plugins/test/noop/debug) = %{version}-%{release}
%description devel
This package contains library source intended for
building other packages which use import path with
%{import_path} prefix.
%endif
####################################
%if 0%{?with_unit_test} && 0%{?with_devel}
%package unit-test-devel
Summary: Unit tests for %{name} package
%if 0%{?with_check}
%endif
Requires: %{name}-devel = %{version}-%{release}
%if 0%{?with_check} && ! 0%{?with_bundled}
BuildRequires: golang(github.com/d2g/dhcp4)
BuildRequires: golang(github.com/onsi/ginkgo)
BuildRequires: golang(github.com/onsi/ginkgo/config)
BuildRequires: golang(github.com/onsi/ginkgo/extensions/table)
BuildRequires: golang(github.com/onsi/gomega)
BuildRequires: golang(github.com/onsi/gomega/gbytes)
BuildRequires: golang(github.com/onsi/gomega/gexec)
BuildRequires: golang(github.com/vishvananda/netlink/nl)
%endif
Requires: golang(github.com/d2g/dhcp4)
Requires: golang(github.com/onsi/ginkgo)
Requires: golang(github.com/onsi/ginkgo/config)
Requires: golang(github.com/onsi/ginkgo/extensions/table)
Requires: golang(github.com/onsi/gomega)
Requires: golang(github.com/onsi/gomega/gbytes)
Requires: golang(github.com/onsi/gomega/gexec)
Requires: golang(github.com/vishvananda/netlink/nl)
%description unit-test-devel
This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif
####################################
###################
%prep
%setup -q -n %{repo}-%{commit}
###################
%build
mkdir -p src/%{provider}.%{provider_tld}/%{project}
ln -s ../../../ src/%{import_path}
%if ! 0%{?with_bundled}
export GOPATH=$(pwd):%{gopath}
%else
export GOPATH=$(pwd):%{gopath}
%endif
###################
# TODO: Fix ./build tooling to make make this less brittle.
%gobuild -o bin/cnitool %{import_path}/cnitool
%gobuild -o bin/plugins/dhcp %{import_path}/plugins/ipam/dhcp
%gobuild -o bin/plugins/host-local %{import_path}/plugins/ipam/host-local
%gobuild -o bin/plugins/bridge %{import_path}/plugins/main/bridge
%gobuild -o bin/plugins/ipvlan %{import_path}/plugins/main/ipvlan
%gobuild -o bin/plugins/loopback %{import_path}/plugins/main/loopback
%gobuild -o bin/plugins/macvlan %{import_path}/plugins/main/macvlan
%gobuild -o bin/plugins/ptp %{import_path}/plugins/main/ptp
%gobuild -o bin/plugins/flannel %{import_path}/plugins/meta/flannel
%gobuild -o bin/plugins/tuning %{import_path}/plugins/meta/tuning
%gobuild -o bin/plugins/noop %{import_path}/plugins/test/noop
###################
%install
install -d -p %{buildroot}%{_bindir}
install -p -m 0755 bin/cnitool %{buildroot}%{_bindir}
install -d -p %{buildroot}%{_libexecdir}/cni/
install -p -m 755 -t %{buildroot}%{_libexecdir}/cni/ bin/plugins/*
# source codes for building projects
%if 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
# find all *.go but no *_test.go files and generate devel.file-list
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go" | grep -v "vendor") ; do
dirprefix=$(dirname $file)
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
while [ "$dirprefix" != "." ]; do
echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
dirprefix=$(dirname $dirprefix)
done
done
%endif
# testing files for this project
%if 0%{?with_unit_test} && 0%{?with_devel}
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
# find all *_test.go files and generate unit-test-devel.file-list
for file in $(find . -iname "*_test.go" | grep -v "vendor") ; do
dirprefix=$(dirname $file)
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
while [ "$dirprefix" != "." ]; do
echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
dirprefix=$(dirname $dirprefix)
done
done
%endif
%if 0%{?with_devel}
sort -u -o devel.file-list devel.file-list
%endif
%check
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
%if ! 0%{?with_bundled}
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
%else
# Since we aren't packaging up the vendor directory we need to link
# back to it somehow. Hack it up so that we can add the vendor
# directory from BUILD dir as a gopath to be searched when executing
# tests from the BUILDROOT dir.
ln -s ./ ./vendor/src # ./vendor/src -> ./vendor
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%endif
%if ! 0%{?gotest:1}
%global gotest go test
%endif
###################
%gotest %{import_path}/libcni
%gotest %{import_path}/pkg/invoke
%gotest %{import_path}/pkg/ip
%gotest %{import_path}/pkg/ipam
%gotest %{import_path}/pkg/ns
%gotest %{import_path}/pkg/skel
%gotest %{import_path}/pkg/types
%gotest %{import_path}/pkg/types/020
%gotest %{import_path}/pkg/types/current
%gotest %{import_path}/pkg/utils
%gotest %{import_path}/pkg/utils/hwaddr
%gotest %{import_path}/pkg/version
%gotest %{import_path}/pkg/version/legacy_examples
%gotest %{import_path}/pkg/version/testhelpers
%gotest %{import_path}/plugins/ipam/dhcp
%gotest %{import_path}/plugins/ipam/host-local
%gotest %{import_path}/plugins/ipam/host-local/backend/allocator
%gotest %{import_path}/plugins/main/bridge
%gotest %{import_path}/plugins/main/ipvlan
%gotest %{import_path}/plugins/main/loopback
%gotest %{import_path}/plugins/main/macvlan
%gotest %{import_path}/plugins/main/ptp
%gotest %{import_path}/plugins/meta/flannel
%gotest %{import_path}/plugins/test/noop
%endif
#define license tag if not already defined
%{!?_licensedir:%global license %doc}
####################################
%files
%license LICENSE
%doc *.md
%{_bindir}/cnitool
%{_libexecdir}/cni/*
####################################
%if 0%{?with_devel}
%files devel -f devel.file-list
%license LICENSE
%doc README.md CONVENTIONS.md SPEC.md CONTRIBUTING.md ROADMAP.md
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%endif
####################################
%if 0%{?with_unit_test} && 0%{?with_devel}
%files unit-test-devel -f unit-test-devel.file-list
%license LICENSE
%doc README.md CONVENTIONS.md SPEC.md CONTRIBUTING.md ROADMAP.md
%endif
####################################
%changelog
* Sun May 07 2017 Timothy St. Clair <tstclair@heptio.com> - 0.5.1-1
- Initial package