rhel/openvswitch.spec: Add SELinux policy.
[cascardo/ovs.git] / rhel / openvswitch.spec.in
index 5d26d59..fbca1ef 100644 (file)
@@ -1,6 +1,6 @@
 # Spec file for Open vSwitch on Red Hat Enterprise Linux.
 
-# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
@@ -22,8 +22,9 @@ License: ASL 2.0
 Release: 1
 Source: openvswitch-%{version}.tar.gz
 Buildroot: /tmp/openvswitch-rpm
-Requires: logrotate, python
+Requires: logrotate, python >= 2.7, python-six
 BuildRequires: openssl-devel
+BuildRequires: checkpolicy, selinux-policy-devel
 
 %bcond_without check
 
@@ -32,12 +33,31 @@ Open vSwitch provides standard network bridging functions and
 support for the OpenFlow protocol for remote per-flow control of
 traffic.
 
+%package devel
+Summary:        Open vSwitch development package
+Group:          Development/Libraries
+
+%description devel
+This package provides openvswitch headers and libopenvswitch for developers.
+
+%package selinux-policy
+Summary: Open vSwitch SELinux policy
+License: ASL 2.0
+BuildArch: noarch
+Requires: selinux-policy-targeted
+
+%description selinux-policy
+Tailored Open vSwitch SELinux policy
+
 %prep
 %setup -q
 
 %build
-./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} --enable-ssl
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} \
+    --libdir=%{_libdir} --enable-ssl --enable-shared
 make %{_smp_mflags}
+cd selinux
+make -f %{_datadir}/selinux/devel/Makefile
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -55,8 +75,8 @@ rhel_cp etc_sysconfig_network-scripts_ifup-ovs 0755
 rhel_cp etc_sysconfig_network-scripts_ifdown-ovs 0755
 rhel_cp usr_share_openvswitch_scripts_sysconfig.template 0644
 
-install python/compat/uuid.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
-install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
+install -p -m 644 -D selinux/openvswitch-custom.pp \
+    $RPM_BUILD_ROOT%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
 
 # Get rid of stuff we don't want to make RPM happy.
 rm \
@@ -67,15 +87,37 @@ rm \
     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-test.8 \
     $RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \
     $RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \
