From db503fec46f74ed09bb6dc6f411695edc727d71253f56bffe1b410e67fb87a7e Mon Sep 17 00:00:00 2001 From: Denisart Benjamin Date: Fri, 7 Feb 2014 13:01:48 +0000 Subject: [PATCH] Accepting request 221236 from home:posophe:branches:devel:languages:python - Implement update-alternative OBS-URL: https://build.opensuse.org/request/show/221236 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-zdaemon?expand=0&rev=17 --- python-zdaemon.changes | 5 +++++ python-zdaemon.spec | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/python-zdaemon.changes b/python-zdaemon.changes index e4baf8b..f60c9c1 100644 --- a/python-zdaemon.changes +++ b/python-zdaemon.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Feb 7 12:43:58 UTC 2014 - p.drouand@gmail.com + +- Implement update-alternative + ------------------------------------------------------------------- Thu Oct 24 11:17:46 UTC 2013 - speilicke@suse.com diff --git a/python-zdaemon.spec b/python-zdaemon.spec index e593609..2e752a5 100644 --- a/python-zdaemon.spec +++ b/python-zdaemon.spec @@ -1,7 +1,7 @@ # # spec file for package python-zdaemon # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,19 +18,19 @@ %define modname zdaemon -Name: python-zdaemon +Name: python-%{modname} Version: 4.0.0a1 Release: 0 Summary: Daemon process control library and tools License: ZPL-2.1 -Group: Development/Libraries/Python +Group: Development/Languages/Python Url: http://pypi.python.org/pypi/zdaemon Source: https://pypi.python.org/packages/source/z/zdaemon/%{modname}-%{version}.zip -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%{py_requires} BuildRequires: python-devel BuildRequires: python-setuptools BuildRequires: unzip +Requires(post): update-alternatives +Requires(postun): update-alternatives BuildArch: noarch %description @@ -41,15 +41,39 @@ although it is not limited to running Python-based applications %prep %setup -q -n %{modname}-%{version} +sed -i "s|%{modname} =|%{modname}-%{py_ver} =|" setup.py %build python setup.py build %install -python setup.py install --prefix=%{_prefix} --root=$RPM_BUILD_ROOT --record-rpm=INSTALLED_FILES +python setup.py install --prefix=%{_prefix} --root=%{buildroot} +ln -s %{_bindir}/%{modname}-%{py_ver} %{buildroot}%{_bindir}/%{modname} -%files -f INSTALLED_FILES +%pre +# Since /usr/bin/zdaemon 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}/%{modname} ]] && rm -f %{_bindir}/%{modname} +exit 0 + +%post +update-alternatives \ + --install %{_bindir}/%{modname} %{modname} %{_bindir}/%{modname}-%{py_ver} 20 + +%preun +if [ $1 -eq 0 ] ; then + update-alternatives --remove %{modname} %{_bindir}/%{modname}-%{py_ver} +fi + +%files %defattr(-,root,root) %doc README.txt CHANGES.txt +%if 0%{?suse_version} >= 1230 +%ghost %{_sysconfdir}/alternatives/%{modname} +%endif +%ghost %{_bindir}/%{modname} +%{python_sitelib} +%{_bindir}/%{modname}-%{py_ver} -%changelog +%changelog \ No newline at end of file