File openvswitch.spec of Package openvswitch
%define realname openvswitch
%define realver 3.3.3
%define srcext tar.gz
%define ver_minor %(VER='%{version}'; echo ${VER%%.*})
%define so_ver 0
%bcond_without dpdk
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
%if ! %{defined _rundir}
%define _rundir /var/run
%endif
%define python3_pkg python3
%define python3 %{_bindir}/python3
%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif
%if ! 0%{?python3_sitearch:1}
%define python3_sitearch %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(True))')
%endif
Name: %{realname}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: Apache-2.0
Group: Productivity/Networking/Routing
URL: http://openvswitch.org/
Summary: Production Quality, Multilayer Open Virtual Switch
# Install-time parameters
Requires: policycoreutils
Requires: %{name}-python
# Build-time parameters
BuildRequires: autoconf automake libtool
BuildRequires: gcc-c++
BuildRequires: pkg-config
BuildRequires: libbpf-devel
BuildRequires: systemd-devel
BuildRequires: openssl-devel
BuildRequires: libcap-ng-devel
BuildRequires: libnuma-devel
BuildRequires: perl%{?suse_version:-base}
BuildRequires: %{python3_pkg}%{?suse_version:-base} >= 3.4
BuildRequires: %{python3_pkg}-six
BuildRequires: %{python3_pkg}-pyparsing >= 2.0.2
%if 0%{?suse_version}
BuildRequires: kernel-syms modutils
%endif
# DPDK support
%if %{with dpdk}
# dpdk is built with pcap support
BuildRequires: dpdk-devel-static >= 20.11 libpcap-devel libxdp-devel
BuildRequires: libnl3-devel
BuildRequires: dbus-1-devel
%if 0%{?rhel}
BuildRequires: rdma-core-devel
%endif
%endif
# SELinux @ RHEL/CentOS
%if 0%{?rhel}
BuildRequires: libxdp-devel
BuildRequires: selinux-policy-devel
%endif
# Documentation
BuildRequires: %{python3_pkg}-setuptools %{python3_pkg}-packaging
%if 0%{?suse_version}
BuildRequires: %{python3_pkg}-Sphinx
%else
BuildRequires: %{python3_pkg}-sphinx
%endif
BuildRequires: graphviz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: http://openvswitch.org/releases/%{realname}-%{realver}.%{srcext}
%description
Open vSwitch is a multilayer software switch licensed under the open
source Apache 2 license. Our goal is to implement a production
quality switch platform that supports standard management interfaces
and opens the forwarding functions to programmatic extension and
control.
Open vSwitch is well suited to function as a virtual switch in VM
environments. In addition to exposing standard control and visibility
interfaces to the virtual networking layer, it was designed to support
distribution across multiple physical servers. Open vSwitch supports
multiple Linux-based virtualization technologies including
Xen/XenServer, KVM, and VirtualBox.
The bulk of the code is written in platform-independent C and is
easily ported to other environments. The current release of Open
vSwitch supports the following features:
* Standard 802.1Q VLAN model with trunk and access ports
* NIC bonding with or without LACP on upstream switch
* NetFlow, sFlow(R), and mirroring for increased visibility
* QoS (Quality of Service) configuration, plus policing
* GRE, GRE over IPSEC, VXLAN, and LISP tunneling
* 802.1ag connectivity fault management
* OpenFlow 1.0 plus numerous extensions
* Transactional configuration database with C and Python bindings
* High-performance forwarding using a Linux kernel module
%package devel
Group: Development/Languages/C and C++
Summary: Development files for %{name}
Requires: %{name} = %{version}
%description devel
Development files for %{name}
%package bugtool
Group: Productivity/Networking/Routing
Summary: Open vSwitch bug reporting utility
Requires: python(abi) = %{py3_ver}
%description bugtool
Open vSwitch bug reporting utility generates a debug bundle with useful
information about Open vSwitch
%package python
Group: Productivity/Networking/Routing
Summary: Python bindings for Open vSwitch database
Provides: python-openvswitch
Requires: python(abi) = %{py3_ver}
%description python
Python bindings for Open vSwitch database.
%prep
%setup -q -n %{realname}-%{realver}
%build
_CFLAGS='%{optflags} %{?gcc_lto} -I%{_includedir}/bpf'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto}'
_LIBS='-lssl -lcrypto -lpcap -lz'
%configure \
--enable-shared \
--disable-static \
--enable-ndebug \
--enable-afxdp \
--with-rundir=%{_rundir} \
--with-dbdir=%{_localstatedir}/lib/%{name} \
%if %{with dpdk}
--with-dpdk=static \
%endif
CFLAGS="$_CFLAGS" \
CXXFLAGS="$_CFLAGS" \
LDFLAGS="$_LDFLAGS" \
LIBS="$_LIBS"
%{__make} %{?_smp_mflags}
%if 0%{?rhel}
# Build SELinux policy
%{__sed} \
-e '/_dpdk@$/d' \
-e 's/@VERSION@/%{version}/' \
selinux/openvswitch-custom.te.in > selinux/openvswitch-custom.te
%{__make} -C selinux -f %{_datadir}/selinux/devel/Makefile
%endif
%install
%{__make} install DESTDIR=%{buildroot}
# Install other stuff
%{__install} -d -m755 %{buildroot}%{_localstatedir}/log/openvswitch
%{__install} -d -m755 %{buildroot}%{_localstatedir}/log/ovs-bugtool
# systemd units
for unitfile in rhel/*.service; do
%{__install} -D -m644 ${unitfile} %{buildroot}%{_unitdir}/${unitfile##*_}
done
%{__install} -D -m755 rhel/etc_init.d_openvswitch %{buildroot}%{_datadir}/openvswitch/scripts/openvswitch.init
%{__install} -D -m644 rhel/usr_share_openvswitch_scripts_systemd_sysconfig.template %{buildroot}%{_sysconfdir}/sysconfig/openvswitch
%{__install} -d -m755 %{buildroot}%{_tmpfilesdir}
echo 'd /run/%{name}' > %{buildroot}%{_tmpfilesdir}/openvswitch.conf
%{__install} -D -m644 rhel/etc_logrotate.d_openvswitch %{buildroot}%{_sysconfdir}/logrotate.d/openvswitch
%if 0%{?rhel}
%{__install} -D -m755 rhel/etc_sysconfig_network-scripts_ifup-ovs %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
%{__install} -D -m755 rhel/etc_sysconfig_network-scripts_ifdown-ovs %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
# Install SELinux policy
%{__install} -p -m 644 -D selinux/openvswitch-custom.pp %{buildroot}%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
%endif
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%license LICENSE
%doc AUTHORS.rst MAINTAINERS.rst NEWS NOTICE README.rst
%{_bindir}/*
%{_sbindir}/*
%{_libdir}/*-%{ver_minor}.so.%{?so_ver}*
%{_datadir}/openvswitch
%dir %{_localstatedir}/lib/%{name}/pki
%dir %{_localstatedir}/lib/%{name}
%dir %{_localstatedir}/log/%{name}
%config %attr(0644,-,-) %{_sysconfdir}/bash_completion.d/*.bash
%{_unitdir}/*.service
%{_tmpfilesdir}/openvswitch.conf
%config(noreplace) %{_sysconfdir}/sysconfig/openvswitch
%config %{_sysconfdir}/logrotate.d/openvswitch
%if 0%{?rhel}
%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
%{_sysconfdir}/sysconfig/network-scripts/ifdown-ovs
%dir %{_datadir}/selinux/packages/%{name}
%dir %{_datadir}/selinux/packages
%dir %{_datadir}/selinux
%{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
%endif
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*
%if 0%{?rhel} >= 7 || 0%{?suse_version}
%exclude %{_sbindir}/ovs-bugtool
%exclude %{_mandir}/man8/ovs-bugtool.8*
%exclude %{_datadir}/openvswitch/bugtool-plugins
%exclude %{_datadir}/openvswitch/scripts/ovs-bugtool-*
%exclude %{_datadir}/openvswitch/python
%endif
%files devel
%defattr(-,root,root)
%dir %{_includedir}/openflow
%dir %{_includedir}/openvswitch
%{_includedir}/openflow/*.h
%{_includedir}/openvswitch/*.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/*.so
%{_libdir}/*.a
%exclude %{_libdir}/*.la
%doc %{_mandir}/man7/*
%files bugtool
%defattr(-,root,root)
%{_sbindir}/ovs-bugtool
%{_datadir}/openvswitch/bugtool-plugins
%{_datadir}/openvswitch/scripts/ovs-bugtool-*
%doc %{_mandir}/man8/ovs-bugtool.8*
%dir %{_localstatedir}/log/ovs-bugtool
%files python
%defattr(-,root,root)
%{_datadir}/openvswitch/python
%if 0%{?rhel}
%post
/usr/sbin/semodule -i %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp &> /dev/null || :
/sbin/ldconfig
%postun
if [ ${1} -eq 0 ]; then
/usr/sbin/semodule -r openvswitch-custom &> /dev/null || :
fi
/sbin/ldconfig
%else
%pre
%{service_add_pre openvswitch-ipsec.service}
%{service_add_pre openvswitch.service}
%{service_add_pre ovs-delete-transient-ports.service}
%{service_add_pre ovsdb-server.service}
%post
/sbin/ldconfig
%{tmpfiles_create %{_tmpfilesdir}/openvswitch.conf}
%{service_add_post openvswitch-ipsec.service}
%{service_add_post openvswitch.service}
%{service_add_post ovs-delete-transient-ports.service}
%{service_add_post ovsdb-server.service}
%preun
%{service_del_preun openvswitch-ipsec.service}
%{service_del_preun openvswitch.service}
%{service_del_preun ovs-delete-transient-ports.service}
%{service_del_preun ovsdb-server.service}
%postun
/sbin/ldconfig
%{service_del_postun openvswitch-ipsec.service}
%{service_del_postun openvswitch.service}
%{service_del_postun ovs-delete-transient-ports.service}
%{service_del_postun ovsdb-server.service}
%endif
%changelog