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-external-ids \
77 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-external-ids
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 if test ! -e /var/xapi/network.dbcache; then
113 if test "$1" = 1; then
114 printf "Creating xapi database cache... "
116 printf "warning: Open vSwitch is being re-installed or upgraded,\n"
117 printf " but the xapi database cache is missing.\n"
118 printf "Re-creating xapi database cache... "
121 if /usr/share/openvswitch/scripts/interface-reconfigure rewrite; then
125 printf "Open vSwitch can only be installed on a XenServer that\n"
126 printf "has connectivity to xapi on the pool master. Please\n"
127 printf "fix connectivity to the pool master, then try again.\n"
132 # Ensure that modprobe will find our modules.
133 depmod %{xen_version}
135 if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
136 cat >>/etc/sysctl.conf <<EOF
137 # This works around an issue in xhad, which binds to a particular
138 # Ethernet device, which in turn causes ICMP port unreachable messages
139 # if packets are received are on the wrong interface, which in turn
140 # can happen if we send out ARP replies on every interface (as Linux
141 # does by default) instead of just on the interface that has the IP
142 # address being ARPed for, which this sysctl setting in turn works
146 net.ipv4.conf.all.arp_filter = 1
150 if test ! -e /etc/openvswitch/conf.db; then
151 install -d -m 755 -o root -g root /etc/openvswitch
153 # Create ovs-vswitchd config database
154 ovsdb-tool -vANY:console:emer create /etc/openvswitch/conf.db \
155 /usr/share/openvswitch/vswitch.ovsschema
157 # Create initial table in config database
158 ovsdb-tool -vANY:console:emer transact /etc/openvswitch/conf.db \
159 '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
163 # Create default or update existing /etc/sysconfig/openvswitch.
164 SYSCONFIG=/etc/sysconfig/openvswitch
165 TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template
166 if [ ! -e $SYSCONFIG ]; then
167 cp $TEMPLATE $SYSCONFIG
169 for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
171 if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
173 sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
178 # Replace XenServer files by our versions.
179 mkdir -p /usr/lib/openvswitch/xs-original \
180 || printf "Could not create script backup directory.\n"
182 /opt/xensource/libexec/interface-reconfigure \
183 /opt/xensource/libexec/InterfaceReconfigure.py \
184 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
185 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
186 /etc/xensource/scripts/vif \
187 /usr/sbin/xen-bugtool
191 if [ -f "$f" ] && [ "$t" != "/usr/share/openvswitch/scripts/$s" ]; then
192 mv "$f" /usr/lib/openvswitch/xs-original/ \
193 || printf "Could not save original XenServer $s script\n"
194 ln -s "/usr/share/openvswitch/scripts/$s" "$f" \
195 || printf "Could not link to Open vSwitch $s script\n"
199 # Ensure all required services are set to run
200 for s in openvswitch openvswitch-xapi-update; do
201 if chkconfig --list $s >/dev/null 2>&1; then
202 chkconfig --del $s || printf "Could not remove $s init script."
204 chkconfig --add $s || printf "Could not add $s init script."
205 chkconfig $s on || printf "Could not enable $s init script."
208 # Configure system to use Open vSwitch
209 echo vswitch > /etc/xensource/network.conf
211 if [ "$1" = "1" ]; then # $1 = 2 for upgrade
212 printf "\nYou MUST reboot the server NOW to complete the change to\n"
213 printf "Open vSwitch. Attempts to modify networking on the server\n"
214 printf "or any hosted VM will fail until after the reboot and could\n"
215 printf "leave the server in an state requiring manual recovery.\n\n"
217 printf "\nTo use the new Open vSwitch install, you should reboot the\n"
218 printf "server now. Failure to do so may result in incorrect operation."
223 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
224 for s in openvswitch openvswitch-xapi-update; do
225 chkconfig --del $s || printf "Could not remove $s init script."
231 if [ "$1" = "0" ]; then # $1 = 1 for upgrade
232 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
233 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
235 rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
236 /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
237 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
238 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
239 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
240 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo
242 # Restore original XenServer scripts
244 /opt/xensource/libexec/interface-reconfigure \
245 /opt/xensource/libexec/InterfaceReconfigure.py \
246 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
247 /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
248 /etc/xensource/scripts/vif \
249 /usr/sbin/xen-bugtool
252 if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then
253 printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n"
254 printf "Could not restore original XenServer script.\n"
257 && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \
258 || printf "Could not restore original XenServer $s script.\n"
262 # Remove all configuration files
263 rm -f /etc/openvswitch/conf.db
264 rm -f /etc/sysconfig/openvswitch
265 rm -f /etc/openvswitch/vswitchd.cacert
266 rm -f /var/xapi/network.dbcache
268 # Configure system to use bridge
269 echo bridge > /etc/xensource/network.conf
271 printf "\nYou MUST reboot the server now to complete the change to\n"
272 printf "standard Xen networking. Attempts to modify networking on the\n"
273 printf "server or any hosted VM will fail until after the reboot and\n"
274 printf "could leave the server in a state requiring manual recovery.\n\n"
279 %defattr(-,root,root)
280 /etc/init.d/openvswitch
281 /etc/init.d/openvswitch-xapi-update
282 /etc/xapi.d/plugins/openvswitch-cfg-update
283 /etc/logrotate.d/openvswitch
284 /etc/profile.d/openvswitch.sh
285 /lib/modules/%{xen_version}/kernel/extra/openvswitch/openvswitch_mod.ko
286 /usr/share/openvswitch/python/ovs/__init__.py
287 /usr/share/openvswitch/python/ovs/daemon.py
288 /usr/share/openvswitch/python/ovs/db/__init__.py
289 /usr/share/openvswitch/python/ovs/db/data.py
290 /usr/share/openvswitch/python/ovs/db/error.py
291 /usr/share/openvswitch/python/ovs/db/idl.py
292 /usr/share/openvswitch/python/ovs/db/parser.py
293 /usr/share/openvswitch/python/ovs/db/schema.py
294 /usr/share/openvswitch/python/ovs/db/types.py
295 /usr/share/openvswitch/python/ovs/dirs.py
296 /usr/share/openvswitch/python/ovs/fatal_signal.py
297 /usr/share/openvswitch/python/ovs/json.py
298 /usr/share/openvswitch/python/ovs/jsonrpc.py
299 /usr/share/openvswitch/python/ovs/ovsuuid.py
300 /usr/share/openvswitch/python/ovs/poller.py
301 /usr/share/openvswitch/python/ovs/process.py
302 /usr/share/openvswitch/python/ovs/reconnect.py
303 /usr/share/openvswitch/python/ovs/socket_util.py
304 /usr/share/openvswitch/python/ovs/stream.py
305 /usr/share/openvswitch/python/ovs/timeval.py
306 /usr/share/openvswitch/python/ovs/util.py
307 /usr/share/openvswitch/python/uuid.py
308 /usr/share/openvswitch/scripts/ovs-external-ids
309 /usr/share/openvswitch/scripts/interface-reconfigure
310 /usr/share/openvswitch/scripts/InterfaceReconfigure.py
311 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
312 /usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
313 /usr/share/openvswitch/scripts/vif
314 /usr/share/openvswitch/scripts/xen-bugtool
315 /usr/share/openvswitch/scripts/sysconfig.template
316 /usr/share/openvswitch/scripts/ovs-save
317 /usr/share/openvswitch/vswitch.ovsschema
318 /usr/sbin/ovs-vswitchd
319 /usr/sbin/ovsdb-server
324 /usr/bin/ovs-tcpundump
325 /usr/bin/ovs-vlan-test
327 /usr/bin/ovsdb-client
329 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
330 /usr/share/man/man1/ovsdb-client.1.gz
331 /usr/share/man/man1/ovsdb-server.1.gz
332 /usr/share/man/man1/ovsdb-tool.1.gz
333 /usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
334 /usr/share/man/man8/ovs-appctl.8.gz
335 /usr/share/man/man8/ovs-dpctl.8.gz
336 /usr/share/man/man8/ovs-ofctl.8.gz
337 /usr/share/man/man8/ovs-parse-leaks.8.gz
338 /usr/share/man/man1/ovs-pcap.1.gz
339 /usr/share/man/man1/ovs-tcpundump.1.gz
340 /usr/share/man/man8/ovs-vlan-test.8.gz
341 /usr/share/man/man8/ovs-vsctl.8.gz
342 /usr/share/man/man8/ovs-vswitchd.8.gz
344 %exclude /lib/modules/%{xen_version}/kernel/extra/openvswitch/brcompat_mod.ko
345 %exclude /usr/lib/xsconsole/plugins-base/*.py[co]
346 %exclude /usr/sbin/ovs-brcompatd
347 %exclude /usr/share/man/man8/ovs-brcompatd.8.gz
348 %exclude /usr/share/openvswitch/scripts/*.py[co]
349 %exclude /usr/share/openvswitch/python/*.py[co]
350 %exclude /usr/share/openvswitch/python/ovs/*.py[co]
351 %exclude /usr/share/openvswitch/python/ovs/db/*.py[co]