15
0

Accepting request 919787 from home:schubi2

- Use libalternatives instead of update-alternatives.

OBS-URL: https://build.opensuse.org/request/show/919787
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cheroot?expand=0&rev=35
This commit is contained in:
2021-09-17 21:26:38 +00:00
committed by Git OBS Bridge
parent 383448dc97
commit 1cb2c60c34
2 changed files with 39 additions and 1 deletions

View File

@@ -16,6 +16,12 @@
#
%if 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define pypi_name cheroot
%bcond_without python2
@@ -60,8 +66,12 @@ BuildRequires: %{python_module urllib3 >= 1.25}
Requires: python-jaraco.functools
Requires: python-more-itertools >= 2.6
Requires: python-six >= 1.11.0
%if %{with libalternatives}
Requires: alts
%else
Requires(post): update-alternatives
Requires(postun):update-alternatives
%endif
# the package and distribution name is lowercase-cheroot,
# but PyPI claims the name is capital-Cheroot
# *smacks head against desk*
@@ -86,7 +96,14 @@ sed -i '/--cov/ d' pytest.ini
%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/cheroot
%if ! %{with libalternatives}
%python_clone -a %{buildroot}%{_bindir}/cheroot
%else
%python_clone %{buildroot}%{_bindir}/cheroot
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/cheroot
mkdir -p %{buildroot}%{_datadir}/libalternatives/cheroot
%python_expand echo "binary=%{_bindir}/cheroot-%{$python_version}" > %{buildroot}%{_datadir}/libalternatives/cheroot/10%{$python_version_nodots}.conf
%endif
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
@@ -98,16 +115,32 @@ pytest_opts="--ignore cheroot/test/test_wsgi.py"
# test_tls_client_auth[...-False-localhost-builtin] fails ocassionally on server-side OBS
%pytest $pytest_opts -k "not (test_tls_client_auth and False-localhost-builtin)"
%if %{with libalternatives}
%pre
# removing old update-alternatives entries
if [ "$1" -gt 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
%python_uninstall_alternative cheroot
fi
%else
%post
%python_install_alternative cheroot
%postun
%python_uninstall_alternative cheroot
%endif
%files %{python_files}
%license LICENSE.md
%doc README.rst CHANGES.rst
%if ! 0%{with libalternatives}
%python_alternative %{_bindir}/cheroot
%else
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/cheroot
%{_datadir}/libalternatives/cheroot/10%python_version_nodots.conf
%{_bindir}/cheroot
%{_bindir}/cheroot-%python_version
%endif
%{python_sitelib}/cheroot
%{python_sitelib}/cheroot-%{version}*-info