Don't build the Python 2 subpackage on EL > 7

Some other minor SPEC improvements.
This commit is contained in:
Charalampos Stratakis 2018-03-16 16:36:13 +01:00
parent 335797bec9
commit 55e95fbe2d

View File

@ -1,5 +1,18 @@
%if 0%{?fedora} || 0%{?rhel} > 7 %if 0%{?fedora} || 0%{?rhel} > 7
%global with_python3 1 # Enable python3 build by default
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?rhel} > 7
# Disable python2 build by default
# disable also docs build as they require python2
%bcond_with python2
%bcond_with docs
%else
%bcond_without python2
%bcond_without docs
%endif %endif
%global oname rtslib-fb %global oname rtslib-fb
@ -9,20 +22,17 @@ License: ASL 2.0
Group: System Environment/Libraries Group: System Environment/Libraries
Summary: API for Linux kernel LIO SCSI target Summary: API for Linux kernel LIO SCSI target
Version: 2.1.fb67 Version: 2.1.fb67
Release: 2%{?dist} Release: 3%{?dist}
URL: https://fedorahosted.org/targetcli-fb/ URL: https://fedorahosted.org/targetcli-fb/
Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz
Source1: target.service Source1: target.service
Patch0: 0001-disable-xen_pvscsi.patch Patch0: 0001-disable-xen_pvscsi.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python2-devel epydoc python2-setuptools systemd-units BuildRequires: epydoc systemd-units
Requires(post): systemd Requires(post): systemd
Requires(preun): systemd Requires(preun): systemd
Requires(postun): systemd Requires(postun): systemd
%if 0%{?with_python3}
BuildRequires: python3-devel python3-setuptools
%endif
%global _description\ %global _description\
API for generic Linux SCSI kernel target. Includes the 'target'\ API for generic Linux SCSI kernel target. Includes the 'target'\
@ -31,42 +41,55 @@ service and targetctl tool for restoring configuration.\
%description %_description %description %_description
%if %{with python2}
%package -n python2-rtslib %package -n python2-rtslib
Summary: %summary Summary: %summary
Requires: python2-kmod python2-six python2-pyudev
BuildRequires: python2-devel
BuildRequires: python2-setuptools
Requires: python2-kmod
Requires: python2-six
Requires: python2-pyudev
%{?python_provide:%python_provide python2-rtslib} %{?python_provide:%python_provide python2-rtslib}
%description -n python2-rtslib %_description %description -n python2-rtslib %_description
%endif # with python2
%if %{with docs}
%package doc %package doc
Summary: Documentation for python-rtslib Summary: Documentation for python-rtslib
Group: Documentation
Requires: python2-rtslib = %{version}-%{release} Requires: python2-rtslib = %{version}-%{release}
%description doc %description doc
API documentation for rtslib, to configure the generic Linux SCSI API documentation for rtslib, to configure the generic Linux SCSI
multiprotocol kernel target. multiprotocol kernel target.
%endif # with docs
%if 0%{?with_python3} %if %{with python3}
%package -n python3-rtslib %package -n python3-rtslib
Summary: API for Linux kernel LIO SCSI target Summary: API for Linux kernel LIO SCSI target
Group: System Environment/Libraries
Requires: python3-kmod python3-six python3-pyudev BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: python3-kmod
Requires: python3-six
Requires: python3-pyudev
%description -n python3-rtslib %description -n python3-rtslib
API for generic Linux SCSI kernel target. API for generic Linux SCSI kernel target.
%endif %endif # with python3
%package -n target-restore %package -n target-restore
Summary: Systemd service for targetcli/rtslib Summary: Systemd service for targetcli/rtslib
Group: System Environment/Libraries %if %{with python3}
%if 0%{?with_python3}
Requires: python3-rtslib = %{version}-%{release} Requires: python3-rtslib = %{version}-%{release}
%else %else
Requires: python2-rtslib = %{version}-%{release} Requires: python2-rtslib = %{version}-%{release}
%endif %endif # with python3
%description -n target-restore %description -n target-restore
Systemd service to restore the LIO kernel target settings Systemd service to restore the LIO kernel target settings
@ -77,35 +100,43 @@ on system restart.
%setup -q -n %{oname}-%{version} %setup -q -n %{oname}-%{version}
%patch0 -p1 %patch0 -p1
%if 0%{?with_python3} %if %{with python3}
rm -rf %{py3dir} rm -rf %{py3dir}
cp -a . %{py3dir} cp -a . %{py3dir}
%endif %endif # with python3
%build %build
%{__python} setup.py build %if %{with python2}
gzip --stdout doc/targetctl.8 > doc/targetctl.8.gz %py2_build
gzip --stdout doc/saveconfig.json.5 > doc/saveconfig.json.5.gz
mkdir -p doc/html mkdir -p doc/html
epydoc --no-sourcecode --html -n rtslib -o doc/html rtslib/*.py epydoc --no-sourcecode --html -n rtslib -o doc/html rtslib/*.py
%endif # with python2
gzip --stdout doc/targetctl.8 > doc/targetctl.8.gz
gzip --stdout doc/saveconfig.json.5 > doc/saveconfig.json.5.gz
%if 0%{?with_python3} %if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
%{__python3} setup.py build %py3_build
popd popd
%endif %endif # with python3
%install %install
# remove py2 scripts if py3 enabled # remove py2 scripts if py3 enabled
%if 0%{?with_python3} %if %{with python3}
pushd %{py3dir} pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot} %py3_install
popd popd
%{__python} setup.py install --skip-build --root %{buildroot} --install-scripts py2scripts %if %{with python2}
%{__python2} setup.py install --skip-build --root %{buildroot} --install-scripts py2scripts
rm -rf %{buildroot}/py2scripts rm -rf %{buildroot}/py2scripts
%endif # with python2
%else %else
%{__python} setup.py install --skip-build --root %{buildroot} %if %{with python2}
%endif %py2_install
%endif # with python2
%endif # with python3
mkdir -p %{buildroot}%{_mandir}/man8/ mkdir -p %{buildroot}%{_mandir}/man8/
mkdir -p %{buildroot}%{_mandir}/man5/ mkdir -p %{buildroot}%{_mandir}/man5/
@ -126,15 +157,19 @@ install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/
%postun -n target-restore %postun -n target-restore
%systemd_postun_with_restart target.service %systemd_postun_with_restart target.service
%if %{with python2}
%files -n python2-rtslib %files -n python2-rtslib
%{python_sitelib}/* %license COPYING
%doc COPYING README.md doc/getting_started.md %{python2_sitelib}/*
%doc README.md doc/getting_started.md
%endif # with python2
%if 0%{?with_python3} %if %{with python3}
%files -n python3-rtslib %files -n python3-rtslib
%license COPYING
%{python3_sitelib}/* %{python3_sitelib}/*
%doc COPYING README.md doc/getting_started.md %doc README.md doc/getting_started.md
%endif %endif # with python3
%files -n target-restore %files -n target-restore
%{_bindir}/targetctl %{_bindir}/targetctl
@ -147,10 +182,15 @@ install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/
%{_mandir}/man8/targetctl.8.gz %{_mandir}/man8/targetctl.8.gz
%{_mandir}/man5/saveconfig.json.5.gz %{_mandir}/man5/saveconfig.json.5.gz
%if %{with python2}
%files doc %files doc
%doc doc/html %doc doc/html
%endif # with python2
%changelog %changelog
* Fri Mar 16 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.1.fb67-3
- Don't build the Python 2 subpackage on EL > 7
* Thu Feb 15 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.1.fb67-2 * Thu Feb 15 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.1.fb67-2
- 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)