Accepting request 919836 from home:schubi2

- Use libalternatives instead of update-alternatives.

OBS-URL: https://build.opensuse.org/request/show/919836
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest?expand=0&rev=93
This commit is contained in:
Matej Cepl 2021-09-17 20:43:42 +00:00 committed by Git OBS Bridge
parent 99c4551ac9
commit 08828803dd
2 changed files with 50 additions and 2 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Sep 16 13:35:07 UTC 2021 - Stefan Schubert <schubi@schubi.de>
- Use libalternatives instead of update-alternatives.
-------------------------------------------------------------------
Tue Sep 14 09:22:10 UTC 2021 - Ondřej Súkup <mimi.vx@gmail.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-%{**}}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
@ -47,8 +53,12 @@ Requires: python-py >= 1.8.2
Requires: python-setuptools
Requires: python-toml
Requires: python-wcwidth
%if %{with libalternatives}
Requires: alts
%else
Requires(post): update-alternatives
Requires(postun):update-alternatives
%endif
Obsoletes: python-pytest-doc
BuildArch: noarch
%if %{with test}
@ -88,8 +98,21 @@ sed -i '/^\[metadata\]/ a version = %{version}' setup.cfg
%install
%if ! %{with test}
%python_install
%python_clone -a %{buildroot}%{_bindir}/pytest
%python_clone -a %{buildroot}%{_bindir}/py.test
%if ! %{with libalternatives}
%python_clone -a %{buildroot}%{_bindir}/pytest
%python_clone -a %{buildroot}%{_bindir}/py.test
%else
%python_clone %{buildroot}%{_bindir}/pytest
%python_clone %{buildroot}%{_bindir}/py.test
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/pytest
mkdir -p %{buildroot}%{_datadir}/libalternatives/pytest
%python_expand content="binary=%{_bindir}/pytest-%{$python_version}\\ngroup=pytest, py.test"
%python_expand echo -e $content > %{buildroot}%{_datadir}/libalternatives/pytest/10%{$python_version_nodots}.conf
ln -sf %{_bindir}/alts %{buildroot}%{_bindir}/py.test
mkdir -p %{buildroot}%{_datadir}/libalternatives/py.test
%python_expand content="binary=%{_bindir}/py.test-%{$python_version}\\ngroup=pytest, py.test"
%python_expand echo -e $content > %{buildroot}%{_datadir}/libalternatives/py.test/10%{$python_version_nodots}.conf
%endif
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
@ -99,6 +122,13 @@ sed -i '/^\[metadata\]/ a version = %{version}' setup.cfg
%endif
%if ! %{with test}
%if %{with libalternatives}
%pre
# removing old update-alternatives entries
if [ "$1" -gt 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
%python_uninstall_alternative pytest py.test
fi
%else
%post
# py.test was the master until Oct 2020. boo#1178547
alternatives=$(update-alternatives --quiet --list py.test 2> /dev/null) && (
@ -117,12 +147,25 @@ alternatives=$(update-alternatives --quiet --list py.test 2> /dev/null) && (
%postun
%python_uninstall_alternative pytest
%endif
%files %{python_files}
%doc AUTHORS CHANGELOG.rst README.rst
%license LICENSE
%if ! 0%{with libalternatives}
%python_alternative %{_bindir}/pytest
%python_alternative %{_bindir}/py.test
%else
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/pytest
%{_datadir}/libalternatives/pytest/10%python_version_nodots.conf
%{_bindir}/pytest
%{_bindir}/pytest-%python_version
%dir %{_datadir}/libalternatives/py.test
%{_datadir}/libalternatives/py.test/10%python_version_nodots.conf
%{_bindir}/py.test
%{_bindir}/py.test-%python_version
%endif
%{python_sitelib}/_pytest
%{python_sitelib}/pytest
%{python_sitelib}/pytest-%{version}*-info