]> git.proxmox.com Git - ovs.git/blob - rhel/openvswitch-fedora.spec.in
Require Python 3 and remove support for Python 2.
[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 # Enable Python 3 by specifying '--with build_python3'.
32 # This is enabled by default for versions of the distribution that
33 # have Python 3 by default (Fedora > 22).
34 %bcond_with build_python3
35 # If there is a need to automatically enable the package after installation,
36 # specify the "--with autoenable"
37 %bcond_with autoenable
38
39 # Enable PIE, bz#955181
40 %global _hardened_build 1
41
42 # some distros (e.g: RHEL-7) don't define _rundir macro yet
43 # Fedora 15 onwards uses /run as _rundir
44 %if 0%{!?_rundir:1}
45 %define _rundir /run
46 %endif
47
48 Name: openvswitch
49 Summary: Open vSwitch
50 Group: System Environment/Daemons
51 URL: http://www.openvswitch.org/
52 Version: @VERSION@
53
54 # Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the
55 # lib/sflow*.[ch] files are SISSL
56 # datapath/ is GPLv2 (although not built into any of the binary packages)
57 License: ASL 2.0 and LGPLv2+ and SISSL
58 Release: 1%{?dist}
59 Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz
60
61 BuildRequires: gcc gcc-c++
62 BuildRequires: autoconf automake libtool
63 BuildRequires: systemd-units openssl openssl-devel
64 %if 0%{?fedora} > 22 || %{with build_python3}
65 BuildRequires: python3-devel
66 %endif
67 BuildRequires: desktop-file-utils
68 BuildRequires: groff graphviz
69 BuildRequires: checkpolicy, selinux-policy-devel
70 BuildRequires: /usr/bin/sphinx-build-3
71 # make check dependencies
72 BuildRequires: procps-ng
73 %if %{with libcapng}
74 BuildRequires: libcap-ng libcap-ng-devel
75 %endif
76 %if %{with dpdk}
77 BuildRequires: libpcap-devel numactl-devel
78 BuildRequires: dpdk-devel >= 17.05.1
79 Provides: %{name}-dpdk = %{version}-%{release}
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 %if 0%{?fedora} > 22 || %{with build_python3}
113 %package -n python3-openvswitch
114 Summary: Open vSwitch python3 bindings
115 License: ASL 2.0
116 BuildArch: noarch
117 Requires: python3
118 Requires: python3-six
119 %{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}}
120
121 %description -n python3-openvswitch
122 Python bindings for the Open vSwitch database
123 %endif
124
125 %package test
126 Summary: Open vSwitch testing utilities
127 License: ASL 2.0
128 BuildArch: noarch
129
130 %description test
131 Utilities that are useful to diagnose performance and connectivity
132 issues in Open vSwitch setup.
133
134 %package devel
135 Summary: Open vSwitch OpenFlow development package (library, headers)
136 License: ASL 2.0
137
138 %description devel
139 This provides shared library, libopenswitch.so and the openvswitch header
140 files needed to build an external application.
141
142 %if 0%{?rhel} > 7 || 0%{?fedora} > 28
143 %package -n network-scripts-%{name}
144 Summary: Open vSwitch legacy network service support
145 License: ASL 2.0
146 Requires: network-scripts
147 Supplements: (%{name} and network-scripts)
148
149 %description -n network-scripts-%{name}
150 This provides the ifup and ifdown scripts for use with the legacy network
151 service.
152 %endif
153
154 %package ipsec
155 Summary: Open vSwitch IPsec tunneling support
156 License: ASL 2.0
157 Requires: openvswitch python3-openvswitch libreswan
158
159 %description ipsec
160 This package provides IPsec tunneling support for OVS tunnels.
161
162 %prep
163 %setup -q
164
165 %build
166 %configure \
167 %if %{with libcapng}
168 --enable-libcapng \
169 %else
170 --disable-libcapng \
171 %endif
172 %if %{with dpdk}
173 --with-dpdk=$(dirname %{_datadir}/dpdk/*/.config) \
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 %if 0%{?fedora} > 22 || %{with build_python3}
248 install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
249 cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
250 $RPM_BUILD_ROOT%{python3_sitelib}
251 %endif
252
253 rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
254
255 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
256
257 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db
258 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/.conf.db.~lock~
259 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
260
261 install -p -m 644 -D selinux/openvswitch-custom.pp \
262 $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
263
264 install -d $RPM_BUILD_ROOT%{_prefix}/lib/firewalld/services/
265
266 install -p -D -m 0755 \
267 rhel/usr_share_openvswitch_scripts_ovs-systemd-reload \
268 $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs-systemd-reload
269
270 # remove unpackaged files
271 rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-parse-backtrace \
272 $RPM_BUILD_ROOT%{_sbindir}/ovs-vlan-bug-workaround \
273 $RPM_BUILD_ROOT%{_mandir}/man8/ovs-vlan-bug-workaround.8
274
275 # remove ovn unpackages files
276 rm -f $RPM_BUILD_ROOT%{_bindir}/ovn*
277 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/ovn*
278 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/ovn*
279 rm -f $RPM_BUILD_ROOT%{_mandir}/man7/ovn*
280 rm -f $RPM_BUILD_ROOT%{_mandir}/man8/ovn*
281 rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/ovn*
282 rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovn*
283 rm -f $RPM_BUILD_ROOT%{_includedir}/ovn/*
284 rm -f $RPM_BUILD_ROOT%{_libdir}/libovn*
285
286 %check
287 %if %{with check}
288 touch resolv.conf
289 export OVS_RESOLV_CONF=$(pwd)/resolv.conf
290 if make check TESTSUITEFLAGS='%{_smp_mflags}' RECHECK=yes; then :;
291 else
292 cat tests/testsuite.log
293 exit 1
294 fi
295 %endif
296 %if %{with check_datapath_kernel}
297 if make check-kernel RECHECK=yes; then :;
298 else
299 cat tests/system-kmod-testsuite.log
300 exit 1
301 fi
302 %endif
303
304 %clean
305 rm -rf $RPM_BUILD_ROOT
306
307 %pre selinux-policy
308 %selinux_relabel_pre -s targeted
309
310 %preun
311 %if 0%{?systemd_preun:1}
312 %systemd_preun %{name}.service
313 %else
314 if [ $1 -eq 0 ] ; then
315 # Package removal, not upgrade
316 /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
317 /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
318 fi
319 %endif
320
321 %pre
322 %if %{with libcapng}
323 getent group openvswitch >/dev/null || groupadd -r openvswitch
324 getent passwd openvswitch >/dev/null || \
325 useradd -r -g openvswitch -d / -s /sbin/nologin \
326 -c "Open vSwitch Daemons" openvswitch
327
328 %if %{with dpdk}
329 getent group hugetlbfs >/dev/null || groupadd -r hugetlbfs
330 usermod -a -G hugetlbfs openvswitch
331 %endif
332 %endif
333
334 %if %{with autoenable}
335 if [ -x "/etc/init.d/openvswitch" ]; then
336 touch %{_tmppath}/ovs-upgrade-from-sysv
337 fi
338 %endif
339 exit 0
340
341 %post
342 %if %{with libcapng}
343 if [ $1 -eq 1 ]; then
344 sed -i 's:^#OVS_USER_ID=:OVS_USER_ID=:' /etc/sysconfig/openvswitch
345 sed -i 's:\(.*su\).*:\1 openvswitch openvswitch:' %{_sysconfdir}/logrotate.d/openvswitch
346
347 %if %{with dpdk}
348 sed -i \
349 's@OVS_USER_ID="openvswitch:openvswitch"@OVS_USER_ID="openvswitch:hugetlbfs"@'\
350 /etc/sysconfig/openvswitch
351 %endif
352
353 # In the case of upgrade, this is not needed.
354 chown -R openvswitch:openvswitch /etc/openvswitch
355 chown -R openvswitch:openvswitch /var/log/openvswitch
356 fi
357 %endif
358
359 %if 0%{?systemd_post:1}
360 # This may not enable openvswitch service or do daemon-reload.
361 %systemd_post %{name}.service
362 %else
363 # Package install, not upgrade
364 if [ $1 -eq 1 ]; then
365 /bin/systemctl daemon-reload >dev/null || :
366 fi
367 %endif
368
369 %if %{with autoenable}
370 systemctl daemon-reload
371 systemctl enable openvswitch
372 # Handle upgrades to this package from the OVS repo's rhel packages.
373 # One "restart" is needed for newer systemd files to see the old running
374 # daemons. Another "restart" (outside the package postinst script) is
375 # needed to actually run new daemons.
376 if [ -e "%{_tmppath}/ovs-upgrade-from-sysv" ]; then
377 systemctl restart openvswitch
378 rm "%{_tmppath}/ovs-upgrade-from-sysv"
379 fi
380 %endif
381
382 %post selinux-policy
383 %selinux_modules_install -s targeted %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
384
385 %postun
386 %if 0%{?systemd_postun:1}
387 %systemd_postun %{name}.service
388 %else
389 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
390 %endif
391
392 %postun selinux-policy
393 if [ $1 -eq 0 ] ; then
394 %selinux_modules_uninstall -s targeted openvswitch-custom
395 fi
396
397 %posttrans selinux-policy
398 %selinux_relabel_post -s targeted
399
400 %files selinux-policy
401 %defattr(-,root,root)
402 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
403
404 %if 0%{?fedora} > 22 || %{with build_python3}
405 %files -n python3-openvswitch
406 %{python3_sitelib}/ovs
407 %endif
408
409 %files test
410 %{_bindir}/ovs-test
411 %{_bindir}/ovs-vlan-test
412 %{_bindir}/ovs-l3ping
413 %{_bindir}/ovs-pcap
414 %{_bindir}/ovs-tcpdump
415 %{_bindir}/ovs-tcpundump
416 %{_mandir}/man8/ovs-test.8*
417 %{_mandir}/man8/ovs-vlan-test.8*
418 %{_mandir}/man8/ovs-l3ping.8*
419 %{_mandir}/man1/ovs-pcap.1*
420 %{_mandir}/man8/ovs-tcpdump.8*
421 %{_mandir}/man1/ovs-tcpundump.1*
422 %{python3_sitelib}/ovstest
423
424 %files devel
425 %{_libdir}/lib*.so
426 %{_libdir}/pkgconfig/*.pc
427 %{_includedir}/openvswitch/*
428 %{_includedir}/openflow/*
429 %exclude %{_libdir}/*.la
430
431 %if 0%{?rhel} > 7 || 0%{?fedora} > 28
432 %files -n network-scripts-%{name}
433 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
434 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
435 %endif
436
437 %files
438 %if %{with libcapng}
439 %defattr(-,openvswitch,openvswitch)
440 %else
441 %defattr(-,root,root)
442 %endif
443 %dir %{_sysconfdir}/openvswitch
444 %{_sysconfdir}/openvswitch/default.conf
445 %config %ghost %{_sysconfdir}/openvswitch/conf.db
446 %ghost %{_sysconfdir}/openvswitch/.conf.db.~lock~
447 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
448 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
449 %defattr(-,root,root)
450 %{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash
451 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
452 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
453 %{_unitdir}/openvswitch.service
454 %{_unitdir}/ovsdb-server.service
455 %{_unitdir}/ovs-vswitchd.service
456 %{_unitdir}/ovs-delete-transient-ports.service
457 %{_datadir}/openvswitch/scripts/openvswitch.init
458 %if ! (0%{?rhel} > 7 || 0%{?fedora} > 28)
459 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
460 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
461 %endif
462 %{_datadir}/openvswitch/bugtool-plugins/
463 %{_datadir}/openvswitch/scripts/ovs-bugtool-*
464 %{_datadir}/openvswitch/scripts/ovs-check-dead-ifs
465 %{_datadir}/openvswitch/scripts/ovs-lib
466 %{_datadir}/openvswitch/scripts/ovs-save
467 %{_datadir}/openvswitch/scripts/ovs-vtep
468 %{_datadir}/openvswitch/scripts/ovs-ctl
469 %{_datadir}/openvswitch/scripts/ovs-kmod-ctl
470 %{_datadir}/openvswitch/scripts/ovs-systemd-reload
471 %config %{_datadir}/openvswitch/vswitch.ovsschema
472 %config %{_datadir}/openvswitch/vtep.ovsschema
473 %{_bindir}/ovs-appctl
474 %{_bindir}/ovs-docker
475 %{_bindir}/ovs-dpctl
476 %{_bindir}/ovs-dpctl-top
477 %{_bindir}/ovs-ofctl
478 %{_bindir}/ovs-vsctl
479 %{_bindir}/ovsdb-client
480 %{_bindir}/ovsdb-tool
481 %{_bindir}/ovs-testcontroller
482 %{_bindir}/ovs-pki
483 %{_bindir}/vtep-ctl
484 %{_libdir}/lib*.so.*
485 %{_sbindir}/ovs-bugtool
486 %{_sbindir}/ovs-vswitchd
487 %{_sbindir}/ovsdb-server
488 %{_mandir}/man1/ovsdb-client.1*
489 %{_mandir}/man1/ovsdb-server.1*
490 %{_mandir}/man1/ovsdb-tool.1*
491 %{_mandir}/man5/ovsdb-server.5*
492 %{_mandir}/man5/ovs-vswitchd.conf.db.5*
493 %{_mandir}/man5/ovsdb.5*
494 %{_mandir}/man5/vtep.5*
495 %{_mandir}/man7/ovs-actions.7*
496 %{_mandir}/man7/ovs-fields.7*
497 %{_mandir}/man7/ovsdb.7*
498 %{_mandir}/man7/ovsdb-server.7*
499 %{_mandir}/man8/vtep-ctl.8*
500 %{_mandir}/man8/ovs-appctl.8*
501 %{_mandir}/man8/ovs-bugtool.8*
502 %{_mandir}/man8/ovs-ctl.8*
503 %{_mandir}/man8/ovs-dpctl.8*
504 %{_mandir}/man8/ovs-dpctl-top.8*
505 %{_mandir}/man8/ovs-kmod-ctl.8*
506 %{_mandir}/man8/ovs-ofctl.8*
507 %{_mandir}/man8/ovs-pki.8*
508 %{_mandir}/man8/ovs-vsctl.8*
509 %{_mandir}/man8/ovs-vswitchd.8*
510 %{_mandir}/man8/ovs-parse-backtrace.8*
511 %{_mandir}/man8/ovs-testcontroller.8*
512 %if %{with dpdk}
513 %{_prefix}/lib/udev/rules.d/91-vfio.rules
514 %endif
515 %doc NOTICE README.rst NEWS rhel/README.RHEL.rst
516 /var/lib/openvswitch
517 %attr(750,root,root) /var/log/openvswitch
518 %ghost %attr(755,root,root) %{_rundir}/openvswitch
519 %ghost %attr(644,root,root) %{_rundir}/openvswitch.useropts
520
521 %files ipsec
522 %{_datadir}/openvswitch/scripts/ovs-monitor-ipsec
523 %{_unitdir}/openvswitch-ipsec.service
524
525 %changelog
526 * Wed Jan 12 2011 Ralf Spenneberg <ralf@os-s.net>
527 - First build on F14