[ovs-dev] [PATCH v3] packaging: Make Fedora spec file CentOS compatible

Leif Madsen lmadsen at redhat.com
Mon Mar 6 20:46:43 UTC 2017


On CentOS, the package names aren't prefixed with python2, but rather
are prefixed with simply python. This change addresses that and fixes
up some documentation that was outdated, and updates the Vagrantfile
to use the proper spec file and package names.

Signed-off-by: Leif Madsen <lmadsen at redhat.com>
---
 Documentation/intro/install/fedora.rst |  4 +--
 Vagrantfile                            |  6 ++--
 rhel/openvswitch-fedora.spec.in        | 54 ++++++++++++++++++++++++----------
 3 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/Documentation/intro/install/fedora.rst b/Documentation/intro/install/fedora.rst
index 0ecd255..ffc77a4 100644
--- a/Documentation/intro/install/fedora.rst
+++ b/Documentation/intro/install/fedora.rst
@@ -42,8 +42,8 @@ in the :doc:`general`. Specific packages (by package name) include:
 - rpm-build
 - autoconf automake libtool
 - systemd-units openssl openssl-devel
-- python-devel python3-devel
-- python python-twisted-core python-zope-interface python-six
+- python2-devel python3-devel
+- python2 python2-twisted python2-zope-interface python2-six
 - desktop-file-utils
 - groff graphviz
 - procps-ng
diff --git a/Vagrantfile b/Vagrantfile
index 8439918..d2b7ecb 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -9,7 +9,7 @@ $bootstrap_fedora = <<SCRIPT
 dnf -y update
 dnf -y install autoconf automake openssl-devel libtool \
                python-devel python3-devel \
-               python-twisted-core python-zope-interface \
+               python-twisted python-zope-interface \
                desktop-file-utils groff graphviz rpmdevtools nc curl \
                wget python-six pyftpdlib checkpolicy selinux-policy-devel \
                libcap-ng-devel kernel-devel-`uname -r` ethtool python-tftpy
@@ -80,8 +80,8 @@ PACKAGE_VERSION=`autom4te -l Autoconf -t 'AC_INIT:$2' /vagrant/configure.ac`
 make && make dist
 rpmdev-setuptree
 cp openvswitch-$PACKAGE_VERSION.tar.gz $HOME/rpmbuild/SOURCES
-rpmbuild --bb -D "kversion `uname -r`" /vagrant/rhel/openvswitch-kmod-rhel6.spec
-rpmbuild --bb --without check /vagrant/rhel/openvswitch.spec
+rpmbuild --bb -D "kversion `uname -r`" /vagrant/rhel/openvswitch-kmod-fedora.spec
+rpmbuild --bb --without check /vagrant/rhel/openvswitch-fedora.spec
 rpm -e openvswitch
 rpm -ivh $HOME/rpmbuild/RPMS/x86_64/openvswitch-$PACKAGE_VERSION-1.x86_64.rpm
 systemctl enable openvswitch
diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index d100f49..09d4f37 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -28,6 +28,8 @@
 %bcond_without libcapng
 # To enable DPDK support, specify '--with dpdk' when building
 %bcond_with dpdk
+# Enable Python 3 building when distribution not default supported
+%bcond_with build_python3
 
 # Enable PIE, bz#955181
 %global _hardened_build 1
@@ -38,6 +40,17 @@
 %define _rundir /run
 %endif
 
+# define the python package prefix based on distribution version so that we can
+# simultaneously support RHEL-based and later Fedora versions in this spec file.
+%if 0%{?fedora} >= 25
+%define _py2 python2
+%endif
+
+%if 0%{?rhel} || 0%{?fedora} < 25
+%define _py2 python
+%endif
+
+
 Name: openvswitch
 Summary: Open vSwitch
 Group: System Environment/Daemons
@@ -53,16 +66,16 @@ Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz
 
 BuildRequires: autoconf automake libtool
 BuildRequires: systemd-units openssl openssl-devel
-BuildRequires: python2-devel
+BuildRequires: %{_py2}-devel
+%if 0%{?fedora} > 22 || %{with build_python3}
 BuildRequires: python3-devel
+%endif
 BuildRequires: desktop-file-utils
 BuildRequires: groff graphviz
 BuildRequires: checkpolicy, selinux-policy-devel
 # make check dependencies
