packaging: Fix Xen and RH packaging error that was introduced with ovs-test utility
[sliver-openvswitch.git] / rhel / openvswitch.spec.in
1 # Spec file for Open vSwitch on Red Hat Enterprise Linux.
2
3 # Copyright (C) 2009, 2010, 2011 Nicira Networks, 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 Name: openvswitch
11 Summary: Open vSwitch daemon/database/utilities
12 Group: System Environment/Daemons
13 URL: http://www.openvswitch.org/
14 Vendor: Nicira Networks, Inc.
15 Version: @VERSION@
16
17 License: ASL 2.0
18 Release: 1
19 Source: openvswitch-%{version}.tar.gz
20 Buildroot: /tmp/openvswitch-rpm
21 Requires: openvswitch-kmod, logrotate, python
22
23 %description
24 Open vSwitch provides standard network bridging functions and
25 support for the OpenFlow protocol for remote per-flow control of
26 traffic.
27
28 %prep
29 %setup -q
30
31 %build
32 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --enable-ssl %{?build_number}
33 make %{_smp_mflags}
34
35 %install
36 rm -rf $RPM_BUILD_ROOT
37 make install DESTDIR=$RPM_BUILD_ROOT
38 for base in \
39         etc_init.d_openvswitch \
40         etc_logrotate.d_openvswitch \
41         etc_sysconfig_network-scripts_ifup-ovs \
42         etc_sysconfig_network-scripts_ifdown-ovs \
43         usr_share_openvswitch_scripts_sysconfig.template; do
44     dst=$RPM_BUILD_ROOT/$(echo $base | sed 's,_,/,g')
45     install -d -m755 "$(dirname $dst)"
46     install rhel/$base "$dst"
47 done
48 docdir=$RPM_BUILD_ROOT/usr/share/doc/openvswitch-%{version}
49 install -d -m755 "$docdir"
50 install rhel/README.RHEL "$docdir"
51 install python/compat/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
52 install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
53
54 # Get rid of stuff we don't want to make RPM happy.
55 rm \
56     $RPM_BUILD_ROOT/usr/bin/ovs-controller \
57     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-controller.8 \
58     $RPM_BUILD_ROOT/usr/bin/ovs-test \
59     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8 \
60     $RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \
61     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8
62
63 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
64
65 %clean
66 rm -rf $RPM_BUILD_ROOT
67
68 %post
69 # Create default or update existing /etc/sysconfig/openvswitch.
70 SYSCONFIG=/etc/sysconfig/openvswitch
71 TEMPLATE=/usr/share/openvswitch/scripts/sysconfig.template
72 if [ ! -e $SYSCONFIG ]; then
73     cp $TEMPLATE $SYSCONFIG
74 else
75     for var in $(awk -F'[ :]' '/^# [_A-Z0-9]+:/{print $2}' $TEMPLATE)
76     do
77         if ! grep $var $SYSCONFIG >/dev/null 2>&1; then
78             echo >> $SYSCONFIG
79             sed -n "/$var:/,/$var=/p" $TEMPLATE >> $SYSCONFIG
80         fi
81     done
82 fi
83
84 # Ensure all required services are set to run
85 /sbin/chkconfig --add openvswitch
86 /sbin/chkconfig openvswitch on
87
88 %preun
89 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
90     /sbin/service openvswitch stop
91     /sbin/chkconfig --del openvswitch
92 fi
93
94 %postun
95 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
96     rm -f /etc/openvswitch/conf.db
97     rm -f /etc/sysconfig/openvswitch
98     rm -f /etc/openvswitch/vswitchd.cacert
99 fi
100
101 exit 0
102
103 %files
104 %defattr(-,root,root)
105 /etc/init.d/openvswitch
106 /etc/logrotate.d/openvswitch
107 /etc/sysconfig/network-scripts/ifup-ovs
108 /etc/sysconfig/network-scripts/ifdown-ovs
109 /etc/openvswitch/bugtool-plugins/*
110 /usr/bin/ovs-appctl
111 /usr/bin/ovs-benchmark
112 /usr/bin/ovs-dpctl
113 /usr/bin/ovs-ofctl
114 /usr/bin/ovs-parse-leaks
115 /usr/bin/ovs-pcap
116 /usr/bin/ovs-pki
117 /usr/bin/ovs-tcpundump
118 /usr/bin/ovs-vlan-test
119 /usr/bin/ovs-vsctl
120 /usr/bin/ovsdb-client
121 /usr/bin/ovsdb-tool
122 /usr/sbin/ovs-brcompatd
123 /usr/sbin/ovs-bugtool
124 /usr/sbin/ovs-vswitchd
125 /usr/sbin/ovsdb-server
126 /usr/share/man/man1/ovs-benchmark.1.gz
127 /usr/share/man/man1/ovs-pcap.1.gz
128 /usr/share/man/man1/ovs-tcpundump.1.gz
129 /usr/share/man/man1/ovsdb-client.1.gz
130 /usr/share/man/man1/ovsdb-server.1.gz
131 /usr/share/man/man1/ovsdb-tool.1.gz
132 /usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
133 /usr/share/man/man8/ovs-appctl.8.gz
134 /usr/share/man/man8/ovs-brcompatd.8.gz
135 /usr/share/man/man8/ovs-bugtool.8.gz
136 /usr/share/man/man8/ovs-ctl.8.gz
137 /usr/share/man/man8/ovs-dpctl.8.gz
138 /usr/share/man/man8/ovs-ofctl.8.gz
139 /usr/share/man/man8/ovs-parse-leaks.8.gz
140 /usr/share/man/man8/ovs-pki.8.gz
141 /usr/share/man/man8/ovs-vlan-test.8.gz
142 /usr/share/man/man8/ovs-vsctl.8.gz
143 /usr/share/man/man8/ovs-vswitchd.8.gz
144 /usr/share/openvswitch/python/
145 /usr/share/openvswitch/scripts/ovs-bugtool-*
146 /usr/share/openvswitch/scripts/ovs-ctl
147 /usr/share/openvswitch/scripts/ovs-lib.sh
148 /usr/share/openvswitch/scripts/ovs-save
149 /usr/share/openvswitch/scripts/sysconfig.template
150 /usr/share/openvswitch/vswitch.ovsschema
151 /usr/share/doc/openvswitch-%{version}/README.RHEL
152 /var/lib/openvswitch