1 # Spec file for Open vSwitch.
3 # Copyright (C) 2009, 2010, 2011 Nicira Networks, Inc.
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.
10 # When building, the rpmbuild command line should define
11 # openvswitch_version, xen_version, and build_number using -D arguments.
14 # rpmbuild -D "openvswitch_version 0.8.9~1+build123" -D "xen_version 2.6.18-128.1.1.el5.xs5.1.0.483.1000xen" -D "build_number --with-build-number=123" -bb /usr/src/redhat/SPECS/openvswitch-xen.spec
16 %define version %{openvswitch_version}-%{xen_version}
19 Summary: Virtual switch
20 Group: System Environment/Daemons
21 URL: http://www.openvswitch.org/
22 Vendor: Nicira Networks, Inc.
23 Version: %{openvswitch_version}
25 # The entire source code is ASL 2.0 except datapath/ which is GPLv2
26 License: ASL 2.0 and GPLv2
28 Source: openvswitch-%{openvswitch_version}.tar.gz
29 Buildroot: /tmp/openvswitch-xen-rpm
30 Requires: kernel-xen = %(echo '%{xen_version}' | sed 's/xen$//')
33 Open vSwitch provides standard network bridging functions augmented with
34 support for the OpenFlow protocol for remote per-flow control of
38 %setup -q -n openvswitch-%{openvswitch_version}
41 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-l26=/lib/modules/%{xen_version}/build --enable-ssl %{build_number}
45 rm -rf $RPM_BUILD_ROOT
46 make install DESTDIR=$RPM_BUILD_ROOT
47 install -d -m 755 $RPM_BUILD_ROOT/etc
48 install -d -m 755 $RPM_BUILD_ROOT/etc/init.d
49 install -m 755 xenserver/etc_init.d_openvswitch \
50 $RPM_BUILD_ROOT/etc/init.d/openvswitch
51 install -m 755 xenserver/etc_init.d_openvswitch-xapi-update \
52 $RPM_BUILD_ROOT/etc/init.d/openvswitch-xapi-update
53 install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
54 install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
55 install -m 755 xenserver/etc_logrotate.d_openvswitch \
56 $RPM_BUILD_ROOT/etc/logrotate.d/openvswitch
57 install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d
58 install -m 755 xenserver/etc_profile.d_openvswitch.sh \
59 $RPM_BUILD_ROOT/etc/profile.d/openvswitch.sh
60 install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins
61 install -m 755 xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \
62 $RPM_BUILD_ROOT/etc/xapi.d/plugins/openvswitch-cfg-update
63 install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
64 install -m 644 vswitchd/vswitch.ovsschema \
65 $RPM_BUILD_ROOT/usr/share/openvswitch/vswitch.ovsschema
66 install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \
67 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/interface-reconfigure
68 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \
69 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigure.py
70 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \
71 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
72 install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
73 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
74 install -m 755 xenserver/etc_xensource_scripts_vif \
75 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/vif
76 install -m 755 xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
77 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-xapi-sync
78 install -m 755 xenserver/usr_sbin_xen-bugtool \
79 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/xen-bugtool
80 install -m 755 xenserver/usr_share_openvswitch_scripts_sysconfig.template \
81 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/sysconfig.template
82 install -m 755 utilities/ovs-save \
83 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-save
84 install -d -m 755 $RPM_BUILD_ROOT/usr/lib/xsconsole/plugins-base
86 xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
87 $RPM_BUILD_ROOT/usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
89 install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/extra/openvswitch
90 find datapath/linux-2.6 -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/kernel/extra/openvswitch \;
91 install xenserver/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
93 # Get rid of stuff we don't want to make RPM happy.
95 $RPM_BUILD_ROOT/usr/bin/ovs-controller \
96 $RPM_BUILD_ROOT/usr/bin/ovs-discover \
97 $RPM_BUILD_ROOT/usr/bin/ovs-kill \
98 $RPM_BUILD_ROOT/usr/bin/ovs-openflowd \
99 $RPM_BUILD_ROOT/usr/bin/ovs-pki \
100 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \
101 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-discover.8 \
102 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-kill.8 \
103 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-openflowd.8 \
104 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8
106 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
109 rm -rf $RPM_BUILD_ROOT
112 # Do not run the first block if we are in the XenServer installer
113 if runlevel >/dev/null 2>&1; then
114 if test ! -e /var/xapi/network.dbcache; then
115 if test "$1" = 1; then
116 printf "Creating xapi database cache... "
118 printf "warning: Open vSwitch is being re-installed or upgraded,\n"
119 printf " but the xapi database cache is missing.\n"
120 printf "Re-creating xapi database cache... "
123 if /usr/share/openvswitch/scripts/interface-reconfigure rewrite; then
127 printf "Open vSwitch can only be installed on a XenServer that\n"
128 printf "has connectivity to xapi on the pool master. Please\n"
129 printf "fix connectivity to the pool master, then try again.\n"
135 # Ensure that modprobe will find our modules.
136 depmod %{xen_version}
138 if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
139 cat >>/etc/sysctl.conf <<EOF
140 # This works around an issue in xhad, which binds to a particular
141 # Ethernet device, which in turn causes ICMP port unreachable messages
142 # if packets are received are on the wrong interface, which in turn
143 # can happen if we send out ARP replies on every interface (as Linux
144 # does by default) instead of just on the interface that has the IP
145 # address being ARPed for, which this sysctl setting in turn works
149 net.ipv4.conf.all.arp_filter = 1
153 if test ! -e /etc/openvswitch/conf.db; then
154 install -d -m 755 -o root -g root /etc/openvswitch
156 # Create ovs-vswitchd config database
157 ovsdb-tool -vANY:console:emer create /etc/openvswitch/conf.db \
158 /usr/share/openvswitch/vswitch.ovsschema
160 # Create initial table in config database
161 ovsdb-tool -vANY:console:emer transact /etc/openvswitch/conf.db \
162 '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
166 # Create default or update existing /etc/sysconfig/openvswitch.
167 SYSCONFIG=/etc/sysconfig/openvswitch
168 TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template
169 if [ ! -e $SYSCONFIG ]; then
170 cp $TEMPLATE $SYSCONFIG
172 for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
174 if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
176 sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
181 # Replace XenServer files by our versions.
182 mkdir -p /usr/lib/openvswitch/xs-original \
183 || printf "Could not create script backup directory.\n"
185 /opt/xensource/libexec/interface-reconfigure \
186 /opt/xensource/libexec/InterfaceReconfigure.py \
187 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
188 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
189 /etc/xensource/scripts/vif \
190 /usr/sbin/xen-bugtool
194 if [ -f "$f" ] && [ "$t" != "/usr/share/openvswitch/scripts/$s" ]; then
195 mv "$f" /usr/lib/openvswitch/xs-original/ \
196 || printf "Could not save original XenServer $s script\n"
197 ln -s "/usr/share/openvswitch/scripts/$s" "$f" \
198 || printf "Could not link to Open vSwitch $s script\n"
202 # Ensure all required services are set to run
203 for s in openvswitch openvswitch-xapi-update; do
204 if chkconfig --list $s >/dev/null 2>&1; then
205 chkconfig --del $s || printf "Could not remove $s init script."
207 chkconfig --add $s || printf "Could not add $s init script."
208 chkconfig $s on || printf "Could not enable $s init script."
211 # Configure system to use Open vSwitch
212 echo vswitch > /etc/xensource/network.conf
214 if [ "$1" = "1" ]; then # $1 = 2 for upgrade
215 printf "\nYou MUST reboot the server NOW to complete the change to\n"
216 printf "Open vSwitch. Attempts to modify networking on the server\n"
217 printf "or any hosted VM will fail until after the reboot and could\n"
218 printf "leave the server in an state requiring manual recovery.\n\n"
220 printf "\nTo use the new Open vSwitch install, you should reboot the\n"
221 printf "server now. Failure to do so may result in incorrect operation."
226 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
227 for s in openvswitch openvswitch-xapi-update; do
228 chkconfig --del $s || printf "Could not remove $s init script."
234 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
235 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
236 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
238 rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
239 /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
240 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
241 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
242 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
243 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo
245 # Restore original XenServer scripts
247 /opt/xensource/libexec/interface-reconfigure \
248 /opt/xensource/libexec/InterfaceReconfigure.py \
249 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
250 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
251 /etc/xensource/scripts/vif \
252 /usr/sbin/xen-bugtool
255 if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then
256 printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n"
257 printf "Could not restore original XenServer script.\n"
260 && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \
261 || printf "Could not restore original XenServer $s script.\n"
265 # Remove all configuration files
266 rm -f /etc/openvswitch/conf.db
267 rm -f /etc/sysconfig/openvswitch
268 rm -f /etc/openvswitch/vswitchd.cacert
269 rm -f /var/xapi/network.dbcache
271 # Configure system to use bridge
272 echo bridge > /etc/xensource/network.conf
274 printf "\nYou MUST reboot the server now to complete the change to\n"
275 printf "standard Xen networking. Attempts to modify networking on the\n"
276 printf "server or any hosted VM will fail until after the reboot and\n"
277 printf "could leave the server in a state requiring manual recovery.\n\n"
282 %defattr(-,root,root)
283 /etc/init.d/openvswitch
284 /etc/init.d/openvswitch-xapi-update
285 /etc/xapi.d/plugins/openvswitch-cfg-update
286 /etc/logrotate.d/openvswitch
287 /etc/profile.d/openvswitch.sh
288 /lib/modules/%{xen_version}/kernel/extra/openvswitch/openvswitch_mod.ko
289 /usr/share/openvswitch/python/ovs/__init__.py
290 /usr/share/openvswitch/python/ovs/daemon.py
291 /usr/share/openvswitch/python/ovs/db/__init__.py
292 /usr/share/openvswitch/python/ovs/db/data.py
293 /usr/share/openvswitch/python/ovs/db/error.py
294 /usr/share/openvswitch/python/ovs/db/idl.py
295 /usr/share/openvswitch/python/ovs/db/parser.py
296 /usr/share/openvswitch/python/ovs/db/schema.py
297 /usr/share/openvswitch/python/ovs/db/types.py
298 /usr/share/openvswitch/python/ovs/dirs.py
299 /usr/share/openvswitch/python/ovs/fatal_signal.py
300 /usr/share/openvswitch/python/ovs/json.py
301 /usr/share/openvswitch/python/ovs/jsonrpc.py
302 /usr/share/openvswitch/python/ovs/ovsuuid.py
303 /usr/share/openvswitch/python/ovs/poller.py
304 /usr/share/openvswitch/python/ovs/process.py
305 /usr/share/openvswitch/python/ovs/reconnect.py
306 /usr/share/openvswitch/python/ovs/socket_util.py
307 /usr/share/openvswitch/python/ovs/stream.py
308 /usr/share/openvswitch/python/ovs/timeval.py
309 /usr/share/openvswitch/python/ovs/util.py
310 /usr/share/openvswitch/python/uuid.py
311 /usr/share/openvswitch/scripts/ovs-xapi-sync
312 /usr/share/openvswitch/scripts/interface-reconfigure
313 /usr/share/openvswitch/scripts/InterfaceReconfigure.py
314 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
315 /usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
316 /usr/share/openvswitch/scripts/vif
317 /usr/share/openvswitch/scripts/xen-bugtool
318 /usr/share/openvswitch/scripts/sysconfig.template
319 /usr/share/openvswitch/scripts/ovs-save
320 /usr/share/openvswitch/vswitch.ovsschema
321 /usr/sbin/ovs-vswitchd
322 /usr/sbin/ovsdb-server
327 /usr/bin/ovs-tcpundump
328 /usr/bin/ovs-vlan-test
330 /usr/bin/ovsdb-client
332 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
333 /usr/share/man/man1/ovsdb-client.1.gz
334 /usr/share/man/man1/ovsdb-server.1.gz
335 /usr/share/man/man1/ovsdb-tool.1.gz
336 /usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
337 /usr/share/man/man8/ovs-appctl.8.gz
338 /usr/share/man/man8/ovs-dpctl.8.gz
339 /usr/share/man/man8/ovs-ofctl.8.gz
340 /usr/share/man/man8/ovs-parse-leaks.8.gz
341 /usr/share/man/man1/ovs-pcap.1.gz
342 /usr/share/man/man1/ovs-tcpundump.1.gz
343 /usr/share/man/man8/ovs-vlan-test.8.gz
344 /usr/share/man/man8/ovs-vsctl.8.gz
345 /usr/share/man/man8/ovs-vswitchd.8.gz
347 %exclude /lib/modules/%{xen_version}/kernel/extra/openvswitch/brcompat_mod.ko
348 %exclude /usr/lib/xsconsole/plugins-base/*.py[co]
349 %exclude /usr/sbin/ovs-brcompatd
350 %exclude /usr/share/man/man8/ovs-brcompatd.8.gz
351 %exclude /usr/share/openvswitch/scripts/*.py[co]
352 %exclude /usr/share/openvswitch/python/*.py[co]
353 %exclude /usr/share/openvswitch/python/ovs/*.py[co]
354 %exclude /usr/share/openvswitch/python/ovs/db/*.py[co]