diff --git a/python-rtslib.spec b/python-rtslib.spec index c860eb0..9c2fb67 100644 --- a/python-rtslib.spec +++ b/python-rtslib.spec @@ -1,28 +1,38 @@ %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 %global oname rtslib-fb -Name: python-rtslib -License: ASL 2.0 -Group: System Environment/Libraries -Summary: API for Linux kernel LIO SCSI target -Version: 2.1.fb67 -Release: 2%{?dist} -URL: https://fedorahosted.org/targetcli-fb/ -Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz -Source1: target.service -Patch0: 0001-disable-xen_pvscsi.patch -BuildArch: noarch -BuildRequires: python2-devel epydoc python2-setuptools systemd-units -Requires(post): systemd -Requires(preun): systemd +Name: python-rtslib +License: ASL 2.0 +Group: System Environment/Libraries +Summary: API for Linux kernel LIO SCSI target +Version: 2.1.fb67 +Release: 3%{?dist} +URL: https://fedorahosted.org/targetcli-fb/ +Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz +Source1: target.service +Patch0: 0001-disable-xen_pvscsi.patch +BuildArch: noarch +BuildRequires: epydoc systemd-units +Requires(post): systemd +Requires(preun): systemd Requires(postun): systemd -%if 0%{?with_python3} -BuildRequires: python3-devel python3-setuptools -%endif %global _description\ API for generic Linux SCSI kernel target. Includes the 'target'\ @@ -31,42 +41,55 @@ service and targetctl tool for restoring configuration.\ %description %_description +%if %{with python2} %package -n python2-rtslib 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} %description -n python2-rtslib %_description +%endif # with python2 +%if %{with docs} %package doc Summary: Documentation for python-rtslib -Group: Documentation Requires: python2-rtslib = %{version}-%{release} %description doc API documentation for rtslib, to configure the generic Linux SCSI multiprotocol kernel target. +%endif # with docs -%if 0%{?with_python3} +%if %{with python3} %package -n python3-rtslib 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 API for generic Linux SCSI kernel target. -%endif +%endif # with python3 %package -n target-restore Summary: Systemd service for targetcli/rtslib -Group: System Environment/Libraries -%if 0%{?with_python3} +%if %{with python3} Requires: python3-rtslib = %{version}-%{release} %else Requires: python2-rtslib = %{version}-%{release} -%endif +%endif # with python3 %description -n target-restore Systemd service to restore the LIO kernel target settings @@ -77,35 +100,43 @@ on system restart. %setup -q -n %{oname}-%{version} %patch0 -p1 -%if 0%{?with_python3} +%if %{with python3} rm -rf %{py3dir} cp -a . %{py3dir} -%endif +%endif # with python3 %build -%{__python} setup.py build -gzip --stdout doc/targetctl.8 > doc/targetctl.8.gz -gzip --stdout doc/saveconfig.json.5 > doc/saveconfig.json.5.gz +%if %{with python2} +%py2_build + mkdir -p doc/html 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} pushd %{py3dir} -%{__python3} setup.py build +%py3_build popd -%endif +%endif # with python3 %install # remove py2 scripts if py3 enabled -%if 0%{?with_python3} +%if %{with python3} pushd %{py3dir} -%{__python3} setup.py install --skip-build --root %{buildroot} +%py3_install 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 +%endif # with python2 %else -%{__python} setup.py install --skip-build --root %{buildroot} -%endif +%if %{with python2} +%py2_install +%endif # with python2 +%endif # with python3 mkdir -p %{buildroot}%{_mandir}/man8/ mkdir -p %{buildroot}%{_mandir}/man5/ @@ -126,15 +157,19 @@ install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/ %postun -n target-restore %systemd_postun_with_restart target.service +%if %{with python2} %files -n python2-rtslib -%{python_sitelib}/* -%doc COPYING README.md doc/getting_started.md +%license COPYING +%{python2_sitelib}/* +%doc README.md doc/getting_started.md +%endif # with python2 -%if 0%{?with_python3} +%if %{with python3} %files -n python3-rtslib +%license COPYING %{python3_sitelib}/* -%doc COPYING README.md doc/getting_started.md -%endif +%doc README.md doc/getting_started.md +%endif # with python3 %files -n target-restore %{_bindir}/targetctl @@ -147,10 +182,15 @@ install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/ %{_mandir}/man8/targetctl.8.gz %{_mandir}/man5/saveconfig.json.5.gz +%if %{with python2} %files doc %doc doc/html +%endif # with python2 %changelog +* Fri Mar 16 2018 Charalampos Stratakis - 2.1.fb67-3 +- Don't build the Python 2 subpackage on EL > 7 + * Thu Feb 15 2018 Iryna Shcherbina - 2.1.fb67-2 - Update Python 2 dependency declarations to new packaging standards (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)