]> git.proxmox.com Git - ovs.git/blame - xenserver/openvswitch-xen.spec.in
BFD: Add BFD output to bugtool
[ovs.git] / xenserver / openvswitch-xen.spec.in
CommitLineData
7b007006
BP
1# Spec file for Open vSwitch.
2
825da1c6 3# Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
7b007006
BP
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# When building, the rpmbuild command line should define
8a07709c
BP
11# openvswitch_version, kernel_name, kernel_version, and kernel_flavor
12# using -D arguments.
7b007006
BP
13# for example:
14#
15# rpmbuild -D "openvswitch_version 1.1.0+build123"
16# -D "kernel_name NAME-xen"
17# -D "kernel_version 2.6.32.12-0.7.1.xs5.6.100.323.170596"
18# -D "kernel_flavor xen"
7b007006
BP
19# -bb /usr/src/redhat/SPECS/openvswitch-xen.spec
20
21%if %{?openvswitch_version:0}%{!?openvswitch_version:1}
22%define openvswitch_version @VERSION@
23%endif
24
25%if %{?kernel_name:0}%{!?kernel_name:1}
26%define kernel %(rpm -qa 'kernel*xen-devel' | head -1)
27%define kernel_name %(rpm -q --queryformat "%%{Name}" %{kernel} | sed 's/-devel//' | sed 's/kernel-//')
28%define kernel_version %(rpm -q --queryformat "%%{Version}-%%{Release}" %{kernel})
29%define kernel_flavor xen
30%endif
31
32%define xen_version %{kernel_version}%{kernel_flavor}
33
34# bump this when breaking compatibility with userspace
35%define module_abi_version 0
36
37# build-supplemental-pack.sh requires this naming for kernel module packages
38%define module_package modules-%{kernel_flavor}-%{kernel_version}
39
40Name: openvswitch
41Summary: Open vSwitch daemon/database/utilities
42Group: System Environment/Daemons
43URL: http://www.openvswitch.org/
e0edde6f 44Vendor: Nicira, Inc.
7b007006
BP
45Version: %{openvswitch_version}
46
47License: ASL 2.0
48Release: 1
49Source: openvswitch-%{openvswitch_version}.tar.gz
50Buildroot: /tmp/openvswitch-xen-rpm
9b80f761 51Requires: openvswitch.ko.%{module_abi_version}
7b007006
BP
52
53%description
54Open vSwitch provides standard network bridging functions augmented with
55support for the OpenFlow protocol for remote per-flow control of
56traffic.
57
58%package %{module_package}
59Summary: Open vSwitch kernel module
60Group: System Environment/Kernel
61License: GPLv2
9b80f761 62Provides: %{name}-modules-%{kernel_flavor} = %{kernel_version}, openvswitch.ko.%{module_abi_version}
7b007006
BP
63Requires: kernel-%{kernel_name} = %{kernel_version}
64
65%description %{module_package}
66Open vSwitch Linux kernel module compiled against kernel version
67%{xen_version}.
68
69%prep
70%setup -q -n openvswitch-%{openvswitch_version}
71
72%build
8a07709c 73./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --with-linux=/lib/modules/%{xen_version}/build --enable-ssl
7b007006
BP
74make %{_smp_mflags}
75
76%install
77rm -rf $RPM_BUILD_ROOT
78make install DESTDIR=$RPM_BUILD_ROOT
79install -d -m 755 $RPM_BUILD_ROOT/etc
80install -d -m 755 $RPM_BUILD_ROOT/etc/init.d
81install -m 755 xenserver/etc_init.d_openvswitch \
82 $RPM_BUILD_ROOT/etc/init.d/openvswitch
83install -m 755 xenserver/etc_init.d_openvswitch-xapi-update \
84 $RPM_BUILD_ROOT/etc/init.d/openvswitch-xapi-update
85install -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig
86install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
87install -m 755 xenserver/etc_logrotate.d_openvswitch \
88 $RPM_BUILD_ROOT/etc/logrotate.d/openvswitch
89install -d -m 755 $RPM_BUILD_ROOT/etc/profile.d
90install -m 755 xenserver/etc_profile.d_openvswitch.sh \
91 $RPM_BUILD_ROOT/etc/profile.d/openvswitch.sh
92install -d -m 755 $RPM_BUILD_ROOT/etc/xapi.d/plugins
93install -m 755 xenserver/etc_xapi.d_plugins_openvswitch-cfg-update \
94 $RPM_BUILD_ROOT/etc/xapi.d/plugins/openvswitch-cfg-update
95install -d -m 755 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts
96install -m 755 xenserver/opt_xensource_libexec_interface-reconfigure \
97 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/interface-reconfigure
98install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigure.py \
99 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigure.py
100install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureBridge.py \
101 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
102install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
103 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
104install -m 755 xenserver/etc_xensource_scripts_vif \
105 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/vif
106install -m 755 xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
107 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-xapi-sync
108install -m 755 xenserver/usr_share_openvswitch_scripts_sysconfig.template \
109 $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/sysconfig.template
110install -d -m 755 $RPM_BUILD_ROOT/usr/lib/xsconsole/plugins-base
111install -m 644 \
112 xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py \
113 $RPM_BUILD_ROOT/usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
114
115install -d -m 755 $RPM_BUILD_ROOT/lib/modules/%{xen_version}/extra/openvswitch
116find datapath/linux -name *.ko -exec install -m 755 \{\} $RPM_BUILD_ROOT/lib/modules/%{xen_version}/extra/openvswitch \;
117install python/compat/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
118install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
119
120install -d -m 755 $RPM_BUILD_ROOT/etc/xensource/bugtool
31f4bd47 121cp -rf $RPM_BUILD_ROOT/usr/share/openvswitch/bugtool-plugins/* $RPM_BUILD_ROOT/etc/xensource/bugtool
7b007006
BP
122
123# Get rid of stuff we don't want to make RPM happy.
124rm \
125 $RPM_BUILD_ROOT/usr/bin/ovs-benchmark \
7b007006 126 $RPM_BUILD_ROOT/usr/bin/ovs-controller \
2d8bdd8f 127 $RPM_BUILD_ROOT/usr/bin/ovs-l3ping \
7b007006
BP
128 $RPM_BUILD_ROOT/usr/bin/ovs-pki \
129 $RPM_BUILD_ROOT/usr/bin/ovs-test \
7b007006 130 $RPM_BUILD_ROOT/usr/share/man/man1/ovs-benchmark.1 \
7b007006 131 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \
bce821a5 132 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \
2d8bdd8f
AA
133 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-pki.8 \
134 $RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8
7b007006
BP
135
136install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
137
138%clean
139rm -rf $RPM_BUILD_ROOT
140
141%post
142# A list of Citrix XenServer scripts that we might need to replace
143# with our own versions.
144scripts="
145 /etc/xensource/scripts/vif
146 /opt/xensource/libexec/InterfaceReconfigure.py
147 /opt/xensource/libexec/InterfaceReconfigureBridge.py
148 /opt/xensource/libexec/InterfaceReconfigureVswitch.py
149 /opt/xensource/libexec/interface-reconfigure"
150
151# Calculate into $md5sums a comma-separated set of md5sums of the
152# Citrix XenServer scripts that we might need to replace. We might be
153# upgrading an older version of the package that moved the files out
154# of the way, so we need to look for the files in those out-of-the-way
155# locations first.
156md5sums=
157for script in $scripts; do
158 b=$(basename "$script")
159 if test -e /usr/lib/openvswitch/xs-saved/"$b"; then
160 f=/usr/lib/openvswitch/xs-saved/"$b"
161 elif test -e /usr/lib/openvswitch/xs-original/"$b"; then
162 f=/usr/lib/openvswitch/xs-original/"$b"
163 elif test -e "$script" && test ! -h "$script"; then
164 f=$script
165 else
166 printf "\n$script: not found\n"
167 f=/dev/null
168 fi
169 md5sums="$md5sums,$(md5sum $f | awk '{print $1}')"
170done
171md5sums=${md5sums#,}
172
173# Now check the md5sums against the known sets of md5sums:
174#
175# - If they are known to be a version of XenServer scripts that we should
176# replace, we replace them (by putting $scripts into $replace_files).
177#
178# - Otherwise, we guess that it's better not to replace them, because the
179# improvements that our versions of the scripts provide are minimal, so
180# it's better to avoid possibly breaking any changes made upstream by
181# Citrix.
182case $md5sums in
183 cf09a68d9f8b434e79a4c83b01a3bb4b,395866df1b0b20c12c4dd2f7de0ecdb4,9d493545ae81463239d3162cbc798852,862d0939b441de9264a900628e950fe9,21f85db25599d7f026cd489385d58aa6)
184 keep_files=
185 replace_files=$scripts
186 printf "\nVerified host scripts from XenServer 6.0.0.\n"
187 ;;
0d6fc641
BP
188
189 c5f48246577a17cf1b971fb5ce4e920b,2e2c912f86f9c536c89adc34ff3c2b2b,28d3ff72d72bdec4f37d70699f5edb76,67e1d0af16fc1ddf10009c5c063ad2ba,f3feff30aa3b3f8b514664a96a8dc0ab)
190 keep_files=
191 replace_files=$scripts
192 printf "\nVerified host scripts from XenServer 5.6-SP2.\n"
193 ;;
7b007006
BP
194
195 c5f48246577a17cf1b971fb5ce4e920b,2e2c912f86f9c536c89adc34ff3c2b2b,28d3ff72d72bdec4f37d70699f5edb76,67e1d0af16fc1ddf10009c5c063ad2ba,24bae6906d182ba47668174f8e480cc6)
196 keep_files=
197 replace_files=$scripts
198 printf "\nVerified host scripts from XenServer 5.6-FP1.\n"
199 ;;
200
201 *)
202 keep_files=$scripts
203 replace_files=
204 cat <<EOF
205
206The host scripts on this machine are not those of any supported
207version of XenServer. On XenServer earlier than 5.6-FP1, your Open
208vSwitch installation will not work. On XenServer 5.6-FP1 or later,
209Open vSwitch is not verified to work, which could lead to unexpected
210behavior.
211
212EOF
213 ;;
214esac
215
216if grep -F net.ipv4.conf.all.arp_filter /etc/sysctl.conf >/dev/null 2>&1; then :; else
217 cat >>/etc/sysctl.conf <<EOF
218# This works around an issue in xhad, which binds to a particular
219# Ethernet device, which in turn causes ICMP port unreachable messages
220# if packets are received are on the wrong interface, which in turn
221# can happen if we send out ARP replies on every interface (as Linux
222# does by default) instead of just on the interface that has the IP
223# address being ARPed for, which this sysctl setting in turn works
224# around.
225#
226# Bug #1378.
227net.ipv4.conf.all.arp_filter = 1
228EOF
229fi
230
231if test ! -e /etc/openvswitch/conf.db; then
232 install -d -m 755 -o root -g root /etc/openvswitch
233
234 # Create ovs-vswitchd config database
ea523221 235 ovsdb-tool -vconsole:off create /etc/openvswitch/conf.db \
7b007006
BP
236 /usr/share/openvswitch/vswitch.ovsschema
237
238 # Create initial table in config database
ea523221 239 ovsdb-tool -vconsole:off transact /etc/openvswitch/conf.db \
7b007006
BP
240 '[{"op": "insert", "table": "Open_vSwitch", "row": {}}]' \
241 > /dev/null
242fi
243
244# Create default or update existing /etc/sysconfig/openvswitch.
245SYSCONFIG=/etc/sysconfig/openvswitch
246TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template
247if [ ! -e $SYSCONFIG ]; then
248 cp $TEMPLATE $SYSCONFIG
249else
250 for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
251 do
252 if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
253 echo >> $SYSCONFIG
254 sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
255 fi
256 done
257fi
258
259# Deliberately break %postun in broken OVS builds that revert original
260# XenServer scripts during rpm -U by moving the directory where it thinks
261# they are saved.
262if [ -d /usr/lib/openvswitch/xs-original ]; then
263 mkdir -p /usr/lib/openvswitch/xs-saved
264 mv /usr/lib/openvswitch/xs-original/* /usr/lib/openvswitch/xs-saved/ &&
265 rmdir /usr/lib/openvswitch/xs-original
266fi
267
268# Replace XenServer files by our versions.
269mkdir -p /usr/lib/openvswitch/xs-saved \
270 || printf "Could not create script backup directory.\n"
271for f in $replace_files; do
272 s=$(basename "$f")
273 t=$(readlink "$f")
274 if [ -f "$f" ] && [ "$t" != "/usr/share/openvswitch/scripts/$s" ]; then
275 mv "$f" /usr/lib/openvswitch/xs-saved/ \
276 || printf "Could not save original XenServer $s script\n"
277 ln -s "/usr/share/openvswitch/scripts/$s" "$f" \
278 || printf "Could not link to Open vSwitch $s script\n"
279 fi
280done
281
282# Clean up dangling symlinks to removed OVS replacement scripts no longer
283# provided by OVS. Any time a replacement script is removed from OVS,
284# it should be added here to ensure correct reversion from old versions of
285# OVS that don't clean up dangling symlinks during the uninstall phase.
5ca1ba48 286for orig in /usr/sbin/xen-bugtool $keep_files; do
7b007006
BP
287 saved=/usr/lib/openvswitch/xs-saved/$(basename "$orig")
288 [ -e "$saved" ] && mv -f "$saved" "$orig"
289done
290
291# Ensure all required services are set to run
292for s in openvswitch openvswitch-xapi-update; do
293 if chkconfig --list $s >/dev/null 2>&1; then
43d36678 294 chkconfig --del $s || printf "Could not remove $s init script.\n"
7b007006 295 fi
43d36678
GS
296 chkconfig --add $s || printf "Could not add $s init script.\n"
297 chkconfig $s on || printf "Could not enable $s init script.\n"
7b007006
BP
298done
299
300if [ "$1" = "1" ]; then # $1 = 1 for install
301 # Configure system to use Open vSwitch
302 /opt/xensource/bin/xe-switch-network-backend vswitch
303else # $1 = 2 for upgrade
304
305 mode=$(cat /etc/xensource/network.conf)
306 if [ "$mode" != "vswitch" ] && [ "$mode" != "openvswitch" ]; then
307 printf "\nThe server is not configured to run Open vSwitch. To run in\n"
308 printf "vswitch mode, you must run the following command:\n\n"
309 printf "\txe-switch-network-backend vswitch"
43d36678 310 printf "\n\n"
7b007006 311 fi
7b007006
BP
312fi
313
314%posttrans %{module_package}
315# Ensure that modprobe will find our modules.
316#
317# This has to be in %posttrans instead of %post because older versions
318# installed modules into a different directory and "rpm -U" runs the
319# new version's %post before removing the old version's files, so if
320# we use %post then depmod may find the old versions that are about to
321# be removed.
322depmod %{xen_version}
323
43d36678
GS
324mode=$(cat /etc/xensource/network.conf)
325if [ "$mode" = "vswitch" ] || [ "$mode" = "openvswitch" ]; then
326 printf "\nTo use the newly installed Open vSwitch kernel module, you\n"
327 printf "will either have to reboot the hypervisor or follow any\n"
328 printf "workarounds provided by your administration guide. Failure to do\n"
329 printf "so may result in incorrect operation."
330 printf "\n\n"
331fi
332
7b007006
BP
333%preun
334if [ "$1" = "0" ]; then # $1 = 0 for uninstall
335 # Configure system to use bridge
336 /opt/xensource/bin/xe-switch-network-backend bridge
337
338 # The "openvswitch" service should have been removed from
339 # "xe-switch-network-backend bridge".
340 for s in openvswitch openvswitch-xapi-update; do
341 if chkconfig --list $s >/dev/null 2>&1; then
342 chkconfig --del $s || printf "Could not remove $s init script."
343 fi
344 done
345fi
346
347%postun
348# Restore original XenServer scripts if the OVS equivalent no longer exists.
349# This works both in the upgrade and erase cases.
350# This lists every file that every version of OVS has ever replaced. Never
351# remove old files that OVS no longer replaces, or upgrades from old versions
352# will fail to restore the XS originals, leaving the system in a broken state.
353# Also be sure to add removed script paths to the %post scriptlet above to
354# prevent the same problem when upgrading from old versions of OVS that lack
355# this restore-on-upgrade logic.
356for f in \
357 /etc/xensource/scripts/vif \
7b007006
BP
358 /usr/sbin/xen-bugtool \
359 /opt/xensource/libexec/interface-reconfigure \
360 /opt/xensource/libexec/InterfaceReconfigure.py \
361 /opt/xensource/libexec/InterfaceReconfigureBridge.py \
362 /opt/xensource/libexec/InterfaceReconfigureVswitch.py
363do
364 # Only revert dangling symlinks.
365 if [ -h "$f" ] && [ ! -e "$f" ]; then
366 s=$(basename "$f")
367 if [ ! -f "/usr/lib/openvswitch/xs-saved/$s" ]; then
368 printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-saved\n" >&2
369 printf "Could not restore original XenServer script.\n" >&2
370 else
371 (rm -f "$f" \
372 && mv "/usr/lib/openvswitch/xs-saved/$s" "$f") \
373 || printf "Could not restore original XenServer $s script.\n" >&2
374 fi
375 fi
376done
377
378if [ "$1" = "0" ]; then # $1 = 0 for uninstall
379 rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
380 /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
381
382 rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
383 /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
384 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
385 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
386 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
387 /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo
388
389 # Remove all configuration files
390 rm -f /etc/openvswitch/conf.db
391 rm -f /etc/sysconfig/openvswitch
392 rm -f /etc/openvswitch/vswitchd.cacert
393
394 # Remove saved XenServer scripts directory, but only if it's empty
395 rmdir -p /usr/lib/openvswitch/xs-saved 2>/dev/null
396fi
397
398exit 0
399
400%files
401%defattr(-,root,root)
402/etc/init.d/openvswitch
403/etc/init.d/openvswitch-xapi-update
404/etc/xapi.d/plugins/openvswitch-cfg-update
405/etc/xensource/bugtool/*
406/etc/logrotate.d/openvswitch
407/etc/profile.d/openvswitch.sh
408/usr/share/openvswitch/python/
31f4bd47 409/usr/share/openvswitch/bugtool-plugins/*
2dc7590d 410/usr/share/openvswitch/scripts/ovs-check-dead-ifs
7b007006
BP
411/usr/share/openvswitch/scripts/ovs-xapi-sync
412/usr/share/openvswitch/scripts/interface-reconfigure
413/usr/share/openvswitch/scripts/InterfaceReconfigure.py
414/usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py
415/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
416/usr/share/openvswitch/scripts/vif
417/usr/share/openvswitch/scripts/sysconfig.template
418/usr/share/openvswitch/scripts/ovs-bugtool-*
419/usr/share/openvswitch/scripts/ovs-save
420/usr/share/openvswitch/scripts/ovs-ctl
421/usr/share/openvswitch/scripts/ovs-lib
422/usr/share/openvswitch/vswitch.ovsschema
31f4bd47 423/usr/sbin/ovs-bugtool
7b007006
BP
424/usr/sbin/ovs-vlan-bug-workaround
425/usr/sbin/ovs-vswitchd
426/usr/sbin/ovsdb-server
427/usr/bin/ovs-appctl
428/usr/bin/ovs-dpctl
429/usr/bin/ovs-ofctl
013061cf 430/usr/bin/ovs-parse-backtrace
7b007006
BP
431/usr/bin/ovs-pcap
432/usr/bin/ovs-tcpundump
433/usr/bin/ovs-vlan-test
434/usr/bin/ovs-vsctl
435/usr/bin/ovsdb-client
436/usr/bin/ovsdb-tool
437/usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.py
438/usr/share/man/man1/ovsdb-client.1.gz
439/usr/share/man/man1/ovsdb-server.1.gz
440/usr/share/man/man1/ovsdb-tool.1.gz
441/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
442/usr/share/man/man8/ovs-appctl.8.gz
31f4bd47 443/usr/share/man/man8/ovs-bugtool.8.gz
7b007006
BP
444/usr/share/man/man8/ovs-ctl.8.gz
445/usr/share/man/man8/ovs-dpctl.8.gz
446/usr/share/man/man8/ovs-ofctl.8.gz
013061cf 447/usr/share/man/man8/ovs-parse-backtrace.8.gz
7b007006
BP
448/usr/share/man/man1/ovs-pcap.1.gz
449/usr/share/man/man1/ovs-tcpundump.1.gz
450/usr/share/man/man8/ovs-vlan-bug-workaround.8.gz
451/usr/share/man/man8/ovs-vlan-test.8.gz
452/usr/share/man/man8/ovs-vsctl.8.gz
453/usr/share/man/man8/ovs-vswitchd.8.gz
454/var/lib/openvswitch
c649fe54 455/var/log/openvswitch
7b007006 456%exclude /usr/lib/xsconsole/plugins-base/*.py[co]
7b007006
BP
457%exclude /usr/share/openvswitch/scripts/*.py[co]
458%exclude /usr/share/openvswitch/python/*.py[co]
459%exclude /usr/share/openvswitch/python/ovs/*.py[co]
460%exclude /usr/share/openvswitch/python/ovs/db/*.py[co]
461
462%files %{module_package}
9b80f761 463/lib/modules/%{xen_version}/extra/openvswitch/openvswitch.ko