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


Name:           fedwatch
Version:        0.5
Release:        6%{?dist}
Summary:        Tool for watching fedmsg messages and running arbitrary scripts

Group:          Development/Languages
License:        LGPLv2+
URL:            https://github.com/sochotnicky/fedwatch
Source0:        https://pypi.python.org/packages/source/f/fedwatch/fedwatch-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  python2-devel
BuildRequires:  python-setuptools
BuildRequires:  python-dpath
BuildRequires:  fedmsg

Requires:       python-%{name} = %{version}-%{release}
Requires:       python-dpath
Requires:       fedmsg
Requires:       python-fedmsg-meta-fedora-infrastructure
%if 0%{?rhel} && 0%{?rhel} < 7
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
%else
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
BuildRequires: systemd
%endif

%description
Tool and library for watching fedmsg messages and running arbitrary scripts in a
nice way. 

Think of fedwatch as simple converter from fedmsg json messages into shell
arguments for scripts.

%package -n python-%{name}
Summary:        Python 2 module for watching fedmsg messages and running arbitrary scripts

%description -n python-%{name}
%{summary}.

%prep
%setup -q -n fedwatch-%{version}
chmod -x examples/fedwatch.d/*
# get rid of hashbang
sed -i '1{d}' fedwatch.py

%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build

%install
%{__python} setup.py install --skip-build --root %{buildroot}

# create initial config
mkdir %{buildroot}%{_sysconfdir}
cat > %{buildroot}%{_sysconfdir}/%{name}.conf << EOF
# Empty configuration file. See /usr/share/doc/%{name}*/examples
# for working examples
EOF

mkdir %{buildroot}%{_sysconfdir}/%{name}.d/

# install init/systemd integration
%if 0%{?rhel} && 0%{?rhel} < 7
mkdir -p %{buildroot}/%{_initddir}
cp fedwatch.init %{buildroot}/%{_initddir}/fedwatch
%else
mkdir -p %{buildroot}/%{_unitdir}
cp fedwatch.service %{buildroot}/%{_unitdir}/
%endif


%if 0%{?rhel} && 0%{?rhel} < 7
%post
# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add fedwatch

%preun
if [ $1 -eq 0 ] ; then
    /sbin/service fedwatch stop >/dev/null 2>&1
    /sbin/chkconfig --del fedwatch
fi
%else
%post
%systemd_post fedwatch.service

%preun
%systemd_preun fedwatch.service

%postun
%systemd_postun_with_restart fedwatch.service
%endif

%files
%doc README.md LICENSE
%doc examples
%{_bindir}/fedwatch
%config(noreplace) %{_sysconfdir}/fedwatch.conf
%dir %{_sysconfdir}/fedwatch.d
%if 0%{?rhel} && 0%{?rhel} < 7
%attr(755, root, root) %{_initddir}/fedwatch
%else
%{_unitdir}/fedwatch.service
%endif

%files -n python-%{name}
%{python_sitelib}/fedwatch*


%changelog
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-4
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Jun 10 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.5-1
- Update to latest upstream
- Fix handling of non-string arguments for scripts

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue Apr 29 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.4-2
- Fix changelog
- Make sure documentation is not executable

* Tue Apr 29 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.4-1
- Update to latest upstream

* Thu Mar 20 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.3-1
- Update to new upstream version
- Handle errors a bit better

* Thu Mar 20 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.2-1
- Update to new upstream version
- Add support for systemd and init

* Wed Mar 19 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.1-1
- Initial packaging