Stanislav Ochotnicky 45ce797
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Name:           fedwatch
Stanislav Ochotnicky 836d0a4
Version:        0.5
Stanislav Ochotnicky 836d0a4
Release:        1%{?dist}
Stanislav Ochotnicky 45ce797
Summary:        Tool for watching fedmsg messages and running arbitrary scripts
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Group:          Development/Languages
Stanislav Ochotnicky 45ce797
License:        LGPLv2+
Stanislav Ochotnicky 45ce797
URL:            https://github.com/sochotnicky/fedwatch
Stanislav Ochotnicky 45ce797
Source0:        https://pypi.python.org/packages/source/f/fedwatch/fedwatch-%{version}.tar.gz
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
BuildArch:      noarch
Stanislav Ochotnicky 45ce797
BuildRequires:  python2-devel
Stanislav Ochotnicky 45ce797
BuildRequires:  python-setuptools
Stanislav Ochotnicky 45ce797
BuildRequires:  python-dpath
Stanislav Ochotnicky 45ce797
BuildRequires:  fedmsg
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Requires:       python-%{name} = %{version}-%{release}
Stanislav Ochotnicky 45ce797
Requires:       python-dpath
Stanislav Ochotnicky 45ce797
Requires:       fedmsg
Stanislav Ochotnicky 45ce797
Requires:       python-fedmsg-meta-fedora-infrastructure
Stanislav Ochotnicky 45ce797
%if 0%{?rhel} && 0%{?rhel} < 7
Stanislav Ochotnicky 45ce797
Requires(post): chkconfig
Stanislav Ochotnicky 45ce797
Requires(preun): chkconfig
Stanislav Ochotnicky 45ce797
# This is for /sbin/service
Stanislav Ochotnicky 45ce797
Requires(preun): initscripts
Stanislav Ochotnicky 45ce797
%else
Stanislav Ochotnicky 45ce797
Requires(post): systemd
Stanislav Ochotnicky 45ce797
Requires(preun): systemd
Stanislav Ochotnicky 45ce797
Requires(postun): systemd
Stanislav Ochotnicky 45ce797
BuildRequires: systemd
Stanislav Ochotnicky 45ce797
%endif
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%description
Stanislav Ochotnicky 45ce797
Tool and library for watching fedmsg messages and running arbitrary scripts in a
Stanislav Ochotnicky 45ce797
nice way. 
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Think of fedwatch as simple converter from fedmsg json messages into shell
Stanislav Ochotnicky 45ce797
arguments for scripts.
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%package -n python-%{name}
Stanislav Ochotnicky 45ce797
Summary:        Python 2 module for watching fedmsg messages and running arbitrary scripts
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%description -n python-%{name}
Stanislav Ochotnicky 45ce797
%{summary}.
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%prep
Stanislav Ochotnicky 45ce797
%setup -q -n fedwatch-%{version}
Stanislav Ochotnicky 45ce797
chmod -x examples/fedwatch.d/*
Stanislav Ochotnicky 45ce797
# get rid of hashbang
Stanislav Ochotnicky 45ce797
sed -i '1{d}' fedwatch.py
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%build
Stanislav Ochotnicky 45ce797
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%install
Stanislav Ochotnicky 45ce797
%{__python} setup.py install --skip-build --root %{buildroot}
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
# create initial config
Stanislav Ochotnicky 45ce797
mkdir %{buildroot}%{_sysconfdir}
Stanislav Ochotnicky 45ce797
cat > %{buildroot}%{_sysconfdir}/%{name}.conf << EOF
Stanislav Ochotnicky 45ce797
# Empty configuration file. See /usr/share/doc/%{name}*/examples
Stanislav Ochotnicky 45ce797
# for working examples
Stanislav Ochotnicky 45ce797
EOF
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
mkdir %{buildroot}%{_sysconfdir}/%{name}.d/
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
# install init/systemd integration
Stanislav Ochotnicky 45ce797
%if 0%{?rhel} && 0%{?rhel} < 7
Stanislav Ochotnicky 45ce797
mkdir -p %{buildroot}/%{_initddir}
Stanislav Ochotnicky 45ce797
cp fedwatch.init %{buildroot}/%{_initddir}/fedwatch
Stanislav Ochotnicky 45ce797
%else
Stanislav Ochotnicky 45ce797
mkdir -p %{buildroot}/%{_unitdir}
Stanislav Ochotnicky 45ce797
cp fedwatch.service %{buildroot}/%{_unitdir}/
Stanislav Ochotnicky 45ce797
%endif
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%if 0%{?rhel} && 0%{?rhel} < 7
Stanislav Ochotnicky 45ce797
%post
Stanislav Ochotnicky 45ce797
# This adds the proper /etc/rc*.d links for the script
Stanislav Ochotnicky 45ce797
/sbin/chkconfig --add fedwatch
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%preun
Stanislav Ochotnicky 45ce797
if [ $1 -eq 0 ] ; then
Stanislav Ochotnicky 45ce797
    /sbin/service fedwatch stop >/dev/null 2>&1
