c95f0bbb9c9ef5df91e0fe15181044566013b9be
[cascardo/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 #%define kernel 2.6.40.4-5.fc15.x86_64
15
16 # If libcap-ng isn't available and there is no need for running OVS
17 # as regular user, specify the '--without libcapng'
18 %bcond_without libcapng
19 # To enable DPDK support, specify '--with dpdk' when building
20 %bcond_with dpdk
21
22 # Enable PIE, bz#955181
23 %global _hardened_build 1
24
25 # some distros (e.g: RHEL-7) don't define _rundir macro yet
26 # Fedora 15 onwards uses /run as _rundir
27 %if 0%{!?_rundir:1}
28 %define _rundir /run
29 %endif
30
31 Name: openvswitch
32 Summary: Open vSwitch
33 Group: System Environment/Daemons
34 URL: http://www.openvswitch.org/
35 Version: @VERSION@
36
37 # Nearly all of openvswitch is ASL 2.0.  The bugtool is LGPLv2+, and the
38 # lib/sflow*.[ch] files are SISSL
39 # datapath/ is GPLv2 (although not built into any of the binary packages)
40 License: ASL 2.0 and LGPLv2+ and SISSL
41 Release: 1%{?dist}
42 Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz
43
44 BuildRequires: autoconf automake libtool
45 BuildRequires: systemd-units openssl openssl-devel
46 BuildRequires: python python-twisted-core python-zope-interface PyQt4 python-six
47 BuildRequires: desktop-file-utils
48 BuildRequires: groff graphviz
49 BuildRequires: checkpolicy, selinux-policy-devel
50 # make check dependencies
51 BuildRequires: procps-ng
52 %if %{with libcapng}
53 BuildRequires: libcap-ng libcap-ng-devel
54 %endif
55 %if %{with dpdk}
56 BuildRequires: dpdk-devel >= 2.2.0
57 Provides: %{name}-dpdk = %{version}-%{release}
58 %endif
59
60 Requires: openssl iproute module-init-tools
61 #Upstream kernel commit 4f647e0a3c37b8d5086214128614a136064110c3
62 #Requires: kernel >= 3.15.0-0
63
64 Requires(post): systemd-units
65 Requires(preun): systemd-units
66 Requires(postun): systemd-units
67 Obsoletes: openvswitch-controller <= 0:2.1.0-1
68
69 %bcond_without check
70
71 %description
72 Open vSwitch provides standard network bridging functions and
73 support for the OpenFlow protocol for remote per-flow control of
74 traffic.
75
76 %package selinux-policy
77 Summary: Open vSwitch SELinux policy
78 License: ASL 2.0
79 BuildArch: noarch
80 Requires: selinux-policy-targeted
81
82 %description selinux-policy
83 Tailored Open vSwitch SELinux policy
84
85 %package -n python-openvswitch
86 Summary: Open vSwitch python bindings
87 License: ASL 2.0
88 BuildArch: noarch
89 Requires: python
90 Requires: python-six
91
92 %description -n python-openvswitch
93 Python bindings for the Open vSwitch database
94
95 %package test
96 Summary: Open vSwitch testing utilities
97 License: ASL 2.0
98 BuildArch: noarch
99 Requires: python-openvswitch = %{version}-%{release}
100 Requires: python python-twisted-core python-twisted-web
101
102 %description test
103 Utilities that are useful to diagnose performance and connectivity
104 issues in Open vSwitch setup.
105
106 %package devel
107 Summary: Open vSwitch OpenFlow development package (library, headers)
108 License: ASL 2.0
109 Provides: openvswitch-static = %{version}-%{release}
110
111 %description devel
112 This provides static library, libopenswitch.a and the openvswitch header
113 files needed to build an external application.
114
115 %package ovn
116 Summary: Open vSwitch - Open Virtual Network support
117 License: ASL 2.0
118 Requires: openvswitch
119
120 %description ovn
121 OVN, the Open Virtual Network, is a system to support virtual network
122 abstraction.  OVN complements the existing capabilities of OVS to add
123 native support for virtual network abstractions, such as virtual L2 and L3
124 overlays and security groups.
125
126
127 %prep
128 %setup -q
129
130 %build
131 %configure \
132 %if %{with libcapng}
133         --enable-libcapng \
134 %else
135         --disable-libcapng \
136 %endif
137 %if %{with dpdk}
138         --with-dpdk=$(dirname %{_datadir}/dpdk/*/.config) \
139 %endif
140         --enable-ssl \
141         --with-pkidir=%{_sharedstatedir}/openvswitch/pki
142
143 make %{?_smp_mflags}
144 cd selinux
145 make -f %{_datadir}/selinux/devel/Makefile
146
147 %install
148 rm -rf $RPM_BUILD_ROOT
149 make install DESTDIR=$RPM_BUILD_ROOT
150
151 install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
152
153 install -p -D -m 0644 \
154         rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
155         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
156 for service in openvswitch openvswitch-nonetwork \
157                 ovn-controller ovn-controller-vtep ovn-northd; do
158         install -p -D -m 0644 \
159                         rhel/usr_lib_systemd_system_${service}.service \
160                         $RPM_BUILD_ROOT%{_unitdir}/${service}.service
161 done
162 install -m 0755 rhel/etc_init.d_openvswitch \
163         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
164
165 install -p -D -m 0644 rhel/etc_logrotate.d_openvswitch \
166         $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/openvswitch
167
168 install -m 0644 vswitchd/vswitch.ovsschema \
169         $RPM_BUILD_ROOT/%{_datadir}/openvswitch/vswitch.ovsschema
170
171 install -d -m 0755 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/
172 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \
173         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
174 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
175         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
176
177 install -d -m 0755 $RPM_BUILD_ROOT%{python_sitelib}
178 mv $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
179    $RPM_BUILD_ROOT%{python_sitelib}
180 rmdir $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
181
182 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
183
184 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db
185 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
186
187 install -p -m 644 -D selinux/openvswitch-custom.pp \
188         $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
189
190 # remove unpackaged files
191 rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-parse-backtrace \
192         $RPM_BUILD_ROOT%{_bindir}/ovs-pcap \
193         $RPM_BUILD_ROOT%{_bindir}/ovs-tcpundump \
194         $RPM_BUILD_ROOT%{_sbindir}/ovs-vlan-bug-workaround \
195         $RPM_BUILD_ROOT%{_mandir}/man1/ovs-pcap.1 \
196         $RPM_BUILD_ROOT%{_mandir}/man1/ovs-tcpundump.1 \
197         $RPM_BUILD_ROOT%{_mandir}/man8/ovs-vlan-bug-workaround.8 \
198         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs-save
199
200 %check
201 %if %{with check}
202     if make check TESTSUITEFLAGS='%{_smp_mflags}' RECHECK=yes; then :;
203     else
204         cat tests/testsuite.log
205         exit 1
206     fi
207 %endif
208
209 %clean
210 rm -rf $RPM_BUILD_ROOT
211
212 %preun
213 %if 0%{?systemd_preun:1}
214     %systemd_preun %{name}.service
215 %else
216     if [ $1 -eq 0 ] ; then
217     # Package removal, not upgrade
218         /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
219         /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
220     fi
221 %endif
222
223 %preun ovn
224 %if 0%{?systemd_preun:1}
225     %systemd_preun ovn-controller.service
226     %systemd_preun ovn-controller-vtep.service
227     %systemd_preun ovn-northd.service
228 %else
229     if [ $1 -eq 0 ] ; then
230     # Package removal, not upgrade
231         /bin/systemctl --no-reload disable ovn-controller.service >/dev/null 2>&1 || :
232         /bin/systemctl stop ovn-controller.service >/dev/null 2>&1 || :
233         /bin/systemctl --no-reload disable ovn-controller-vtep.service >/dev/null 2>&1 || :
234         /bin/systemctl stop ovn-controller-vtep.service >/dev/null 2>&1 || :
235         /bin/systemctl --no-reload disable ovn-northd.service >/dev/null 2>&1 || :
236         /bin/systemctl stop ovn-northd.service >/dev/null 2>&1 || :
237     fi
238 %endif
239
240 %post
241 %if 0%{?systemd_post:1}
242     %systemd_post %{name}.service
243 %else
244     # Package install, not upgrade
245     if [ $1 -eq 1 ]; then
246         /bin/systemctl daemon-reload >dev/null || :
247     fi
248 %endif
249
250 %post ovn
251 %if 0%{?systemd_post:1}
252     %systemd_post ovn-controller.service
253     %systemd_post ovn-controller-vtep.service
254     %systemd_post ovn-northd.service
255 %else
256     # Package install, not upgrade
257     if [ $1 -eq 1 ]; then
258         /bin/systemctl daemon-reload >dev/null || :
259     fi
260 %endif
261
262 %post selinux-policy
263 /usr/sbin/semodule -i %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp &> /dev/null || :
264
265 %postun
266 %if 0%{?systemd_postun_with_restart:1}
267     %systemd_postun_with_restart %{name}.service
268 %else
269     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
270     if [ "$1" -ge "1" ] ; then
271     # Package upgrade, not uninstall
272         /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
273     fi
274 %endif
275
276 %postun ovn
277 %if 0%{?systemd_postun_with_restart:1}
278     %systemd_postun_with_restart ovn-controller.service
279     %systemd_postun_with_restart ovn-controller-vtep.service
280     %systemd_postun_with_restart ovn-northd.service
281 %else
282     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
283     if [ "$1" -ge "1" ] ; then
284     # Package upgrade, not uninstall
285         /bin/systemctl try-restart ovn-controller.service >/dev/null 2>&1 || :
286         /bin/systemctl try-restart ovn-controller-vtep.service >/dev/null 2>&1 || :
287         /bin/systemctl try-restart ovn-northd.service >/dev/null 2>&1 || :
288     fi
289 %endif
290
291 %postun selinux-policy
292 if [ $1 -eq 0 ] ; then
293   /usr/sbin/semodule -r openvswitch-custom &> /dev/null || :
294 fi
295
296 %files selinux-policy
297 %defattr(-,root,root)
298 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
299
300 %files -n python-openvswitch
301 %{python_sitelib}/ovs
302 %doc COPYING
303
304 %files test
305 %{_bindir}/ovs-test
306 %{_bindir}/ovs-vlan-test
307 %{_bindir}/ovs-l3ping
308 %{_mandir}/man8/ovs-test.8*
309 %{_mandir}/man8/ovs-vlan-test.8*
310 %{_mandir}/man8/ovs-l3ping.8*
311 %{python_sitelib}/ovstest
312
313 %files devel
314 %{_libdir}/*.a
315 %{_libdir}/*.la
316 %{_libdir}/pkgconfig/*.pc
317 %{_includedir}/openvswitch/*
318 %{_includedir}/openflow/*
319
320 %files
321 %defattr(-,root,root)
322 %{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash
323 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
324 %dir %{_sysconfdir}/openvswitch
325 %config %ghost %{_sysconfdir}/openvswitch/conf.db
326 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
327 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
328 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
329 %{_unitdir}/openvswitch.service
330 %{_unitdir}/openvswitch-nonetwork.service
331 %{_datadir}/openvswitch/scripts/openvswitch.init
332 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
333 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
334 %{_datadir}/openvswitch/bugtool-plugins/
335 %{_datadir}/openvswitch/scripts/ovs-bugtool-*
336 %{_datadir}/openvswitch/scripts/ovs-check-dead-ifs
337 %{_datadir}/openvswitch/scripts/ovs-lib
338 %{_datadir}/openvswitch/scripts/ovs-vtep
339 %{_datadir}/openvswitch/scripts/ovs-ctl
340 %config %{_datadir}/openvswitch/vswitch.ovsschema
341 %config %{_datadir}/openvswitch/vtep.ovsschema
342 %{_bindir}/ovs-appctl
343 %{_bindir}/ovs-docker
344 %{_bindir}/ovs-dpctl
345 %{_bindir}/ovs-dpctl-top
346 %{_bindir}/ovs-ofctl
347 %{_bindir}/ovs-vsctl
348 %{_bindir}/ovsdb-client
349 %{_bindir}/ovsdb-tool
350 %{_bindir}/ovs-testcontroller
351 %{_bindir}/ovs-pki
352 %{_bindir}/vtep-ctl
353 %{_sbindir}/ovs-bugtool
354 %{_sbindir}/ovs-vswitchd
355 %{_sbindir}/ovsdb-server
356 %{_mandir}/man1/ovsdb-client.1*
357 %{_mandir}/man1/ovsdb-server.1*
358 %{_mandir}/man1/ovsdb-tool.1*
359 %{_mandir}/man5/ovs-vswitchd.conf.db.5*
360 %{_mandir}/man5/vtep.5*
361 %{_mandir}/man8/vtep-ctl.8*
362 %{_mandir}/man8/ovs-appctl.8*
363 %{_mandir}/man8/ovs-bugtool.8*
364 %{_mandir}/man8/ovs-ctl.8*
365 %{_mandir}/man8/ovs-dpctl.8*
366 %{_mandir}/man8/ovs-dpctl-top.8*
367 %{_mandir}/man8/ovs-ofctl.8*
368 %{_mandir}/man8/ovs-pki.8*
369 %{_mandir}/man8/ovs-vsctl.8*
370 %{_mandir}/man8/ovs-vswitchd.8*
371 %{_mandir}/man8/ovs-parse-backtrace.8*
372 %{_mandir}/man8/ovs-testcontroller.8*
373 %doc COPYING DESIGN.md INSTALL.SSL.md NOTICE README.md WHY-OVS.md
374 %doc FAQ.md NEWS INSTALL.DPDK.md rhel/README.RHEL
375 /var/lib/openvswitch
376 /var/log/openvswitch
377 %ghost %attr(755,root,root) %{_rundir}/openvswitch
378
379 %files ovn
380 %{_bindir}/ovn-controller
381 %{_bindir}/ovn-controller-vtep
382 %{_bindir}/ovn-docker-overlay-driver
383 %{_bindir}/ovn-docker-underlay-driver
384 %{_bindir}/ovn-nbctl
385 %{_bindir}/ovn-northd
386 %{_bindir}/ovn-sbctl
387 %{_datadir}/openvswitch/scripts/ovn-ctl
388 %{_datadir}/openvswitch/scripts/ovn-bugtool-nbctl-show
389 %{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-lflow-list
390 %{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-show
391 %{_mandir}/man8/ovs-testcontroller.8*
392 %{_mandir}/man5/ovn-nb.5*
393 %{_mandir}/man5/ovn-sb.5*
394 %{_mandir}/man7/ovn-architecture.7*
395 %{_mandir}/man8/ovn-controller.8*
396 %{_mandir}/man8/ovn-controller-vtep.8*
397 %{_mandir}/man8/ovn-ctl.8*
398 %{_mandir}/man8/ovn-nbctl.8*
399 %{_mandir}/man8/ovn-northd.8*
400 %{_mandir}/man8/ovn-sbctl.8*
401 %config %{_datadir}/openvswitch/ovn-nb.ovsschema
402 %config %{_datadir}/openvswitch/ovn-sb.ovsschema
403 %{_unitdir}/ovn-controller.service
404 %{_unitdir}/ovn-controller-vtep.service
405 %{_unitdir}/ovn-northd.service
406
407 %changelog
408 * Wed Jan 12 2011 Ralf Spenneberg <ralf@os-s.net>
409 - First build on F14