File python-jsonpatch.spec of Package

# 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

Name:           python-jsonpatch
Version:        1.11
Release:        0
Summary:        Python - JSON-Patches
License:        BSD-3-Clause
Group:          Development/Languages/Python
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()")}
BuildArch:      noarch

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

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

python build

python 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

[ -h %{_bindir}/jsonpatch ] || rm -f %{_bindir}/jsonpatch
[ -h %{_bindir}/jsondiff ] || rm -f %{_bindir}/jsondiff

update-alternatives --install \
    %{_bindir}/jsonpatch jsonpatch %{_bindir}/jsonpatch-%{py_ver} 20 \
    --slave %{_bindir}/jsondiff jsondiff %{_bindir}/jsondiff-%{py_ver}

if [ $1 -eq 0 ] ; then
    update-alternatives --remove jsonpatch %{_bindir}/jsonpatch-%{py_ver}

%ghost %{_bindir}/jsonpatch
%ghost %{_bindir}/jsondiff