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