17
0

Accepting request 419498 from home:TheBlackCat:branches:devel:languages:python

Fix update-alternatives implementation.

OBS-URL: https://build.opensuse.org/request/show/419498
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-jsonpatch?expand=0&rev=21
This commit is contained in:
Todd R
2016-08-15 18:02:48 +00:00
committed by Git OBS Bridge
parent 474c0d3f82
commit 48fd60dc22
2 changed files with 21 additions and 16 deletions

View File

@@ -27,9 +27,8 @@ Source: http://pypi.python.org/packages/source/j/jsonpatch/jsonpatch-%{v
BuildRequires: python-devel
BuildRequires: python-jsonpointer
Requires: python-jsonpointer >= 1.9
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires(pre): coreutils
Requires(post): update-alternatives
Requires(preun): 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()")}
@@ -49,31 +48,32 @@ python setup.py build
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
for i in patch diff; do
mv %{buildroot}%{_bindir}/json$i %{buildroot}%{_bindir}/json$i-%{py_ver}
ln -s %{_bindir}/json$i-%{py_ver} %{buildroot}%{_bindir}/json$i
# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for p in jsonpatch jsondiff ; do
mv %{buildroot}%{_bindir}/$p %{buildroot}%{_bindir}/$p-%{py_ver}
ln -s -f %{_sysconfdir}/alternatives/$p %{buildroot}%{_bindir}/$p
done
%pre
[ -h %{_bindir}/jsonpatch ] || rm -f %{_bindir}/jsonpatch
[ -h %{_bindir}/jsondiff ] || rm -f %{_bindir}/jsondiff
%post
update-alternatives --install \
%{_bindir}/jsonpatch jsonpatch %{_bindir}/jsonpatch-%{py_ver} 20 \
%_sbindir/update-alternatives \
--install %{_bindir}/jsonpatch jsonpatch %{_bindir}/jsonpatch-%{py_ver} 20 \
--slave %{_bindir}/jsondiff jsondiff %{_bindir}/jsondiff-%{py_ver}
%preun
if [ $1 -eq 0 ] ; then
update-alternatives --remove jsonpatch %{_bindir}/jsonpatch-%{py_ver}
%_sbindir/update-alternatives --remove jsonpatch %{_bindir}/jsonpatch-%{py_ver}
fi
%files
%defattr(-,root,root,-)
%ghost %{_bindir}/jsonpatch
%{_bindir}/jsonpatch-%{py_ver}
%ghost %{_bindir}/jsondiff
%{_bindir}/jsondiff
%{_bindir}/jsonpatch
%{_bindir}/jsondiff-%{py_ver}
%{_bindir}/jsonpatch-%{py_ver}
%ghost %{_sysconfdir}/alternatives/jsondiff
%ghost %{_sysconfdir}/alternatives/jsonpatch
%{python_sitelib}/jsonpatch*
%changelog