Stanislav Ochotnicky 45ce797
    /sbin/chkconfig --del fedwatch
Stanislav Ochotnicky 45ce797
fi
Stanislav Ochotnicky 45ce797
%else
Stanislav Ochotnicky 45ce797
%post
Stanislav Ochotnicky 45ce797
%systemd_post fedwatch.service
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%preun
Stanislav Ochotnicky 45ce797
%systemd_preun fedwatch.service
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%postun
Stanislav Ochotnicky 45ce797
%systemd_postun_with_restart fedwatch.service
Stanislav Ochotnicky 45ce797
%endif
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%files
Stanislav Ochotnicky 45ce797
%doc README.md LICENSE
Stanislav Ochotnicky 45ce797
%doc examples
Stanislav Ochotnicky 45ce797
%{_bindir}/fedwatch
Stanislav Ochotnicky 45ce797
%config(noreplace) %{_sysconfdir}/fedwatch.conf
Stanislav Ochotnicky 45ce797
%dir %{_sysconfdir}/fedwatch.d
Stanislav Ochotnicky 45ce797
%if 0%{?rhel} && 0%{?rhel} < 7
Stanislav Ochotnicky 45ce797
%attr(755, root, root) %{_initddir}/fedwatch
Stanislav Ochotnicky 45ce797
%else
Stanislav Ochotnicky 45ce797
%{_unitdir}/fedwatch.service
Stanislav Ochotnicky 45ce797
%endif
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%files -n python-%{name}
Stanislav Ochotnicky 45ce797
%{python_sitelib}/fedwatch*
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
%changelog
Stanislav Ochotnicky 836d0a4
* Tue Jun 10 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.5-1
Stanislav Ochotnicky 836d0a4
- Update to latest upstream
Stanislav Ochotnicky 836d0a4
- Fix handling of non-string arguments for scripts
Stanislav Ochotnicky 836d0a4
e443563
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-3
e443563
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
e443563
Stanislav Ochotnicky 45ce797
* Tue Apr 29 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.4-2
Stanislav Ochotnicky 45ce797
- Fix changelog
Stanislav Ochotnicky 45ce797
- Make sure documentation is not executable
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
* Tue Apr 29 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.4-1
Stanislav Ochotnicky 45ce797
- Update to latest upstream
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
* Thu Mar 20 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.3-1
Stanislav Ochotnicky 45ce797
- Update to new upstream version
Stanislav Ochotnicky 45ce797
- Handle errors a bit better
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
* Thu Mar 20 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.2-1
Stanislav Ochotnicky 45ce797
- Update to new upstream version
Stanislav Ochotnicky 45ce797
- Add support for systemd and init
Stanislav Ochotnicky 45ce797
Stanislav Ochotnicky 45ce797
* Wed Mar 19 2014 Stanislav Ochotnicky <sochotnicky@redhat.com> - 0.1-1
Stanislav Ochotnicky 45ce797
- Initial packaging
Stanislav Ochotnicky 45ce797