05b9e4d281db94538acb9868acf3cb55c71af863
[cascardo/ovs.git] / rhel / openvswitch.spec.in
1 # Spec file for Open vSwitch on Red Hat Enterprise Linux.
2
3 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, 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.spec
13
14 Name: openvswitch
15 Summary: Open vSwitch daemon/database/utilities
16 Group: System Environment/Daemons
17 URL: http://www.openvswitch.org/
18 Vendor: Nicira, Inc.
19 Version: @VERSION@
20
21 License: ASL 2.0
22 Release: 1
23 Source: openvswitch-%{version}.tar.gz
24 Buildroot: /tmp/openvswitch-rpm
25 Requires: logrotate, python >= 2.7, python-six
26 BuildRequires: openssl-devel
27
28 %bcond_without check
29
30 %description
31 Open vSwitch provides standard network bridging functions and
32 support for the OpenFlow protocol for remote per-flow control of
33 traffic.
34
35 %prep
36 %setup -q
37
38 %build
39 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --enable-ssl
40 make %{_smp_mflags}
41
42 %install
43 rm -rf $RPM_BUILD_ROOT
44 make install DESTDIR=$RPM_BUILD_ROOT
45
46 rhel_cp() {
47  base=$1
48  mode=$2
49  dst=$RPM_BUILD_ROOT/$(echo $base | sed 's,_,/,g')
50  install -D -m $mode rhel/$base $dst
51 }
52 rhel_cp etc_init.d_openvswitch 0755
53 rhel_cp etc_logrotate.d_openvswitch 0644
54 rhel_cp etc_sysconfig_network-scripts_ifup-ovs 0755
55 rhel_cp etc_sysconfig_network-scripts_ifdown-ovs 0755
56 rhel_cp usr_share_openvswitch_scripts_sysconfig.template 0644
57
58 # Get rid of stuff we don't want to make RPM happy.
59 rm \
60     $RPM_BUILD_ROOT/usr/bin/ovs-testcontroller \
61     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-testcontroller.8 \
62     $RPM_BUILD_ROOT/usr/bin/ovs-test \
63     $RPM_BUILD_ROOT/usr/bin/ovs-l3ping \
64     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8 \
65     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \
66     $RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \
67     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8 \
68     $RPM_BUILD_ROOT/usr/bin/ovn-* \
69     $RPM_BUILD_ROOT/usr/share/man/man?/ovn-* \
70     $RPM_BUILD_ROOT/usr/share/openvswitch/ovn-* \
71     $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovn-*
72 (cd "$RPM_BUILD_ROOT" && rm -rf usr/lib)
73 (cd "$RPM_BUILD_ROOT" && rm -rf usr/include)
74
75 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
76
77 %check
78 %if %{with check}
79     if make check TESTSUITEFLAGS='%{_smp_mflags}' ||
80        make check TESTSUITEFLAGS='--recheck'; then :;
81     else
82         cat tests/testsuite.log
83         exit 1
84     fi
85 %endif
86
87 %clean
88 rm -rf $RPM_BUILD_ROOT
89
90 %post
91 # Create default or update existing /etc/sysconfig/openvswitch.
92 SYSCONFIG=/etc/sysconfig/openvswitch
93 TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template
94 if [ ! -e $SYSCONFIG ]; then
95     cp $TEMPLATE $SYSCONFIG
96 else
97     for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
98     do
99         if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
100             echo >> $SYSCONFIG
101             sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
102         fi
103     done
104 fi
105
106 # Ensure all required services are set to run
107 /sbin/chkconfig --add openvswitch
108 /sbin/chkconfig openvswitch on
109
110 %preun
111 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
112     /sbin/service openvswitch stop
113     /sbin/chkconfig --del openvswitch
114 fi
115
116 %postun
117 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
118     rm -f /etc/openvswitch/conf.db
119     rm -f /etc/sysconfig/openvswitch
120     rm -f /etc/openvswitch/vswitchd.cacert
121 fi
122
123 exit 0
124
125 %files
126 %defattr(-,root,root)
127 %dir /etc/openvswitch
128 /etc/bash_completion.d/ovs-appctl-bashcomp.bash
129 /etc/bash_completion.d/ovs-vsctl-bashcomp.bash
130 /etc/init.d/openvswitch
131 %config(noreplace) /etc/logrotate.d/openvswitch
132 /etc/sysconfig/network-scripts/ifup-ovs
133 /etc/sysconfig/network-scripts/ifdown-ovs
134 /usr/bin/ovs-appctl
135 /usr/bin/ovs-dpctl
136 /usr/bin/ovs-dpctl-top
137 /usr/bin/ovs-docker
138 /usr/bin/ovs-ofctl
139 /usr/bin/ovs-parse-backtrace
140 /usr/bin/ovs-pcap
141 /usr/bin/ovs-pki
142 /usr/bin/ovs-tcpundump
143 /usr/bin/ovs-vlan-test
144 /usr/bin/ovs-vsctl
145 /usr/bin/ovsdb-client
146 /usr/bin/ovsdb-tool
147 /usr/bin/vtep-ctl
148 /usr/sbin/ovs-bugtool
149 /usr/sbin/ovs-vswitchd
150 /usr/sbin/ovsdb-server
151 /usr/share/man/man1/ovs-pcap.1.gz
152 /usr/share/man/man1/ovs-tcpundump.1.gz
153 /usr/share/man/man1/ovsdb-client.1.gz
154 /usr/share/man/man1/ovsdb-server.1.gz
155 /usr/share/man/man1/ovsdb-tool.1.gz
156 /usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
157 /usr/share/man/man5/vtep.5.gz
158 /usr/share/man/man8/ovs-appctl.8.gz
159 /usr/share/man/man8/ovs-bugtool.8.gz
160 /usr/share/man/man8/ovs-ctl.8.gz
161 /usr/share/man/man8/ovs-dpctl.8.gz
162 /usr/share/man/man8/ovs-dpctl-top.8.gz
163 /usr/share/man/man8/ovs-ofctl.8.gz
164 /usr/share/man/man8/ovs-parse-backtrace.8.gz
165 /usr/share/man/man8/ovs-pki.8.gz
166 /usr/share/man/man8/ovs-vlan-test.8.gz
167 /usr/share/man/man8/ovs-vsctl.8.gz
168 /usr/share/man/man8/ovs-vswitchd.8.gz
169 /usr/share/man/man8/vtep-ctl.8.gz
170 /usr/share/openvswitch/bugtool-plugins/
171 /usr/share/openvswitch/python/
172 /usr/share/openvswitch/scripts/ovs-bugtool-*
173 /usr/share/openvswitch/scripts/ovs-check-dead-ifs
174 /usr/share/openvswitch/scripts/ovs-ctl
175 /usr/share/openvswitch/scripts/ovs-lib
176 /usr/share/openvswitch/scripts/ovs-save
177 /usr/share/openvswitch/scripts/ovs-vtep
178 /usr/share/openvswitch/scripts/sysconfig.template
179 /usr/share/openvswitch/vswitch.ovsschema
180 /usr/share/openvswitch/vtep.ovsschema
181 %doc COPYING DESIGN.md INSTALL.SSL.md NOTICE README.md WHY-OVS.md FAQ.md NEWS
182 %doc INSTALL.DPDK.md rhel/README.RHEL README-native-tunneling.md
183 /var/lib/openvswitch
184 /var/log/openvswitch