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 # Bug #4667: one-time cleanup of brctl removal in commit 54f16a10
203 # (xenserver: Remove brctl wrapper script).
204 if [ -h /usr/sbin/brctl ] &&
205 [ "$(readlink /usr/sbin/brctl)" = /usr/share/openvswitch/scripts/brctl ]; then
206 mv -f /usr/lib/openvswitch/xs-original/brctl /usr/sbin/
209 # Ensure all required services are set to run
210 for s in openvswitch openvswitch-xapi-update; do
211 if chkconfig --list $s >/dev/null 2>&1; then
212 chkconfig --del $s || printf "Could not remove $s init script."
214 chkconfig --add $s || printf "Could not add $s init script."
215 chkconfig $s on || printf "Could not enable $s init script."
218 # Configure system to use Open vSwitch
219 echo vswitch > /etc/xensource/network.conf
221 if [ "$1" = "1" ]; then # $1 = 2 for upgrade
222 printf "\nYou MUST reboot the server NOW to complete the change to\n"
223 printf "Open vSwitch. Attempts to modify networking on the server\n"
224 printf "or any hosted VM will fail until after the reboot and could\n"
225 printf "leave the server in an state requiring manual recovery.\n\n"
227 printf "\nTo use the new Open vSwitch install, you should reboot the\n"
228 printf "server now. Failure to do so may result in incorrect operation."
233 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
234 for s in openvswitch openvswitch-xapi-update; do
235 chkconfig --del $s || printf "Could not remove $s init script."
241 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
242 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
244 rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
245 /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
246 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
247 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
248 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
249 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo
251 # Restore original XenServer scripts. It's important to do this even on upgrade
252 # since the version to be installed may be missing some of these scripts.
254 /opt/xensource/libexec/interface-reconfigure \
255 /opt/xensource/libexec/InterfaceReconfigure.py \
256 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
257 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
258 /etc/xensource/scripts/vif \
259 /usr/sbin/xen-bugtool
262 if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then
263 printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n"
264 printf "Could not restore original XenServer script.\n"
267 && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \
268 || printf "Could not restore original XenServer $s script.\n"
272 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
273 # Remove all configuration files
274 rm -f /etc/openvswitch/conf.db
275 rm -f /etc/sysconfig/openvswitch
276 rm -f /etc/openvswitch/vswitchd.cacert
277 rm -f /var/xapi/network.dbcache
279 # Configure system to use bridge
280 echo bridge > /etc/xensource/network.conf
282 printf "\nYou MUST reboot the server now to complete the change to\n"
283 printf "standard Xen networking. Attempts to modify networking on the\n"
284 printf "server or any hosted VM will fail until after the reboot and\n"
285 printf "could leave the server in a state requiring manual recovery.\n\n"
289 %defattr(-,root,root)
290 /etc/init.d/openvswitch
291 /etc/init.d/openvswitch-xapi-update
292 /etc/xapi.d/plugins/openvswitch-cfg-update
293 /etc/logrotate.d/openvswitch
294 /etc/profile.d/openvswitch.sh
295 /lib/modules/%{xen_version}/kernel/extra/openvswitch/openvswitch_mod.ko
296 /usr/share/openvswitch/python/ovs/__init__.py
297 /usr/share/openvswitch/python/ovs/daemon.py
298 /usr/share/openvswitch/python/ovs/db/__init__.py
299 /usr/share/openvswitch/python/ovs/db/data.py
300 /usr/share/openvswitch/python/ovs/db/error.py
301 /usr/share/openvswitch/python/ovs/db/idl.py
302 /usr/share/openvswitch/python/ovs/db/parser.py
303 /usr/share/openvswitch/python/ovs/db/schema.py
304 /usr/share/openvswitch/python/ovs/db/types.py
305 /usr/share/openvswitch/python/ovs/dirs.py
306 /usr/share/openvswitch/python/ovs/fatal_signal.py
307 /usr/share/openvswitch/python/ovs/json.py
308 /usr/share/openvswitch/python/ovs/jsonrpc.py
309 /usr/share/openvswitch/python/ovs/ovsuuid.py
310 /usr/share/openvswitch/python/ovs/poller.py
311 /usr/share/openvswitch/python/ovs/process.py
312 /usr/share/openvswitch/python/ovs/reconnect.py
313 /usr/share/openvswitch/python/ovs/socket_util.py
314 /usr/share/openvswitch/python/ovs/stream.py
315 /usr/share/openvswitch/python/ovs/timeval.py
316 /usr/share/openvswitch/python/ovs/util.py
317 /usr/share/openvswitch/python/uuid.py
318 /usr/share/openvswitch/scripts/ovs-xapi-sync
319 /usr/share/openvswitch/scripts/interface-reconfigure
320 /usr/share/openvswitch/scripts/InterfaceReconfigure.py
321 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
322 /usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
323 /usr/share/openvswitch/scripts/vif
324 /usr/share/openvswitch/scripts/xen-bugtool
325 /usr/share/openvswitch/scripts/sysconfig.template
326 /usr/share/openvswitch/scripts/ovs-save
327 /usr/share/openvswitch/vswitch.ovsschema
328 /usr/sbin/ovs-vswitchd
329 /usr/sbin/ovsdb-server
334 /usr/bin/ovs-tcpundump
335 /usr/bin/ovs-vlan-test
337 /usr/bin/ovsdb-client
339 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
340 /usr/share/man/man1/ovsdb-client.1.gz
341 /usr/share/man/man1/ovsdb-server.1.gz
342 /usr/share/man/man1/ovsdb-tool.1.gz
343 /usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
344 /usr/share/man/man8/ovs-appctl.8.gz
345 /usr/share/man/man8/ovs-dpctl.8.gz
346 /usr/share/man/man8/ovs-ofctl.8.gz
347 /usr/share/man/man8/ovs-parse-leaks.8.gz
348 /usr/share/man/man1/ovs-pcap.1.gz
349 /usr/share/man/man1/ovs-tcpundump.1.gz
350 /usr/share/man/man8/ovs-vlan-test.8.gz
351 /usr/share/man/man8/ovs-vsctl.8.gz
352 /usr/share/man/man8/ovs-vswitchd.8.gz
354 %exclude /lib/modules/%{xen_version}/kernel/extra/openvswitch/brcompat_mod.ko
355 %exclude /usr/lib/xsconsole/plugins-base/*.py[co]
356 %exclude /usr/sbin/ovs-brcompatd
357 %exclude /usr/share/man/man8/ovs-brcompatd.8.gz
358 %exclude /usr/share/openvswitch/scripts/*.py[co]
359 %exclude /usr/share/openvswitch/python/*.py[co]
360 %exclude /usr/share/openvswitch/python/ovs/*.py[co]
361 %exclude /usr/share/openvswitch/python/ovs/db/*.py[co]