File irker.spec of Package irker

#
# spec file for package irker
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           irker
Version:        2.18
Release:        0
Summary:        Submission tools for IRC notifications
License:        BSD-3-Clause
Group:          Productivity/Networking/IRC
Url:            http://www.catb.org/~esr/irker/
Source0:        http://www.catb.org/~esr/irker/%{name}-%{version}.tar.gz
# https://github.com/shikadilord/irker-svnpoller
Source1:        irker-svnpoller
Source2:        irker.service
Source3:        sysconfig.irker
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  pkg-config
BuildRequires:  python-setuptools
BuildRequires:  xmlto
BuildRequires:  systemd
%{?systemd_requires}
BuildArch:      noarch

%description
irker is an IRC submission bot that runs as a daemon, accepting JSON requests on a
listener socket that are then passed to IRC servers.
Each JSON object consists of an IRC channel URL and a message string;
irkerd manages IRC server connections so as to deliver messages with minimal join/leave spam.

The use case for which irker was designed is passing notifications from VCS
repository hooks to project IRC channels.
The distribution also includes an installable hook script supporting git and Subversion.


%prep
%setup -q
# Fix MAkefile permissions
sed -i -e 's/-o 0 -g 0//g' Makefile
# Remove irkerd.service file handling (or push "MY" .service upstream)
sed -i -e '/irkerd.service/d' Makefile

%build

%install
mkdir -p %{buildroot}/%{_bindir}
make install DESTDIR=%{buildroot}
cp %{SOURCE1} %{buildroot}/%{_bindir}/irker-svnpoller
cp  irkerhook.py %{buildroot}/%{_bindir}/irkerhook
cp  irk %{buildroot}/%{_bindir}/irk

%if 0%{?suse_version} >= 1210
install -D -m0644 %{SOURCE2} %{buildroot}/%{_unitdir}/irker.service
%endif
install -D -m644 %{SOURCE3} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.irker

cat << EOF >> %{buildroot}/%{_bindir}/irkerhook-git
#!/bin/sh
refname=\$1
old=\$2
new=\$3

%{_bindir}/irkerhook --refname=\${refname} \$(git rev-list --reverse \${old}..\${new})

EOF

sed -i "s|#!/usr/bin/env python|#!%{_bindir}/python2|" %{buildroot}/%{_bindir}/*

%pre
%{_bindir}/getent group irker >/dev/null || %{_sbindir}/groupadd -r irker || :
%{_bindir}/getent passwd irker >/dev/null || %{_sbindir}/useradd -r -d %{_localstatedir}/lib/irker -s /bin/false -c "irker IRC daemon" -g irker irker || :
%if 0%{?suse_version} >= 1210
%service_add_pre %{name}.service
%endif

%post
%if 0%{?suse_version} >= 1210
%service_add_post %{name}.service
%fillup_only
%endif

%preun
%if 0%{?suse_version} >= 1210
%service_del_preun %{name}.service
%endif

%postun
%if 0%{?suse_version} >= 1210
%service_del_postun %{name}.service
%endif

%files
%defattr(0755,root,root)
%{_bindir}/irk
%{_bindir}/irkerd
%{_bindir}/irkerhook
%{_bindir}/irkerhook-git
%{_bindir}/irker-svnpoller
%defattr(0644,root,root)
%doc README COPYING hacking.txt install.txt security.txt
%{_mandir}/man1/irkerhook.1*
%{_mandir}/man1/irk.1*
%{_mandir}/man8/irkerd.8*
%if 0%{?suse_version} >= 1210
%{_unitdir}/irker.service
%endif
%{_localstatedir}/adm/fillup-templates/sysconfig.irker

%changelog
openSUSE Build Service is sponsored by