Implement alternatives
This commit is contained in:
parent
1b1710221f
commit
d1ed1b809b
@ -154,6 +154,14 @@ BuildRequires: python%{python3_pkgversion}-installer
|
|||||||
# Side note: pip bundles pkg_resources from setuptools for internal usage.
|
# Side note: pip bundles pkg_resources from setuptools for internal usage.
|
||||||
Recommends: python%{python3_pkgversion}-setuptools
|
Recommends: python%{python3_pkgversion}-setuptools
|
||||||
|
|
||||||
|
# Require alternatives version that implements the --keep-foreign flag and fixes rhbz#2203820
|
||||||
|
Requires(postun): alternatives >= 1.19.2-1
|
||||||
|
|
||||||
|
# python3.12 installs the alternatives master symlink to which we attach a slave
|
||||||
|
Requires: python%{python3_pkgversion}
|
||||||
|
Requires(post): python%{python3_pkgversion}
|
||||||
|
Requires(postun): python%{python3_pkgversion}
|
||||||
|
|
||||||
# Virtual provides for the packages bundled by pip:
|
# Virtual provides for the packages bundled by pip:
|
||||||
%{bundled %{python3_pkgversion}}
|
%{bundled %{python3_pkgversion}}
|
||||||
|
|
||||||
@ -254,6 +262,11 @@ install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
|
|||||||
rm %{buildroot}%{_bindir}/pip
|
rm %{buildroot}%{_bindir}/pip
|
||||||
rm %{buildroot}%{_bindir}/pip3
|
rm %{buildroot}%{_bindir}/pip3
|
||||||
|
|
||||||
|
# All ghost files controlled by alternatives need to exist for the files
|
||||||
|
# section check to succeed
|
||||||
|
touch %{buildroot}%{_bindir}/pip3
|
||||||
|
touch %{buildroot}%{_bindir}/pip-3
|
||||||
|
|
||||||
%check
|
%check
|
||||||
%if 0%{?rhel} >= 9
|
%if 0%{?rhel} >= 9
|
||||||
# The test cannot run on RHEL8 due to the test script missing from RPM.
|
# The test cannot run on RHEL8 due to the test script missing from RPM.
|
||||||
@ -276,6 +289,34 @@ pytest_k='not completion'
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
||||||
|
%post -n python%{python3_pkgversion}-%{srcname}
|
||||||
|
alternatives --keep-foreign --add-slave python3 %{_bindir}/python%{python3_version} \
|
||||||
|
%{_bindir}/pip3 \
|
||||||
|
pip3 \
|
||||||
|
%{_bindir}/pip%{python3_version}
|
||||||
|
alternatives --keep-foreign --add-slave python3 %{_bindir}/python%{python3_version} \
|
||||||
|
%{_bindir}/pip-3 \
|
||||||
|
pip-3 \
|
||||||
|
%{_bindir}/pip-%{python3_version}
|
||||||
|
|
||||||
|
%postun -n python%{python3_pkgversion}-%{srcname}
|
||||||
|
# Do this only during uninstall process (not during update)
|
||||||
|
if [ $1 -eq 0 ]; then
|
||||||
|
# Only remove the slave links if the master link for python3 still exists.
|
||||||
|
# Due to a possible bug in yum, python3.12 gets removed before python3.12-pip
|
||||||
|
# even though we have declared Requires(postun): python3.12
|
||||||
|
EXISTS=`alternatives --display python3 | \
|
||||||
|
grep -c "^/usr/bin/python%{python3_version} - priority [0-9]*"`
|
||||||
|
|
||||||
|
if [ $EXISTS -ne 0 ]; then
|
||||||
|
alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \
|
||||||
|
pip3
|
||||||
|
alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \
|
||||||
|
pip-3
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
%files -n python%{python3_pkgversion}-%{srcname}
|
%files -n python%{python3_pkgversion}-%{srcname}
|
||||||
%doc README.rst
|
%doc README.rst
|
||||||
%license %{python3_sitelib}/pip-%{upstream_version}.dist-info/LICENSE.txt
|
%license %{python3_sitelib}/pip-%{upstream_version}.dist-info/LICENSE.txt
|
||||||
@ -288,6 +329,8 @@ pytest_k='not completion'
|
|||||||
%{python3_sitelib}/pip*
|
%{python3_sitelib}/pip*
|
||||||
%dir %{bashcompdir}
|
%dir %{bashcompdir}
|
||||||
%{bashcompdir}/pip%{python3_pkgversion}
|
%{bashcompdir}/pip%{python3_pkgversion}
|
||||||
|
%ghost %{_bindir}/pip3
|
||||||
|
%ghost %{_bindir}/pip-3
|
||||||
|
|
||||||
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
|
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
|
||||||
%license LICENSE.txt
|
%license LICENSE.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user