File python-ZEO.spec of Package python-ZEO

#
# spec file for package python-ZEO
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2013 LISA GmbH, Bingen, 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-ZEO
Version:        4.1.0
Release:        0
Url:            http://docs.pylonsproject.org
Summary:        Client-Server storage implementation for ZODB
License:        ZPL-2.1
Group:          Development/Languages/Python
Source:         http://pypi.python.org/packages/source/Z/ZEO/ZEO-%{version}.tar.gz
Requires:       python-ZConfig
Requires:       python-ZODB >= 4.0.0
Requires:       python-persistent
Requires:       python-transaction
Requires:       python-zc.lockfile
Requires:       python-zdaemon
Requires:       python-zope.interface
BuildRequires:  python-ZConfig
BuildRequires:  python-ZODB >= 4.0.0
BuildRequires:  python-persistent
BuildRequires:  python-transaction
BuildRequires:  python-zc.lockfile
BuildRequires:  python-zdaemon
BuildRequires:  python-zope.interface

BuildRequires:  python-six
# Documentation requirements:
BuildRequires:  python-Sphinx
# Testing requirements:
BuildRequires:  python-manuel
BuildRequires:  python-random2
BuildRequires:  python-zope.testing
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(post): update-alternatives
Requires(postun): update-alternatives

%if 0%{?suse_version} && 0%{?suse_version} <= 1110
BuildRequires:  python-ordereddict
BuildRequires:  python-unittest2
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
ZEO provides a client-server storage implementation for ZODB.


%package doc
Summary:        Client-Server storage implementation for ZODB
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description doc
This package contains documentation files for %{name}.

%prep
%setup -q -n ZEO-%{version}
# delete backup files
find . -name "*~" -print -delete
# remove unwanted shebang
find src -name "*.py" | xargs sed -i '1 { /^#!/ d }'

%build
python setup.py build
python setup.py build_sphinx && rm build/sphinx/html/.buildinfo

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
# for update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for fn in runzeo zeoctl zeopack zeopasswd zeo-nagios; do
    mv %{buildroot}%{_bindir}/$fn %{buildroot}%{_bindir}/$fn-%{py_ver}
    touch %{buildroot}%{_sysconfdir}/alternatives/$fn
    ln -s %{_sysconfdir}/alternatives/$fn %{buildroot}%{_bindir}/$fn
done

%check
python setup.py test

%pre
# Since binaries in /usr/bin became ghosted to be used with update-alternatives, we have
# to get rid of the old binaries resulting from the non-update-alternativies-ified package:
[ -h %{_bindir}/runzeo ] || rm -f %{_bindir}/runzeo
[ -h %{_bindir}/zeoctl ] || rm -f %{_bindir}/zeoctl
[ -h %{_bindir}/zeopack ] || rm -f %{_bindir}/zeopack
[ -h %{_bindir}/zeopasswd ] || rm -f %{_bindir}/zeopasswd
# not for zeo-nagios, it appeared after update-alternatives

%post
update-alternatives \
    --install %{_bindir}/runzeo runzeo %{_bindir}/runzeo-%{py_ver} 20 \
    --slave %{_bindir}/zeoctl zeoctl %{_bindir}/zeoctl-%{py_ver} \
    --slave %{_bindir}/zeopack zeopack %{_bindir}/zeopack-%{py_ver} \
    --slave %{_bindir}/zeopasswd zeopasswd %{_bindir}/zeopasswd-%{py_ver} \
    --slave %{_bindir}/zeo-nagios zeo-nagios %{_bindir}/zeo-nagios-%{py_ver}

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

%files
%defattr(-,root,root,-)
%doc CHANGES.rst COPYRIGHT.txt LICENSE.txt README.rst
%ghost %{_sysconfdir}/alternatives/runzeo
%{_bindir}/runzeo
%{_bindir}/runzeo-%{py_ver}
%ghost %{_sysconfdir}/alternatives/zeoctl
%{_bindir}/zeoctl
%{_bindir}/zeoctl-%{py_ver}
%ghost %{_sysconfdir}/alternatives/zeopack
%{_bindir}/zeopack
%{_bindir}/zeopack-%{py_ver}
%ghost %{_sysconfdir}/alternatives/zeopasswd
%{_bindir}/zeopasswd
%{_bindir}/zeopasswd-%{py_ver}
%ghost %{_sysconfdir}/alternatives/zeo-nagios
%{_bindir}/zeo-nagios
%{_bindir}/zeo-nagios-%{py_ver}
%{python_sitelib}/ZEO
%{python_sitelib}/ZEO-%{version}-py%{py_ver}.egg-info

%files doc
%defattr(-,root,root,-)
%doc build/sphinx/html

%changelog
openSUSE Build Service is sponsored by