-%if %{with check}
-BuildRequires: python2-twisted python2-zope-interface python2-six
+BuildRequires: %{_py2}-twisted%{?rhel:-core} %{_py2}-zope-interface %{_py2}-six
 BuildRequires: procps-ng
-%endif
 %if %{with libcapng}
 BuildRequires: libcap-ng libcap-ng-devel
 %endif
@@ -81,6 +94,7 @@ Requires(preun): systemd-units
 Requires(postun): systemd-units
 Obsoletes: openvswitch-controller <= 0:2.1.0-1
 
+# to skip running checks, pass --without check
 %bcond_without check
 %bcond_with check_datapath_kernel
 
@@ -98,33 +112,35 @@ Requires: selinux-policy-targeted
 %description selinux-policy
 Tailored Open vSwitch SELinux policy
 
-%package -n python2-openvswitch
+%package -n %{_py2}-openvswitch
 Summary: Open vSwitch python2 bindings
 License: ASL 2.0
 BuildArch: noarch
-Requires: python2
-Requires: python2-six
-Provides: python-openvswitch = %{version}-%{release}
-
-%description -n python2-openvswitch
+Requires: %{_py2}
+Requires: %{_py2}-six
+%{?python_provide:%python_provide python2-openvswitch = %{version}-%{release}}
+%description -n %{_py2}-openvswitch
 Python bindings for the Open vSwitch database
 
+%if 0%{?fedora} > 22 || %{with build_python3}
 %package -n python3-openvswitch
 Summary: Open vSwitch python3 bindings
 License: ASL 2.0
 BuildArch: noarch
 Requires: python3
 Requires: python3-six
+%{?python_provide:%python_provide python3-openvswitch = %{version}-%{release}}
 
 %description -n python3-openvswitch
 Python bindings for the Open vSwitch database
+%endif
 
 %package test
 Summary: Open vSwitch testing utilities
 License: ASL 2.0
 BuildArch: noarch
-Requires: python2-openvswitch = %{version}-%{release}
-Requires: python2 python2-twisted
+Requires: %{_py2}-openvswitch = %{version}-%{release}
+Requires: %{_py2} %{_py2}-twisted
 
 %description test
 Utilities that are useful to diagnose performance and connectivity
@@ -182,7 +198,7 @@ Utilities that are use to diagnose and manage the OVN components.
 %package ovn-docker
 Summary: Open vSwitch - Open Virtual Network support
 License: ASL 2.0
-Requires: openvswitch openvswitch-ovn-common python2-openvswitch
+Requires: openvswitch openvswitch-ovn-common %{_py2}-openvswitch
 
 %description ovn-docker
 Docker network plugins for OVN.
@@ -238,11 +254,15 @@ install -p -m 0755 rhel/etc_sysconfig_network-scripts_ifup-ovs \
         $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/network-scripts/ifup-ovs
 
 install -d -m 0755 $RPM_BUILD_ROOT%{python2_sitelib}
-install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
 cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/* \
    $RPM_BUILD_ROOT%{python2_sitelib}
+
+%if 0%{?fedora} > 22 || %{with build_python3}
+install -d -m 0755 $RPM_BUILD_ROOT%{python3_sitelib}
 cp -a $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ovs \
    $RPM_BUILD_ROOT%{python3_sitelib}
+%endif
+
 rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/
 
 install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch
@@ -429,13 +449,15 @@ fi
 %defattr(-,root,root)
 %{_datadir}/selinux/packages/%{name}/openvswitch-custom.pp
 
-%files -n python2-openvswitch
+%files -n %{_py2}-openvswitch
 %{python2_sitelib}/ovs
 %doc COPYING
 
+%if 0%{?fedora} > 22 || %{with build_python3}
 %files -n python3-openvswitch
 %{python3_sitelib}/ovs
 %doc COPYING
+%endif
 
 %files test
 %{_bindir}/ovs-test
@@ -562,5 +584,7 @@ fi
 %{_unitdir}/ovn-controller-vtep.service
 
 %changelog
+* Mon Mar 06 2017 Leif Madsen <lmadsen at redhat.com>
+- Update compatibility issues with building Python 2 and 3 submodules
 * Wed Jan 12 2011 Ralf Spenneberg <ralf at os-s.net>
 - First build on F14
-- 
2.9.3



More information about the dev mailing list