diff --git a/pyparted.spec b/pyparted.spec index fe36fb1..2487df5 100644 --- a/pyparted.spec +++ b/pyparted.spec @@ -1,10 +1,42 @@ -%define with_python3 1 +%if 0%{?rhel} +%if %{rhel} <= 7 +# disable python3 by default +%bcond_with python3 +%else +%bcond_without python3 +%endif + +%if %{rhel} > 7 +# disable python2 by default +%bcond_with python2 +%else +%bcond_without python2 +%endif +%endif + +%if 0%{?fedora} +%if %{fedora} < 23 +# disable python3 by default +%bcond_with python3 +%else +%bcond_without python3 +%endif + +%if %{fedora} > 28 +# disable python2 by default +%bcond_with python2 +%else +%bcond_without python2 +%endif +%endif + +%global py2dir python2-build Summary: Python module for GNU parted Name: pyparted Epoch: 1 Version: 3.11.0 -Release: 13%{?dist} +Release: 14%{?dist} License: GPLv2+ Group: System Environment/Libraries URL: https://github.com/rhinstaller/pyparted @@ -12,22 +44,27 @@ URL: https://github.com/rhinstaller/pyparted Source0: https://github.com/rhinstaller/pyparted/archive/%{name}-%{version}.tar.gz BuildRequires: gcc -BuildRequires: python2-devel -BuildRequires: python2-six -%if 0%{?with_python3} -BuildRequires: python3-devel -BuildRequires: python3-six -%endif BuildRequires: parted-devel >= 3.2-18 BuildRequires: pkgconfig BuildRequires: e2fsprogs +%if %{with python3} +BuildRequires: python3-devel +BuildRequires: python3-six +%endif + +%if %{with python2} +BuildRequires: python2-devel +BuildRequires: python2-six +%endif + %global _description\ Python module for the parted library. It is used for manipulating\ partition tables. %description %_description +%if %{with python2} %package -n python2-pyparted Summary: %summary %{?python_provide:%python_provide python2-pyparted} @@ -37,8 +74,9 @@ Provides: pyparted%{?_isa} = %{epoch}:%{version}-%{release} Obsoletes: pyparted < %{epoch}:%{version}-%{release} %description -n python2-pyparted %_description +%endif -%if 0%{?with_python3} +%if %{with python3} %package -n python3-pyparted Summary: Python 3 module for GNU parted Group: System Environment/Libraries @@ -51,46 +89,47 @@ partition tables. This package provides Python 3 bindings for parted. %prep %setup -q -%if 0%{?with_python3} -rm -rf %{py3dir} -cp -a . %{py3dir} +%if %{with python2} +rm -rf ../%{py2dir} +mkdir -p ../%{py2dir} +cp -a . ../%{py2dir} +mv ../%{py2dir} . %endif %build -PYTHON=python2 make %{?_smp_mflags} - -%if 0%{?with_python3} -pushd %{py3dir} +%if %{with python3} PYTHON=python3 make %{?_smp_mflags} +%endif + +%if %{with python2} +pushd %{py2dir} +PYTHON=python2 make %{?_smp_mflags} popd %endif %check -PYTHON=python2 make test - -%if 0%{?with_python3} -pushd %{py3dir} +%if %{with python3} PYTHON=python3 make test +%endif + +%if %{with python2} +pushd %{py2dir} +PYTHON=python2 make test popd %endif %install -rm -rf %{buildroot} -PYTHON=python2 make install DESTDIR=%{buildroot} - -%if 0%{?with_python3} -pushd %{py3dir} +%if %{with python3} PYTHON=python3 make install DESTDIR=%{buildroot} +%endif + +%if %{with python2} +pushd %{py2dir} +PYTHON=python2 make install DESTDIR=%{buildroot} popd %endif -%files -n python2-pyparted -%doc AUTHORS COPYING NEWS README TODO -%{python2_sitearch}/_ped.so -%{python2_sitearch}/parted -%{python2_sitearch}/%{name}-%{version}-*.egg-info - -%if 0%{?with_python3} +%if %{with python3} %files -n python3-pyparted %doc AUTHORS COPYING NEWS README TODO %{python3_sitearch}/_ped.*.so @@ -98,7 +137,20 @@ popd %{python3_sitearch}/%{name}-%{version}-*.egg-info %endif +%if %{with python2} +%files -n python2-pyparted +%doc AUTHORS COPYING NEWS README TODO +%{python2_sitearch}/_ped.so +%{python2_sitearch}/parted +%{python2_sitearch}/%{name}-%{version}-*.egg-info +%endif + %changelog +* Wed Jul 25 2018 David Cantrell - 1:3.11.0-14 +- Conditionalize python2 and python3 builds to make the SRPM more portable + across releases. On RHEL > 7 and Fedora > 28, do not build for python2. + On RHEL <= 7, do not build for python3. + * Tue Jul 24 2018 David Cantrell - 1:3.11.0-13 - Use 'python2' when building the Python 2.x bindings (#1605566) - BuildRequires gcc (#1605566)