Accepting request 919785 from home:schubi2

- Use libalternatives instead of update-alternatives.

OBS-URL: https://build.opensuse.org/request/show/919785
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-tempora?expand=0&rev=26
This commit is contained in:
Matej Cepl 2021-09-17 20:48:26 +00:00 committed by Git OBS Bridge
parent 611484dc03
commit 3e0e915738
2 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Sep 1 12:24:10 UTC 2021 - Stefan Schubert <schubi@suse.com>
- Use libalternatives instead of update-alternatives.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Sep 1 11:24:10 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com> Wed Sep 1 11:24:10 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>

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-%{**}} %{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1 %define skip_python2 1
Name: python-tempora Name: python-tempora
@ -37,8 +43,12 @@ BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: python-jaraco.functools >= 1.20 Requires: python-jaraco.functools >= 1.20
Requires: python-pytz Requires: python-pytz
%if %{with libalternatives}
Requires: alts
%else
Requires(post): update-alternatives Requires(post): update-alternatives
Requires(postun):update-alternatives Requires(postun):update-alternatives
%endif
BuildArch: noarch BuildArch: noarch
%python_subpackages %python_subpackages
@ -59,23 +69,47 @@ sed -i '/--mypy/d' pytest.ini
%install %install
%python_install %python_install
%python_clone -a %{buildroot}%{_bindir}/calc-prorate %if ! %{with libalternatives}
%python_clone -a %{buildroot}%{_bindir}/calc-prorate
%else
%python_clone %{buildroot}%{_bindir}/calc-prorate
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/calc-prorate
mkdir -p %{buildroot}%{_datadir}/libalternatives/calc-prorate
%python_expand echo "binary=%{_bindir}/calc-prorate-%{$python_version}" > %{buildroot}%{_datadir}/libalternatives/calc-prorate/10%{$python_version_nodots}.conf
%endif
%python_expand %fdupes %{buildroot}%{$python_sitelib} %python_expand %fdupes %{buildroot}%{$python_sitelib}
%check %check
sed -i -e 's:--black::' -e 's:--cov::' -e 's/--flake8//g' pytest.ini sed -i -e 's:--black::' -e 's:--cov::' -e 's/--flake8//g' pytest.ini
%pytest %pytest
%if %{with libalternatives}
%pre
# removing old update-alternatives entries
if [ "$1" -gt 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
%python_uninstall_alternative calc-prorate
fi
%else
%post %post
%python_install_alternative calc-prorate %python_install_alternative calc-prorate
%postun %postun
%python_uninstall_alternative calc-prorate %python_uninstall_alternative calc-prorate
%endif
%files %{python_files} %files %{python_files}
%license LICENSE %license LICENSE
%doc CHANGES.rst README.rst docs/*rst %doc CHANGES.rst README.rst docs/*rst
%if ! 0%{with libalternatives}
%python_alternative %{_bindir}/calc-prorate %python_alternative %{_bindir}/calc-prorate
%else
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/calc-prorate
%{_datadir}/libalternatives/calc-prorate/10%python_version_nodots.conf
%{_bindir}/calc-prorate
%{_bindir}/calc-prorate-%python_version
%endif
%{python_sitelib}/tempora %{python_sitelib}/tempora
%{python_sitelib}/tempora-%{version}-py*.egg-info %{python_sitelib}/tempora-%{version}-py*.egg-info