Massimo fafe581
%if 0%{?fedora} > 12 || 0%{?rhel} > 6
Massimo fafe581
%global with_python3 1
Massimo fafe581
%endif
Massimo fafe581
%if 0%{?rhel} == 5
Massimo fafe581
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
Massimo fafe581
%endif
Massimo fafe581
Massimo fafe581
%global srcname simplevisor
Massimo fafe581
Massimo fafe581
Name:		python-simplevisor
Massimo b11edb7
Version:	0.8
Massimo fafe581
Release:	1%{?dist}
Massimo fafe581
Summary:	Python simple daemons supervisor
Massimo fafe581
Massimo fafe581
Group:		Development/Libraries
Massimo fafe581
License:	ASL 2.0
Massimo 75d1694
URL:		https://github.com/cern-mig/%{name}
Massimo fafe581
Source0:	http://pypi.python.org/packages/source/s/%{srcname}/%{srcname}-%{version}.tar.gz
Massimo fafe581
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Massimo fafe581
Massimo fafe581
BuildArch:	noarch
Massimo fafe581
BuildRequires:	python2-devel
Massimo fafe581
Requires:	perl-Config-General
Massimo b11edb7
BuildRequires:	perl-No-Worries
Massimo fafe581
Requires:	perl-No-Worries
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
BuildRequires:	python3-devel
Massimo fafe581
%endif # if with_python3
Massimo fafe581
%if ! 0%{?with_python3}
Massimo fafe581
BuildRequires:	python-argparse
Massimo fafe581
Requires:	python-argparse
Massimo fafe581
%endif
Massimo b11edb7
%if 0%{?fedora} == 19
Massimo b11edb7
BuildRequires:	perl-Pod-Usage
Massimo b11edb7
Requires:	perl-Pod-Usage
Massimo b11edb7
%endif
Massimo fafe581
# For python < 2.6 python-siplejson is required
Massimo fafe581
%if 0%{?fedora} < 11 || 0%{?rhel} <= 6
Massimo fafe581
BuildRequires:	python-simplejson
Massimo fafe581
Requires:	python-simplejson
Massimo fafe581
%endif
Massimo fafe581
Massimo fafe581
%description
Massimo fafe581
Simplevisor is a simple daemons supervisor, it is inspired by
Massimo fafe581
Erlang OTP and it can supervise hierarchies of services.
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
%package -n python3-simplevisor
Massimo fafe581
Summary:	Python simple daemons supervisor
Massimo fafe581
Group:		Development/Libraries
Massimo fafe581
Massimo fafe581
%description -n python3-simplevisor
Massimo fafe581
Simplevisor is a simple daemons supervisor, it is inspired by
Massimo fafe581
Erlang OTP and it can supervise hierarchies of services.
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo fafe581
%prep
Massimo fafe581
%setup -q -n %{srcname}-%{version}
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
rm -rf %{py3dir}
Massimo fafe581
cp -a . %{py3dir}
Massimo fafe581
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo fafe581
find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'
Massimo fafe581
Massimo fafe581
%build 
Massimo fafe581
%{__python} setup.py build
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
pushd %{py3dir}
Massimo fafe581
%{__python3} setup.py build
Massimo fafe581
popd
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo fafe581
%install
Massimo fafe581
rm -rf $RPM_BUILD_ROOT
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
pushd %{py3dir}
Massimo b11edb7
%{__python3} setup.py install --with-data-files --skip-build --root $RPM_BUILD_ROOT
Massimo fafe581
mv $RPM_BUILD_ROOT/usr/bin/simplevisor $RPM_BUILD_ROOT/usr/bin/simplevisor3
Massimo fafe581
mv $RPM_BUILD_ROOT/usr/bin/simplevisor-control $RPM_BUILD_ROOT/usr/bin/simplevisor3-control
Massimo fafe581
sed -i 's|/usr/bin/python|/usr/bin/python3|' $RPM_BUILD_ROOT/usr/bin/simplevisor3-control
Massimo fafe581
install -D -m 644 man/%{srcname}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}3.1;
Massimo fafe581
install -D -m 644 man/%{srcname}-control.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}3-control.1;
Massimo fafe581
install -D -m 644 man/%{srcname}-loop.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-loop.1;
Massimo fafe581
popd
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo b11edb7
%{__python} setup.py install --with-data-files --skip-build --root $RPM_BUILD_ROOT
Massimo fafe581
install -D -m 644 man/%{srcname}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}.1;
Massimo fafe581
install -D -m 644 man/%{srcname}-control.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-control.1;
Massimo fafe581
install -D -m 644 man/%{srcname}-loop.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{srcname}-loop.1;
Massimo fafe581
Massimo fafe581
%check
Massimo b11edb7
%if 0%{?rhel} == 5
Massimo b11edb7
# syslog in el5 is not configured, workaround for simplevisor-loop
Massimo b11edb7
# in order to pass the tests, does not affect functionality during test
Massimo b11edb7
mkdir Sys
Massimo b11edb7
cp `find %{_libdir}/perl5/5*/ -name "Syslog.pm"` Sys/Syslog.pm
Massimo b11edb7
sed -i "s/^.*grep { \$_ ne 'udp' }.*$/# noop/" Sys/Syslog.pm
Massimo b11edb7
sed -i "s/^.*udp connect: nobody listening.*$/return 1;/g" Sys/Syslog.pm
Massimo b11edb7
export PERL5LIB=.:${PERL5LIB}
Massimo b11edb7
%endif
Massimo fafe581
%{__python} setup.py test
Massimo fafe581
# And remove compiled documentation.
Massimo fafe581
rm -f test/*.pyc
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
pushd %{py3dir}
Massimo fafe581
%{__python3} setup.py test
Massimo fafe581
rm -f test/*.pyc
Massimo fafe581
popd
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo fafe581
%clean
Massimo fafe581
rm -rf $RPM_BUILD_ROOT
Massimo fafe581
Massimo fafe581
%files
Massimo fafe581
%defattr(-,root,root)
Massimo fafe581
%doc LICENSE README.rst CHANGES examples
Massimo fafe581
%{_mandir}/man?/%{srcname}.1*
Massimo fafe581
%{_mandir}/man?/%{srcname}-control.1*
Massimo fafe581
%{_mandir}/man?/%{srcname}-loop.1*
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor-control
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor-loop
Massimo fafe581
%{python_sitelib}/%{srcname}/
Massimo fafe581
%if 0%{?rhel} != 5
Massimo fafe581
%{python_sitelib}/%{srcname}-%{version}-py?.?.egg-info
Massimo fafe581
%endif
Massimo fafe581
Massimo fafe581
%if 0%{?with_python3}
Massimo fafe581
%files -n python3-simplevisor
Massimo fafe581
%doc LICENSE README.rst CHANGES
Massimo fafe581
%{_mandir}/man?/%{srcname}3.1*
Massimo fafe581
%{_mandir}/man?/%{srcname}3-control.1*
Massimo fafe581
%{_mandir}/man?/%{srcname}-loop.1*
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor3
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor3-control
Massimo fafe581
%attr(755, root, root) /usr/bin/simplevisor-loop
Massimo fafe581
%{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info
Massimo fafe581
%{python3_sitelib}/%{srcname}/
Massimo fafe581
%endif # with_python3
Massimo fafe581
Massimo fafe581
%changelog
Massimo b11edb7
* Fri Apr 26 2013 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.8-1
Massimo b11edb7
- Updating to upstream 0.8.
Massimo b11edb7
Massimo ba283c9
* Mon Jan 28 2013 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.7-1
Massimo ba283c9
- Updating to upstream 0.7.
Massimo ba283c9
Massimo fafe581
* Thu Jan 17 2013 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.6-1
Massimo fafe581
- Updating to upstream 0.6.
Massimo fafe581
Massimo fafe581
* Fri Nov 30 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.5-2
Massimo fafe581
- Use macros consistently.
Massimo fafe581
Massimo fafe581
* Fri Sep 14 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.5-1
Massimo fafe581
- Updating to version 0.5.
Massimo fafe581
Massimo fafe581
* Thu Jul 05 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.4-1
Massimo fafe581
- Updating to version 0.4.
Massimo fafe581
Massimo fafe581
* Mon Jun 25 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.3-1
Massimo fafe581
- Updating to version 0.3.
Massimo fafe581
Massimo fafe581
* Mon Mar 14 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.2-1
Massimo fafe581
- Improvements.
Massimo fafe581
Massimo fafe581
* Mon Mar 11 2012 Massimo Paladin <Massimo.Paladin@gmail.com> - 0.1-1
Massimo fafe581
- Initial packaging.
Massimo fafe581