Conditionalize the Python 2 subpackage, don't build it on EL > 7

This commit is contained in:
Miro Hrončok 2018-03-16 15:38:27 +01:00
parent 3ba81b438a
commit 459fddd27d

View File

@ -17,10 +17,16 @@
%bcond_without drpm %bcond_without drpm
%endif %endif
%if 0%{?rhel} > 7
%bcond_with python2
%else
%bcond_without python2
%endif
Summary: Creates a common metadata repository Summary: Creates a common metadata repository
Name: createrepo_c Name: createrepo_c
Version: 0.10.0 Version: 0.10.0
Release: 18%{?dist} Release: 19%{?dist}
License: GPLv2+ License: GPLv2+
URL: https://github.com/rpm-software-management/createrepo_c URL: https://github.com/rpm-software-management/createrepo_c
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
@ -75,6 +81,7 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
This package contains the createrepo_c C library and header files. This package contains the createrepo_c C library and header files.
These development files are for easy manipulation with a repodata. These development files are for easy manipulation with a repodata.
%if %{with python2}
%package -n python2-%{name} %package -n python2-%{name}
Summary: Python bindings for the createrepo_c library Summary: Python bindings for the createrepo_c library
%{?python_provide:%python_provide python2-%{name}} %{?python_provide:%python_provide python2-%{name}}
@ -85,6 +92,7 @@ Requires: %{name}-libs = %{version}-%{release}
%description -n python2-%{name} %description -n python2-%{name}
Python bindings for the createrepo_c library. Python bindings for the createrepo_c library.
%endif
%if %{with python3} %if %{with python3}
%package -n python3-%{name} %package -n python3-%{name}
@ -101,57 +109,72 @@ Python 3 bindings for the createrepo_c library.
%prep %prep
%autosetup -p1 %autosetup -p1
mkdir build %if %{with python2}
mkdir build-py2
%endif
%if %{with python3} %if %{with python3}
mkdir build-py3 mkdir build-py3
%endif %endif
%build %build
# Build createrepo_c with Python 2 # Build createrepo_c with Python 2
pushd build %if %{with python2}
pushd build-py2
%cmake ../ %cmake ../
make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}" make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}"
%if %{without python3}
# Build C documentation
make doc-c
%endif
popd popd
%endif
# Build createrepo_c with Pyhon 3 # Build createrepo_c with Pyhon 3
%if %{with python3} %if %{with python3}
pushd build-py3 pushd build-py3
%cmake ../ -DPYTHON_DESIRED:str=3 %cmake ../ -DPYTHON_DESIRED:str=3
make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}" make %{?_smp_mflags} RPM_OPT_FLAGS="%{optflags}"
# Build C documentation
make doc-c
popd popd
%endif %endif
# Build C documentation
pushd build
make doc-c
popd
%check %check
pushd build %if %{with python2}
pushd build-py2
%if %{without python3}
# Compile C tests # Compile C tests
make tests make tests
%endif
# Run Python 2 tests # Run Python 2 tests
make ARGS="-V" test make ARGS="-V" test
popd popd
%endif
# Run Python 3 tests # Run Python 3 tests
%if %{with python3} %if %{with python3}
pushd build-py3 pushd build-py3
# Compile C tests
make tests
# Run Python 3 tests
make ARGS="-V" test make ARGS="-V" test
popd popd
%endif %endif
%install %install
%if %{with python2}
pushd build pushd build-py2
# Install createrepo_c with Python 2 # Install createrepo_c with Python 2
make install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
popd popd
%endif
# Install createrepo_c with Python 3
%if %{with python3} %if %{with python3}
pushd build-py3 pushd build-py3
# Install createrepo_c with Python 3
make install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
popd popd
%endif %endif
@ -175,13 +198,19 @@ popd
%{_libdir}/lib%{name}.so.* %{_libdir}/lib%{name}.so.*
%files devel %files devel
%doc build/doc/html %if %{with python3}
%doc build-py3/doc/html
%else
%doc build-py2/doc/html
%endif
%{_libdir}/lib%{name}.so %{_libdir}/lib%{name}.so
%{_libdir}/pkgconfig/%{name}.pc %{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/%{name}/ %{_includedir}/%{name}/
%if %{with python2}
%files -n python2-%{name} %files -n python2-%{name}
%{python2_sitearch}/%{name}/ %{python2_sitearch}/%{name}/
%endif
%if %{with python3} %if %{with python3}
%files -n python3-%{name} %files -n python3-%{name}
@ -189,6 +218,10 @@ popd
%endif %endif
%changelog %changelog
* Fri Mar 16 2018 Miro Hrončok <mhroncok@redhat.com> - 0.10.0-19
- Conditionalize the Python 2 subpackage
- Don't build the Python 2 subpackage on EL > 7
* Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.10.0-18 * Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.10.0-18
- Update Python 2 dependency declarations to new packaging standards - Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3) (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)