File python-jsonpatch.spec of Package python-jsonpatch.new

#
# spec file for package python-jsonpatch
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           python-jsonpatch
Version:        1.11
Release:        0
Summary:        Python - JSON-Patches
License:        BSD-3-Clause
Group:          Development/Languages/Python
Url:            https://github.com/stefankoegl/python-json-patch
Source:         http://pypi.python.org/packages/source/j/jsonpatch/jsonpatch-%{version}.tar.gz
BuildRequires:  python-devel
BuildRequires:  python-jsonpointer
Requires:       python-jsonpointer >= 1.9
Requires(post):   update-alternatives
Requires(postun): update-alternatives
Requires(pre):    coreutils
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()")}
%else
BuildArch:      noarch
%endif

%description
Python module to apply JSON-Patches (according to RFC 6902).

%prep
%setup -q -n jsonpatch-%{version}
sed -i "s|entry_poimts|entry_points|" setup.py # Typo fix already in upstream git..

%build
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
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 \
    --slave %{_bindir}/jsondiff jsondiff %{_bindir}/jsondiff-%{py_ver}

%preun
if [ $1 -eq 0 ] ; then
    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-%{py_ver}
%{python_sitelib}/jsonpatch*

%changelog