From 063974cc392d7c19a3092934072e1257da3a0bc1abc1021639eec12fa89d7d91 Mon Sep 17 00:00:00 2001 From: Todd R Date: Thu, 11 Sep 2014 15:12:36 +0000 Subject: [PATCH] Accepting request 248624 from home:TheBlackCat:branches:devel:languages:python Implement update-alternatives OBS-URL: https://build.opensuse.org/request/show/248624 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-invoke?expand=0&rev=3 --- python-invoke.changes | 5 +++++ python-invoke.spec | 31 ++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/python-invoke.changes b/python-invoke.changes index e076fee..74ea996 100644 --- a/python-invoke.changes +++ b/python-invoke.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Sep 11 13:11:26 UTC 2014 - toddrme2178@gmail.com + +- Implement update-alternatives + ------------------------------------------------------------------- Thu Sep 11 12:58:33 UTC 2014 - toddrme2178@gmail.com diff --git a/python-invoke.spec b/python-invoke.spec index ecd5524..ce9dc16 100644 --- a/python-invoke.spec +++ b/python-invoke.spec @@ -25,6 +25,8 @@ Group: Development/Languages/Python Source: https://pypi.python.org/packages/source/i/invoke/invoke-%{version}.tar.gz BuildRequires: python-devel BuildRequires: python-setuptools +Requires(post): update-alternatives +Requires(postun): update-alternatives BuildRoot: %{_tmppath}/%{name}-%{version}-build %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()")} @@ -66,12 +68,35 @@ python setup.py build %install python setup.py install --prefix=%{_prefix} --root=%{buildroot} +mv %{buildroot}%{_bindir}/inv %{buildroot}%{_bindir}/inv-%{py_ver} +mv %{buildroot}%{_bindir}/invoke %{buildroot}%{_bindir}/invoke-%{py_ver} +ln -s %{_bindir}/inv-%{py_ver} %{buildroot}%{_bindir}/inv +ln -s %{_bindir}/invoke-%{py_ver} %{buildroot}%{_bindir}/invoke + +%pre +# Since /usr/bin/* became ghosted to be used with update-alternatives, we have to get rid +# of the old binary resulting from the non-update-alternativies-ified package: +[[ ! -L %{_bindir}/inv ]] && rm -f %{_bindir}/inv +[[ ! -L %{_bindir}/invoke ]] && rm -f %{_bindir}/invoke +exit 0 + +%post +update-alternatives \ + --install %{_bindir}/invoke invoke %{_bindir}/invoke-%{py_ver} 30 \ + --slave %{_bindir}/inv inv %{_bindir}/inv%{py_ver} \ + +%preun +if [ $1 -eq 0 ] ; then + update-alternatives --remove invoke %{_bindir}/invoke-%{py_ver} +fi %files %defattr(-,root,root,-) %doc LICENSE README.rst -%{_bindir}/inv -%{_bindir}/invoke +%{_bindir}/inv-%{py_ver} +%{_bindir}/invoke-%{py_ver} +%ghost %{_bindir}/inv +%ghost %{_bindir}/invoke %{python_sitelib}/* -%changelog \ No newline at end of file +%changelog