]> git.proxmox.com Git - mirror_ovs.git/blob - rhel/openvswitch-fedora.spec.in
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / rhel / openvswitch-fedora.spec.in
1 # Spec file for Open vSwitch.
2
3 # Copyright (C) 2009, 2010, 2013, 2014, 2015, 2016 Nicira Networks, Inc.
4 #
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved. This file is offered as-is,
8 # without warranty of any kind.
9 #
10 # If tests have to be skipped while building, specify the '--without check'
11 # option. For example:
12 # rpmbuild -bb --without check rhel/openvswitch-fedora.spec
13 #
14 # Support for executing kernel data path tests under rpmbuild is
15 # provided, however this is intended for use only in test environments
16 # and should not be used otherwise (these tests require root privileges).
17 # These tests can be executed, for example, via:
18 # rpmbuild -rb --with check_datapath_kernel openvswitch-fedora.src.rpm
19 #
20 # These tests will use the currently installed OVS kernel modules, when
21 # testing out of tree kernel modules the appropriate openvswitch-kmod
22 # package should be installed first.
23
24 #%define kernel 2.6.40.4-5.fc15.x86_64
25
26 # If libcap-ng isn't available and there is no need for running OVS
27 # as regular user, specify the '--without libcapng'
28 %bcond_without libcapng
29 # To enable DPDK support, specify '--with dpdk' when building
30 %bcond_with dpdk
31 # To enable AF_XDP support, specify '--with afxdp' when building
32 %bcond_with afxdp
33
34 # If there is a need to automatically enable the package after installation,
35 # specify the "--with autoenable"
36 %bcond_with autoenable
37
38 # Enable PIE, bz#955181
39 %global _hardened_build 1
40
41 # some distros (e.g: RHEL-7) don't define _rundir macro yet
42 # Fedora 15 onwards uses /run as _rundir
43 %if 0%{!?_rundir:1}
44 %define _rundir /run
45 %endif
46
47 Name: openvswitch
48 Summary: Open vSwitch
49 Group: System Environment/Daemons
50 URL: http://www.openvswitch.org/
51 Version: @VERSION@
52
53 # Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the
54 # lib/sflow*.[ch] files are SISSL
55 # datapath/ is GPLv2 (although not built into any of the binary packages)
56 License: ASL 2.0 and LGPLv2+ and SISSL
57 Release: 1%{?dist}
58 Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz
59
60 BuildRequires: gcc gcc-c++
61 BuildRequires: autoconf automake libtool
62 BuildRequires: systemd-units openssl openssl-devel
63 BuildRequires: python3-devel
64 BuildRequires: desktop-file-utils
65 BuildRequires: groff graphviz
66 BuildRequires: checkpolicy, selinux-policy-devel
67 BuildRequires: /usr/bin/sphinx-build-3
68 # make check dependencies
69 BuildRequires: procps-ng
70 %if %{with libcapng}
71 BuildRequires: libcap-ng libcap-ng-devel
72 %endif
73 %if %{with dpdk}
74 BuildRequires: libpcap-devel numactl-devel
75 BuildRequires: dpdk-devel >= 20.11
76 Provides: %{name}-dpdk = %{version}-%{release}
77 %endif
78 %if %{with afxdp}
79 BuildRequires: libbpf-devel numactl-devel
80 %endif
81 BuildRequires: unbound unbound-devel
82
83 Requires: openssl hostname iproute module-init-tools unbound
84 #Upstream kernel commit 4f647e0a3c37b8d5086214128614a136064110c3
85 #Requires: kernel >= 3.15.0-0
86
87 Requires(pre): shadow-utils
88 Requires(post): /bin/sed
89 Requires(post): systemd-units
90 Requires(preun): systemd-units
91 Requires(postun): systemd-units
92 Obsoletes: openvswitch-controller <= 0:2.1.0-1
93
94 # to skip running checks, pass --without check
95 %bcond_without check
96 %bcond_with check_datapath_kernel
97
98 %description
99 Open vSwitch provides standard network bridging functions and
100 support for the OpenFlow protocol for remote per-flow control of
101 traffic.
102
103 %package selinux-policy
104 Summary: Open vSwitch SELinux policy
105 License: ASL 2.0
106 BuildArch: noarch
107 Requires: selinux-policy-targeted
108
109 %description selinux-policy
110 Tailored Open vSwitch SELinux policy
111
112 %package -n python3-openvswitch
113 Summary: Open vSwitch python3 bindings
114 License: ASL 2.0
115 BuildArch: noarch
116 Requires: python3
117 %{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}}
118
119 %description -n python3-openvswitch
120 Python bindings for the Open vSwitch database
121
122 %package test
123 Summary: Open vSwitch testing utilities
124 License: ASL 2.0
125 BuildArch: noarch
126
127 %description test
128 Utilities that are useful to diagnose performance and connectivity
129 issues in Open vSwitch setup.
130
131 %package devel
132 Summary: Open vSwitch OpenFlow development package (library, headers)
133 License: ASL 2.0
134
135 %description devel
136 This provides shared library, libopenswitch.so and the openvswitch header
137 files needed to build an external application.
138
139 %if 0%{?rhel} > 7 || 0%{?fedora} > 28
140 %package -n network-scripts-%{name}
141 Summary: Open vSwitch legacy network service support
142 License: ASL 2.0
143 Requires: network-scripts
144 Supplements: (%{name} and network-scripts)
145
146 %description -n network-scripts-%{name}
147 This provides the ifup and ifdown scripts for use with the legacy network
148 service.
149 %endif
150
151 %package ipsec
152 Summary: Open vSwitch IPsec tunneling support
153 License: ASL 2.0
154 Requires: openvswitch python3-openvswitch libreswan
155
156 %description ipsec
157 This package provides IPsec tunneling support for OVS tunnels.
158
159 %prep
160 %setup -q
161
162 %build
163 %configure \
164 %if %{with libcapng}
165 --enable-libcapng \
166 %else
167 --disable-libcapng \
168 %endif
169 %if %{with dpdk}
170 --with-dpdk=shared \
171 %endif
172 %if %{with afxdp}
173 --enable-afxdp \
174 %endif
175 --enable-ssl \
176 --disable-static \
177 --enable-shared \
178 --with-pkidir=%{_sharedstatedir}/openvswitch/pki \
179 PYTHON3=%{__python3}
180
181 build-aux/dpdkstrip.py \
182 %if %{with dpdk}
183 --dpdk \
184 %else
185 --nodpdk \
186 %endif
187 < rhel/usr_lib_systemd_system_ovs-vswitchd.service.in \
188 > rhel/usr_lib_systemd_system_ovs-vswitchd.service
189
190 make %{?_smp_mflags}
191 make selinux-policy
192
193 %install
194 rm -rf $RPM_BUILD_ROOT
195 make install DESTDIR=$RPM_BUILD_ROOT
196
197 install -d -m 0755 $RPM_BUILD_ROOT%{_rundir}/openvswitch
198 install -d -m 0750 $RPM_BUILD_ROOT%{_localstatedir}/log/openvswitch
199 install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
200 copy_headers() {
201 src=$1
202 dst=$RPM_BUILD_ROOT/$2
203 install -d -m 0755 $dst
204 install -m 0644 $src/*.h $dst
205 }
206 copy_headers include %{_includedir}/openvswitch
207 copy_headers include/openflow %{_includedir}/openvswitch/openflow
208 copy_headers include/openvswitch %{_includedir}/openvswitch/openvswitch
209 copy_headers include/sparse %{_includedir}/openvswitch/sparse
210 copy_headers include/sparse/arpa %{_includedir}/openvswitch/sparse/arpa
211 copy_headers include/sparse/netinet %{_includedir}/openvswitch/sparse/netinet
212 copy_headers include/sparse/sys %{_includedir}/openvswitch/sparse/sys
213 copy_headers lib %{_includedir}/openvswitch/lib
214
215 %if %{with dpdk}
216 install -p -D -m 0644 rhel/usr_lib_udev_rules.d_91-vfio.rules \
217 $RPM_BUILD_ROOT%{_prefix}/lib/udev/rules.d/91-vfio.rules
218 %endif
219
220 install -p -D -m 0644 \
221 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
222 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
223 for service in openvswitch ovsdb-server ovs-vswitchd ovs-delete-transient-ports \
224 openvswitch-ipsec; do
225 install -p -D -m 0644 \
226 rhel/usr_lib_systemd_system_${service}.service \
227 $RPM_BUILD_ROOT%{_unitdir}/${service}.service
228 done
229 install -m 0755 rhel/etc_init.d_openvswitch \
230 $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
231
232 install -p -D -m 0644 rhel/etc_openvswitch_default.conf \
233 $RPM_BUILD_ROOT/%{_sysconfdir}/openvswitch/default.conf
234
235 install -p -D -m 0644 rhel/etc_logrotate.d_openvswitch \
236 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/openvswitch
237
238 install -m 0644 vswitchd/vswitch.ovsschema \
239 $RPM_BUILD_ROOT/%{_datadir}/openvswitch/vswitch.ovsschema
240
241 install -d -m 0755 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/
242 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \
243 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
244 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
245 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
246
247 install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
248 cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
249 $RPM_BUILD_ROOT%{python3_sitelib}
250
251 rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
252
253 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
254
255 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db
256 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/.conf.db.~lock~
257 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
258
259 install -p -m 644 -D selinux/openvswitch-custom.pp \
260 $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
261
262 install -d $RPM_BUILD_ROOT%{_prefix}/lib/firewalld/services/
263
264 install -p -D -m 0755 \
265 rhel/usr_share_openvswitch_scripts_ovs-systemd-reload \
266 $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs-systemd-reload
267
268 # remove unpackaged files
269 rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-parse-backtrace
270
271 %check
272 %if %{with check}
273 touch resolv.conf
274 export OVS_RESOLV_CONF=$(pwd)/resolv.conf
275 if make check TESTSUITEFLAGS='%{_smp_mflags}' RECHECK=yes; then :;
276 else
277 cat tests/testsuite.log
278 exit 1
279 fi
280 %endif
281 %if %{with check_datapath_kernel}
282 if make check-kernel RECHECK=yes; then :;
283 else
284 cat tests/system-kmod-testsuite.log
285 exit 1
286 fi
287 %endif
288
289 %clean
290 rm -rf $RPM_BUILD_ROOT
291
292 %pre selinux-policy
293 %selinux_relabel_pre -s targeted
294
295 %preun
296 %if 0%{?systemd_preun:1}
297 %systemd_preun %{name}.service
298 %else
299 if [ $1 -eq 0 ] ; then
300 # Package removal, not upgrade
301 /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
302 /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
303 fi
304 %endif
305
306 %pre
307 %if %{with libcapng}
308 getent group openvswitch >/dev/null || groupadd -r openvswitch
309 getent passwd openvswitch >/dev/null || \
310 useradd -r -g openvswitch -d / -s /sbin/nologin \
311 -c "Open vSwitch Daemons" openvswitch
312
313 %if %{with dpdk}
314 getent group hugetlbfs >/dev/null || groupadd -r hugetlbfs
315 usermod -a -G hugetlbfs openvswitch
316 %endif
317 %endif
318
319 %if %{with autoenable}
320 if [ -x "/etc/init.d/openvswitch" ]; then
321 touch %{_tmppath}/ovs-upgrade-from-sysv
322 fi
323 %endif
324 exit 0
325
326 %post
327 %if %{with libcapng}
328 if [ $1 -eq 1 ]; then
329 %if %{with dpdk}
330 %define gname hugetlbfs
331 %else
332 %define gname openvswitch
333 %endif
334 sed -i \
335 's@^#OVS_USER_ID="openvswitch:openvswitch"@OVS_USER_ID="openvswitch:%{gname}"@'\
336 %{_sysconfdir}/sysconfig/openvswitch
337 sed -i 's:\(.*su\).*:\1 openvswitch %{gname}:' %{_sysconfdir}/logrotate.d/openvswitch
338
339 # In the case of upgrade, this is not needed
340 chown -R openvswitch:openvswitch %{_sysconfdir}/openvswitch
341 chown -R openvswitch:%{gname} %{_localstatedir}/log/openvswitch
342 fi
343 %endif
344
345 %if 0%{?systemd_post:1}
346 # This may not enable openvswitch service or do daemon-reload.
347 %systemd_post %{name}.service
348 %else
349 # Package install, not upgrade
350 if [ $1 -eq 1 ]; then
351 /bin/systemctl daemon-reload >/dev/null || :
352 fi
353 %endif
354
355 %if %{with autoenable}
356 systemctl daemon-reload
357 systemctl enable openvswitch
358 # Handle upgrades to this package from the OVS repo's rhel packages.
359 # One "restart" is needed for newer systemd files to see the old running
360 # daemons. Another "restart" (outside the package postinst script) is
361 # needed to actually run new daemons.
362 if [ -e "%{_tmppath}/ovs-upgrade-from-sysv" ]; then
363 systemctl restart openvswitch
364 rm "%{_tmppath}/ovs-upgrade-from-sysv"
365 fi
366 %endif
367
368 %post selinux-policy
369 %selinux_modules_install -s targeted %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
370
371 %postun
372 %if 0%{?systemd_postun:1}
373 %systemd_postun %{name}.service
374 %else
375 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
376 %endif
377
378 %postun selinux-policy
379 if [ $1 -eq 0 ] ; then
380 %selinux_modules_uninstall -s targeted openvswitch-custom
381 fi
382
383 %posttrans selinux-policy
384 %selinux_relabel_post -s targeted
385
386 %files selinux-policy
387 %defattr(-,root,root)
388 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
389
390 %files -n python3-openvswitch
391 %{python3_sitelib}/ovs
392
393 %files test
394 %{_bindir}/ovs-test
395 %{_bindir}/ovs-vlan-test
396 %{_bindir}/ovs-l3ping
397 %{_bindir}/ovs-pcap
398 %{_bindir}/ovs-tcpdump
399 %{_bindir}/ovs-tcpundump
400 %{_mandir}/man8/ovs-test.8*
401 %{_mandir}/man8/ovs-vlan-test.8*
402 %{_mandir}/man8/ovs-l3ping.8*
403 %{_mandir}/man1/ovs-pcap.1*
404 %{_mandir}/man8/ovs-tcpdump.8*
405 %{_mandir}/man1/ovs-tcpundump.1*
406 %{python3_sitelib}/ovstest
407
408 %files devel
409 %{_libdir}/lib*.so
410 %{_libdir}/pkgconfig/*.pc
411 %{_includedir}/openvswitch/*
412 %{_includedir}/openflow/*
413 %exclude %{_libdir}/*.la
414 %exclude %{_libdir}/*.a
415
416 %if 0%{?rhel} > 7 || 0%{?fedora} > 28
417 %files -n network-scripts-%{name}
418 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
419 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
420 %endif
421
422 %files
423 %if %{with libcapng}
424 %defattr(-,openvswitch,openvswitch)
425 %else
426 %defattr(-,root,root)
427 %endif
428 %dir %{_sysconfdir}/openvswitch
429 %{_sysconfdir}/openvswitch/default.conf
430 %config %ghost %{_sysconfdir}/openvswitch/conf.db
431 %ghost %{_sysconfdir}/openvswitch/.conf.db.~lock~
432 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
433 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
434 %defattr(-,root,root)
435 %{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash
436 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
437 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
438 %{_unitdir}/openvswitch.service
439 %{_unitdir}/ovsdb-server.service
440 %{_unitdir}/ovs-vswitchd.service
441 %{_unitdir}/ovs-delete-transient-ports.service
442 %{_datadir}/openvswitch/scripts/openvswitch.init
443 %if ! (0%{?rhel} > 7 || 0%{?fedora} > 28)
444 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
445 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
446 %endif
447 %{_datadir}/openvswitch/bugtool-plugins/
448 %{_datadir}/openvswitch/scripts/ovs-bugtool-*
449 %{_datadir}/openvswitch/scripts/ovs-check-dead-ifs
450 %{_datadir}/openvswitch/scripts/ovs-lib
451 %{_datadir}/openvswitch/scripts/ovs-save
452 %{_datadir}/openvswitch/scripts/ovs-vtep
453 %{_datadir}/openvswitch/scripts/ovs-ctl
454 %{_datadir}/openvswitch/scripts/ovs-kmod-ctl
455 %{_datadir}/openvswitch/scripts/ovs-systemd-reload
456 %config %{_datadir}/openvswitch/vswitch.ovsschema
457 %config %{_datadir}/openvswitch/vtep.ovsschema
458 %{_bindir}/ovs-appctl
459 %{_bindir}/ovs-docker
460 %{_bindir}/ovs-dpctl
461 %{_bindir}/ovs-dpctl-top
462 %{_bindir}/ovs-ofctl
463 %{_bindir}/ovs-vsctl
464 %{_bindir}/ovsdb-client
465 %{_bindir}/ovsdb-tool
466 %{_bindir}/ovs-testcontroller
467 %{_bindir}/ovs-pki
468 %{_bindir}/vtep-ctl
469 %{_libdir}/lib*.so.*
470 %{_sbindir}/ovs-bugtool
471 %{_sbindir}/ovs-vswitchd
472 %{_sbindir}/ovsdb-server
473 %{_mandir}/man1/ovsdb-client.1*
474 %{_mandir}/man1/ovsdb-server.1*
475 %{_mandir}/man1/ovsdb-tool.1*
476 %{_mandir}/man5/ovsdb-server.5*
477 %{_mandir}/man5/ovs-vswitchd.conf.db.5*
478 %{_mandir}/man5/ovsdb.5*
479 %{_mandir}/man5/vtep.5*
480 %{_mandir}/man7/ovs-actions.7*
481 %{_mandir}/man7/ovs-fields.7*
482 %{_mandir}/man7/ovsdb.7*
483 %{_mandir}/man7/ovsdb-server.7*
484 %{_mandir}/man8/vtep-ctl.8*
485 %{_mandir}/man8/ovs-appctl.8*
486 %{_mandir}/man8/ovs-bugtool.8*
487 %{_mandir}/man8/ovs-ctl.8*
488 %{_mandir}/man8/ovs-dpctl.8*
489 %{_mandir}/man8/ovs-dpctl-top.8*
490 %{_mandir}/man8/ovs-kmod-ctl.8*
491 %{_mandir}/man8/ovs-ofctl.8*
492 %{_mandir}/man8/ovs-pki.8*
493 %{_mandir}/man8/ovs-vsctl.8*
494 %{_mandir}/man8/ovs-vswitchd.8*
495 %{_mandir}/man8/ovs-parse-backtrace.8*
496 %{_mandir}/man8/ovs-testcontroller.8*
497 %if %{with dpdk}
498 %{_prefix}/lib/udev/rules.d/91-vfio.rules
499 %endif
500 %doc NOTICE README.rst NEWS rhel/README.RHEL.rst
501 /var/lib/openvswitch
502 %attr(750,root,root) /var/log/openvswitch
503 %ghost %attr(755,root,root) %{_rundir}/openvswitch
504 %ghost %attr(644,root,root) %{_rundir}/openvswitch.useropts
505
506 %files ipsec
507 %{_datadir}/openvswitch/scripts/ovs-monitor-ipsec
508 %{_unitdir}/openvswitch-ipsec.service
509
510 %changelog
511 * Wed Jan 12 2011 Ralf Spenneberg <ralf@os-s.net>
512 - First build on F14