rhel: provide our own SELinux custom policy package
[cascardo/ovs.git] / rhel / openvswitch-fedora.spec.in
1 # Spec file for Open vSwitch.
2
3 # Copyright (C) 2009, 2010, 2013, 2014, 2015 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
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
91 %description -n python-openvswitch
92 Python bindings for the Open vSwitch database
93
94 %package test
95 Summary: Open vSwitch testing utilities
96 License: ASL 2.0
97 BuildArch: noarch
98 Requires: python-openvswitch = %{version}-%{release}
99 Requires: python python-twisted-core python-twisted-web
100
101 %description test
102 Utilities that are useful to diagnose performance and connectivity
103 issues in Open vSwitch setup.
104
105 %package devel
106 Summary: Open vSwitch OpenFlow development package (library, headers)
107 License: ASL 2.0
108 Provides: openvswitch-static = %{version}-%{release}
109
110 %description devel
111 This provides static library, libopenswitch.a and the openvswitch header
112 files needed to build an external application.
113
114 %package ovn
115 Summary: Open vSwitch - Open Virtual Network support
116 License: ASL 2.0
117 Requires: openvswitch
118
119 %description ovn
120 OVN, the Open Virtual Network, is a system to support virtual network
121 abstraction.  OVN complements the existing capabilities of OVS to add
122 native support for virtual network abstractions, such as virtual L2 and L3
123 overlays and security groups.
124
125
126 %prep
127 %setup -q
128
129 %build
130 %configure \
131 %if %{with libcapng}
132         --enable-libcapng \
133 %else
134         --disable-libcapng \
135 %endif
136 %if %{with dpdk}
137         --with-dpdk=$(dirname %{_datadir}/dpdk/*/.config) \
138 %endif
139         --enable-ssl \
140         --with-pkidir=%{_sharedstatedir}/openvswitch/pki
141
142 make %{?_smp_mflags}
143 cd selinux
144 make -f %{_datadir}/selinux/devel/Makefile
145
146 %install
147 rm -rf $RPM_BUILD_ROOT
148 make install DESTDIR=$RPM_BUILD_ROOT
149
150 install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch
151
152 install -p -D -m 0644 \
153         rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template \
154         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/openvswitch
155 for service in openvswitch openvswitch-nonetwork \
156                 ovn-controller ovn-controller-vtep ovn-northd; do
157         install -p -D -m 0644 \
158                         rhel/usr_lib_systemd_system_${service}.service \
159                         $RPM_BUILD_ROOT%{_unitdir}/${service}.service
160 done
161 install -m 0755 rhel/etc_init.d_openvswitch \
162         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/openvswitch.init
163
164 install -p -D -m 0644 rhel/etc_logrotate.d_openvswitch \
165         $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/openvswitch
166
167 install -m 0644 vswitchd/vswitch.ovsschema \
168         $RPM_BUILD_ROOT/%{_datadir}/openvswitch/vswitch.ovsschema
169
170 install -d -m 0755 $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/
171 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifdown-ovs \
172         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
173 install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
174         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
175
176 install -d -m 0755 $RPM_BUILD_ROOT%{python_sitelib}
177 mv $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
178    $RPM_BUILD_ROOT%{python_sitelib}
179 rmdir $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
180
181 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
182
183 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/conf.db
184 touch $RPM_BUILD_ROOT%{_sysconfdir}/openvswitch/system-id.conf
185
186 install -p -m 644 -D selinux/openvswitch-custom.pp \
187         $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
188
189 # remove unpackaged files
190 rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-benchmark \
191         $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-benchmark.1 \
196         $RPM_BUILD_ROOT%{_mandir}/man1/ovs-pcap.1 \
197         $RPM_BUILD_ROOT%{_mandir}/man1/ovs-tcpundump.1 \
198         $RPM_BUILD_ROOT%{_mandir}/man8/ovs-vlan-bug-workaround.8 \
199         $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs-save
200
201 %check
202 %if %{with check}
203     if make check TESTSUITEFLAGS='%{_smp_mflags}' ||
204        make check TESTSUITEFLAGS='--recheck'; then :;
205     else
206         cat tests/testsuite.log
207         exit 1
208     fi
209 %endif
210
211 %clean
212 rm -rf $RPM_BUILD_ROOT
213
214 %preun
215 %if 0%{?systemd_preun:1}
216     %systemd_preun %{name}.service
217 %else
218     if [ $1 -eq 0 ] ; then
219     # Package removal, not upgrade
220         /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || :
221         /bin/systemctl stop %{name}.service >/dev/null 2>&1 || :
222     fi
223 %endif
224
225 %preun ovn
226 %if 0%{?systemd_preun:1}
227     %systemd_preun ovn-controller.service
228     %systemd_preun ovn-controller-vtep.service
229     %systemd_preun ovn-northd.service
230 %else
231     if [ $1 -eq 0 ] ; then
232     # Package removal, not upgrade
233         /bin/systemctl --no-reload disable ovn-controller.service >/dev/null 2>&1 || :
234         /bin/systemctl stop ovn-controller.service >/dev/null 2>&1 || :
235         /bin/systemctl --no-reload disable ovn-controller-vtep.service >/dev/null 2>&1 || :
236         /bin/systemctl stop ovn-controller-vtep.service >/dev/null 2>&1 || :
237         /bin/systemctl --no-reload disable ovn-northd.service >/dev/null 2>&1 || :
238         /bin/systemctl stop ovn-northd.service >/dev/null 2>&1 || :
239     fi
240 %endif
241
242 %post
243 %if 0%{?systemd_post:1}
244     %systemd_post %{name}.service
245 %else
246     # Package install, not upgrade
247     if [ $1 -eq 1 ]; then
248         /bin/systemctl daemon-reload >dev/null || :
249     fi
250 %endif
251
252 %post ovn
253 %if 0%{?systemd_post:1}
254     %systemd_post ovn-controller.service
255     %systemd_post ovn-controller-vtep.service
256     %systemd_post ovn-northd.service
257 %else
258     # Package install, not upgrade
259     if [ $1 -eq 1 ]; then
260         /bin/systemctl daemon-reload >dev/null || :
261     fi
262 %endif
263
264 %post selinux-policy
265 /usr/sbin/semodule -i %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp &> /dev/null || :
266
267 %postun
268 %if 0%{?systemd_postun_with_restart:1}
269     %systemd_postun_with_restart %{name}.service
270 %else
271     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
272     if [ "$1" -ge "1" ] ; then
273     # Package upgrade, not uninstall
274         /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
275     fi
276 %endif
277
278 %postun ovn
279 %if 0%{?systemd_postun_with_restart:1}
280     %systemd_postun_with_restart ovn-controller.service
281     %systemd_postun_with_restart ovn-controller-vtep.service
282     %systemd_postun_with_restart ovn-northd.service
283 %else
284     /bin/systemctl daemon-reload >/dev/null 2>&1 || :
285     if [ "$1" -ge "1" ] ; then
286     # Package upgrade, not uninstall
287         /bin/systemctl try-restart ovn-controller.service >/dev/null 2>&1 || :
288         /bin/systemctl try-restart ovn-controller-vtep.service >/dev/null 2>&1 || :
289         /bin/systemctl try-restart ovn-northd.service >/dev/null 2>&1 || :
290     fi
291 %endif
292
293 %postun selinux-policy
294 if [ $1 -eq 0 ] ; then
295   /usr/sbin/semodule -r openvswitch-custom &> /dev/null || :
296 fi
297
298 %files selinux-policy
299 %defattr(-,root,root)
300 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
301
302 %files -n python-openvswitch
303 %{python_sitelib}/ovs
304 %doc COPYING
305
306 %files test
307 %{_bindir}/ovs-test
308 %{_bindir}/ovs-vlan-test
309 %{_bindir}/ovs-l3ping
310 %{_mandir}/man8/ovs-test.8*
311 %{_mandir}/man8/ovs-vlan-test.8*
312 %{_mandir}/man8/ovs-l3ping.8*
313 %{python_sitelib}/ovstest
314
315 %files devel
316 %{_libdir}/*.a
317 %{_libdir}/*.la
318 %{_libdir}/pkgconfig/*.pc
319 %{_includedir}/openvswitch/*
320 %{_includedir}/openflow/*
321
322 %files
323 %defattr(-,root,root)
324 %{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash
325 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
326 %dir %{_sysconfdir}/openvswitch
327 %config %ghost %{_sysconfdir}/openvswitch/conf.db
328 %config %ghost %{_sysconfdir}/openvswitch/system-id.conf
329 %config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
330 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch
331 %{_unitdir}/openvswitch.service
332 %{_unitdir}/openvswitch-nonetwork.service
333 %{_datadir}/openvswitch/scripts/openvswitch.init
334 %{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
335 %{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
336 %{_datadir}/openvswitch/bugtool-plugins/
337 %{_datadir}/openvswitch/scripts/ovs-bugtool-*
338 %{_datadir}/openvswitch/scripts/ovs-check-dead-ifs
339 %{_datadir}/openvswitch/scripts/ovs-lib
340 %{_datadir}/openvswitch/scripts/ovs-vtep
341 %{_datadir}/openvswitch/scripts/ovs-ctl
342 %config %{_datadir}/openvswitch/vswitch.ovsschema
343 %config %{_datadir}/openvswitch/vtep.ovsschema
344 %{_bindir}/ovs-appctl
345 %{_bindir}/ovs-docker
346 %{_bindir}/ovs-dpctl
347 %{_bindir}/ovs-dpctl-top
348 %{_bindir}/ovs-ofctl
349 %{_bindir}/ovs-vsctl
350 %{_bindir}/ovsdb-client
351 %{_bindir}/ovsdb-tool
352 %{_bindir}/ovs-testcontroller
353 %{_bindir}/ovs-pki
354 %{_bindir}/vtep-ctl
355 %{_sbindir}/ovs-bugtool
356 %{_sbindir}/ovs-vswitchd
357 %{_sbindir}/ovsdb-server
358 %{_mandir}/man1/ovsdb-client.1*
359 %{_mandir}/man1/ovsdb-server.1*
360 %{_mandir}/man1/ovsdb-tool.1*
361 %{_mandir}/man5/ovs-vswitchd.conf.db.5*
362 %{_mandir}/man5/vtep.5*
363 %{_mandir}/man8/vtep-ctl.8*
364 %{_mandir}/man8/ovs-appctl.8*
365 %{_mandir}/man8/ovs-bugtool.8*
366 %{_mandir}/man8/ovs-ctl.8*
367 %{_mandir}/man8/ovs-dpctl.8*
368 %{_mandir}/man8/ovs-dpctl-top.8*
369 %{_mandir}/man8/ovs-ofctl.8*
370 %{_mandir}/man8/ovs-pki.8*
371 %{_mandir}/man8/ovs-vsctl.8*
372 %{_mandir}/man8/ovs-vswitchd.8*
373 %{_mandir}/man8/ovs-parse-backtrace.8*
374 %{_mandir}/man8/ovs-testcontroller.8*
375 %doc COPYING DESIGN.md INSTALL.SSL.md NOTICE README.md WHY-OVS.md
376 %doc FAQ.md NEWS INSTALL.DPDK.md rhel/README.RHEL
377 /var/lib/openvswitch
378 /var/log/openvswitch
379 %ghost %attr(755,root,root) %{_rundir}/openvswitch
380
381 %files ovn
382 %{_bindir}/ovn-controller
383 %{_bindir}/ovn-controller-vtep
384 %{_bindir}/ovn-docker-overlay-driver
385 %{_bindir}/ovn-docker-underlay-driver
386 %{_bindir}/ovn-nbctl
387 %{_bindir}/ovn-northd
388 %{_bindir}/ovn-sbctl
389 %{_datadir}/openvswitch/scripts/ovn-ctl
390 %{_mandir}/man8/ovs-testcontroller.8*
391 %{_mandir}/man5/ovn-nb.5*
392 %{_mandir}/man5/ovn-sb.5*
393 %{_mandir}/man7/ovn-architecture.7*
394 %{_mandir}/man8/ovn-controller.8*
395 %{_mandir}/man8/ovn-controller-vtep.8*
396 %{_mandir}/man8/ovn-ctl.8*
397 %{_mandir}/man8/ovn-nbctl.8*
398 %{_mandir}/man8/ovn-northd.8*
399 %{_mandir}/man8/ovn-sbctl.8*
400 %config %{_datadir}/openvswitch/ovn-nb.ovsschema
401 %config %{_datadir}/openvswitch/ovn-sb.ovsschema
402 %{_unitdir}/ovn-controller.service
403 %{_unitdir}/ovn-controller-vtep.service
404 %{_unitdir}/ovn-northd.service
405
406 %changelog
407 * Wed Jan 12 2011 Ralf Spenneberg <ralf@os-s.net>
408 - First build on F14