%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

Summary:  A System for Allowing the Control of Process State on UNIX
Name: supervisor
Group: system
Version: 4.2.0
Release: 1%{?_dist_release}

License: ZPLv2.1 and BSD and MIT
URL: http://supervisord.org/
Source0: https://pypi.python.org/packages/source/s/%{name}/%{name}-%{version}%{?prever}.tar.gz
Source1: supervisord.init
Source2: supervisord.conf
Source3: supervisor.logrotate
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

Vendor:         Project Vine
Distribution:   Vine Linux

BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-rpm-macros
BuildRequires: python3-setuptools

Requires: python3-setuptools


%description
The supervisor is a client/server system that allows its users to control a
number of processes on UNIX-like operating systems.

%prep
%setup -q -n %{name}-%{version}%{?prever}

%build
%py3_build

%install
rm -rf %{buildroot}
%py3_install

mkdir -p %{buildroot}/%{_sysconfdir}
mkdir -p %{buildroot}/%{_sysconfdir}/supervisord.d
mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d/
%{__mkdir} -p %{buildroot}/%{_initrddir}
mkdir -p %{buildroot}/%{_localstatedir}/log/%{name}
chmod 770 %{buildroot}/%{_localstatedir}/log/%{name}
%{__install} -p -m 755 %{SOURCE1} %{buildroot}/%{_initrddir}/supervisord
install -p -m 644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/supervisord.conf
install -p -m 644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/logrotate.d/supervisor
sed -i s'/^#!.*//' $( find %{buildroot}/%{python3_sitelib}/supervisor/ -type f)

rm -rf %{buildroot}/%{python_sitelib}/supervisor/meld3/
rm -f %{buildroot}%{_prefix}/doc/*.txt

%clean
rm -rf %{buildroot}

%post
/sbin/chkconfig --add %{name}d || :

%preun
if [ $1 = 0 ]; then
    /sbin/service supervisord stop > /dev/null 2>&1 || :
    /sbin/chkconfig --del %{name}d || :
fi

%files
%defattr(-,root,root,-)
%license COPYRIGHT.txt LICENSES.txt
%doc CHANGES.rst README.rst
%dir %{_localstatedir}/log/%{name}
%{python3_sitelib}/*
%{_initrddir}/supervisord
%{_bindir}/supervisor*
%{_bindir}/echo_supervisord_conf
%{_bindir}/pidproxy

%config(noreplace) %{_sysconfdir}/supervisord.conf
%dir %{_sysconfdir}/supervisord.d
%config(noreplace) %{_sysconfdir}/logrotate.d/supervisor

%changelog
* Sat Aug 15 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.2.0-1
- new upstream release.
- dropped R:python3-meld: no longer needed.

* Sun Mar 22 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.1.0-1
- new upstream release.

* Wed May 22 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.0.2-1
- new upstream release.
- switched to python3.

* Sun Dec 31 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.3.3-1
- new upstream release.

* Tue May 10 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.3-1
- new upstream release.

* Sat Dec 5 2015 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.2.0-1
- initial build for Vine Linux.