-    $RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8
-(cd "$RPM_BUILD_ROOT" && rm -rf usr/lib)
+    $RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8 \
+    $RPM_BUILD_ROOT/usr/bin/ovn-* \
+    $RPM_BUILD_ROOT/usr/share/man/man?/ovn-* \
+    $RPM_BUILD_ROOT/usr/share/openvswitch/ovn-* \
+    $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovn-*
+(cd "$RPM_BUILD_ROOT" && rm -rf usr/%{_lib}/*.la)
+(cd "$RPM_BUILD_ROOT" && rm -rf usr/include)
 
 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
 
+copy_headers() {
+    src=$1
+    dst=$RPM_BUILD_ROOT/$2
+    install -d -m 0755 $dst
+    install -m 0644 $src/*.h $dst
+}
+copy_headers include %{_includedir}/openvswitch
+copy_headers include/openflow %{_includedir}/openvswitch/openflow
+copy_headers include/openvswitch %{_includedir}/openvswitch/openvswitch
+copy_headers include/sparse %{_includedir}/openvswitch/sparse
+copy_headers include/sparse/arpa %{_includedir}/openvswitch/sparse/arpa
+copy_headers include/sparse/netinet %{_includedir}/openvswitch/sparse/netinet
+copy_headers include/sparse/sys %{_includedir}/openvswitch/sparse/sys
+copy_headers lib %{_includedir}/openvswitch/lib
+
+install -D -m 0644 lib/.libs/libopenvswitch.a \
+    $RPM_BUILD_ROOT/%{_libdir}/libopenvswitch.a
+
 %check
 %if %{with check}
-    if make check TESTSUITEFLAGS='%{_smp_mflags}' ||
-       make check TESTSUITEFLAGS='--recheck'; then :;
+    if make check TESTSUITEFLAGS='%{_smp_mflags}' RECHECK=yes; then :;
     else
         cat tests/testsuite.log
         exit 1
@@ -105,6 +147,9 @@ fi
 /sbin/chkconfig --add openvswitch
 /sbin/chkconfig openvswitch on
 
+%post selinux-policy
+/usr/sbin/semodule -i %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp &> /dev/null || :
+
 %preun
 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
     /sbin/service openvswitch stop
@@ -118,16 +163,23 @@ if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
     rm -f /etc/openvswitch/vswitchd.cacert
 fi
 
+%postun selinux-policy
+if [ $1 -eq 0 ] ; then
+  /usr/sbin/semodule -r openvswitch-custom &> /dev/null || :
+fi
+
 exit 0
 
 %files
 %defattr(-,root,root)
+%dir /etc/openvswitch
+/etc/bash_completion.d/ovs-appctl-bashcomp.bash
+/etc/bash_completion.d/ovs-vsctl-bashcomp.bash
 /etc/init.d/openvswitch
 %config(noreplace) /etc/logrotate.d/openvswitch
 /etc/sysconfig/network-scripts/ifup-ovs
 /etc/sysconfig/network-scripts/ifdown-ovs
 /usr/bin/ovs-appctl
-/usr/bin/ovs-benchmark
 /usr/bin/ovs-dpctl
 /usr/bin/ovs-dpctl-top
 /usr/bin/ovs-docker
@@ -135,16 +187,17 @@ exit 0
 /usr/bin/ovs-parse-backtrace
 /usr/bin/ovs-pcap
 /usr/bin/ovs-pki
+/usr/bin/ovs-tcpdump
 /usr/bin/ovs-tcpundump
 /usr/bin/ovs-vlan-test
 /usr/bin/ovs-vsctl
 /usr/bin/ovsdb-client
 /usr/bin/ovsdb-tool
 /usr/bin/vtep-ctl
+%{_libdir}/lib*.so.*
 /usr/sbin/ovs-bugtool
 /usr/sbin/ovs-vswitchd
 /usr/sbin/ovsdb-server
-/usr/share/man/man1/ovs-benchmark.1.gz
 /usr/share/man/man1/ovs-pcap.1.gz
 /usr/share/man/man1/ovs-tcpundump.1.gz
 /usr/share/man/man1/ovsdb-client.1.gz
@@ -160,6 +213,7 @@ exit 0
 /usr/share/man/man8/ovs-ofctl.8.gz
 /usr/share/man/man8/ovs-parse-backtrace.8.gz
 /usr/share/man/man8/ovs-pki.8.gz
+/usr/share/man/man8/ovs-tcpdump.8.gz
 /usr/share/man/man8/ovs-vlan-test.8.gz
 /usr/share/man/man8/ovs-vsctl.8.gz
 /usr/share/man/man8/ovs-vswitchd.8.gz
@@ -175,7 +229,17 @@ exit 0
 /usr/share/openvswitch/scripts/sysconfig.template
 /usr/share/openvswitch/vswitch.ovsschema
 /usr/share/openvswitch/vtep.ovsschema
-%doc COPYING DESIGN INSTALL.SSL NOTICE README.md WHY-OVS FAQ NEWS
-%doc INSTALL.DPDK rhel/README.RHEL
+%doc COPYING DESIGN.md INSTALL.SSL.md NOTICE README.md WHY-OVS.md FAQ.md NEWS
+%doc INSTALL.DPDK.md rhel/README.RHEL README-native-tunneling.md
 /var/lib/openvswitch
 /var/log/openvswitch
+
+%files devel
+%{_libdir}/lib*.so
+%{_libdir}/lib*.a
+%{_libdir}/pkgconfig
+%{_includedir}/openvswitch/*
+
+%files selinux-policy
+%defattr(-,root,root)
+%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp