# spec file for package ceph-deploy
#
-%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
-%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
-%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+%if 0%{?rhel} >= 8 || 0%{?suse_version} >= 1500
+%bcond_with python2
+%bcond_without python3
+%else
+%bcond_without python2
+%bcond_with python3
%endif
+# Exclude ceph-deploy from the rpmbuild shebang check to allow it to run
+# under Python 2 and 3.
+%global __brp_mangle_shebangs_exclude_from ceph-deploy
+
#################################################################################
# common
#################################################################################
Name: ceph-deploy
-Version: 2.0.1
+Version: 2.0.2
Release: 0
Summary: Admin and deploy tool for Ceph
License: MIT
URL: http://ceph.com/
Source0: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: python-devel
-BuildRequires: python-setuptools
-BuildRequires: python-virtualenv
-BuildRequires: python-mock
+%if %{with python2}
+BuildRequires: python2-devel
+BuildRequires: python2-setuptools
+BuildRequires: python2-virtualenv
+BuildRequires: python2-mock
BuildRequires: python-tox
+BuildRequires: git
%if 0%{?suse_version}
BuildRequires: python-pytest
%else
BuildRequires: pytest
%endif
-BuildRequires: git
-Requires: python-argparse
-Requires: python-configparser
-Requires: python-remoto
-%if 0%{?suse_version} && 0%{?suse_version} <= 1110
-%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
-%else
+%endif
+%if %{with python3}
+BuildRequires: python%{python3_pkgversion}-devel
+BuildRequires: python%{python3_pkgversion}-setuptools
+BuildRequires: python%{python3_pkgversion}-virtualenv
+BuildRequires: python%{python3_pkgversion}-mock
+BuildRequires: python%{python3_pkgversion}-tox
+BuildRequires: python%{python3_pkgversion}-pytest
+%endif
BuildArch: noarch
+%description
+An easy to use admin tool for deploy ceph storage clusters.
+
+
+%if %{with python2}
+%package -n python2-%{name}
+Summary: %{summary}
+Requires: python2-argparse
+Requires: python2-configparser
+Requires: python2-remoto
+%{?python_provide:%python_provide python2-%{name}}
+Provides: ceph-deploy
+%description -n python2-%{name}
+An easy to use admin tool for deploy ceph storage clusters.
+%endif
+
+%if %{with python3}
+%package -n python%{python3_pkgversion}-%{name}
+Summary: %{summary}
+Requires: python%{python3_pkgversion}-remoto
+%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
+Conflicts: ceph-deploy < 2.1.0
+%description -n python%{python3_pkgversion}-%{name}
+An easy to use admin tool for deploy ceph storage clusters.
%endif
#################################################################################
%py_requires
%endif
-%description
-An easy to use admin tool for deploy ceph storage clusters.
-
%prep
#%%setup -q -n %%{name}
%setup -q
%build
-#python setup.py build
+# %{?with_python2:%py2_build}
+# %{?with_python3:%py3_build}
%install
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
-install -m 0755 -D scripts/ceph-deploy $RPM_BUILD_ROOT/usr/bin
+%if %{with python2}
+%py2_install
+mv %{buildroot}%{_bindir}/ceph-deploy %{buildroot}%{_bindir}/ceph-deploy-%{python2_version}
+ln -s ./ceph-deploy-%{python2_version} %{buildroot}%{_bindir}/ceph-deploy-2
+ln -s ./ceph-deploy-2 %{buildroot}%{_bindir}/ceph-deploy
+%endif
+%if %{with python3}
+%py3_install
+mv %{buildroot}%{_bindir}/ceph-deploy %{buildroot}%{_bindir}/ceph-deploy-%{python3_version}
+ln -s ./ceph-deploy-%{python3_version} %{buildroot}%{_bindir}/ceph-deploy-3
+%endif
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
-%files
+%if %{with python2}
+%files -n python2-%{name}
%defattr(-,root,root)
-%doc LICENSE README.rst
+%license LICENSE
+%doc README.rst
+%{python2_sitelib}/*
%{_bindir}/ceph-deploy
-%{python_sitelib}/*
+%{_bindir}/ceph-deploy-2
+%{_bindir}/ceph-deploy-%{python2_version}
+%endif
+
+%if %{with python3}
+%files -n python3-%{name}
+%defattr(-,root,root)
+%license LICENSE
+%doc README.rst
+%{python3_sitelib}/*
+%{_bindir}/ceph-deploy-3
+%{_bindir}/ceph-deploy-%{python3_version}
+%endif
%changelog