File leafnode.spec of Package leafnode2

%define commit 0433b24e5e9bcedad060bec4ec53899a1bceb074
%define shortcommit %(c=%{commit}; echo ${c:0:7})

%if 0%{?rhel} >= 7 || 0%{?fedora} >= 18 || 0%{?suse_version}
%bcond_without systemd
%bcond_with systemd

Version: 2.0.0.alpha20140727b
Summary: Leaf site NNTP server
Summary(de): Ein offline-Newsserver
Name: leafnode
Release: 0.0.14.vcs%{shortcommit}%{?dist}
License: MIT
Group: Productivity/Networking/News/Servers
# Use checkout from the git repo at
Source0: %{name}.tar.bz2
Source1: %{name}.xinetd
Source4: %{name}-hourly.cron
Source5: %{name}-daily.cron
Patch0:  Fixes-autotools-on-systemd-based-systems.patch
Patch1:  Convert-manpages-to-UTF8-and-mark-them-a-such.patch

%if %{with systemd}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
BuildRequires: systemd
Requires: xinetd
Requires(post): initscripts
BuildRequires: pam-devel, pcre-devel
BuildRequires:  automake intltool gettext libtool
%if 0%{?rhel} >= 7 || 0%{?fedora} >= 18
BuildRequires:  perl-podlators
BuildRequires:  perl
%if 0%{?rhel} <= 6
BuildRequires:  autoconf >= 2.63
BuildRequires:  autoconf >= 2.68
%if 0%{?rhel} >= 5 || 0%{?fedora} >= 18
BuildRequires: shadow-utils
Requires(pre): shadow-utils
BuildRequires: shadow
Requires(pre): shadow
Requires(post): coreutils
%if %{with systemd}
Recommends: cron
%if 0%{?suse_version}
PreReq: permissions

%define spooldir    /var/spool/news
%define confdir     /etc/leafnode
%define runas_user  news
%define runas_group news

# Distribution: ${DISTRIBUTION}
Leafnode is a small NNTP server for leaf sites without permanent
connection to the internet. It supports a subset of NNTP and is able to
automatically fetch the newsgroups the user reads regularly from the
newsserver of the ISP and additionally offer local (site-specific)
groups to a LAN.

%description -l de
Leafnode ist ein offline-Newsserver, der vor allem für den typischen
Einzelnutzer-Rechner ohne permanente Internetanbindung geeignet ist.
Leafnode bezieht automatisch die Newsgroups, die der oder die Nutzer
regelmäßig lesen, vom Newsserver des Providers. Weiter erlaubt es, lokale
(Standort-spezifische) Newsgruppen im LAN anzubieten.

%setup -q -n %{name}-2
%patch0 -p1
%patch1 -p1

autoreconf -v -i

%configure \
 --disable-silent-rules \
 --enable-spooldir=%spooldir \
 --enable-runas-user=$(id -un) \
%if 0%{?suse_version}
 --sysconfdir=%{_fillupdir}/sysconfig.%{name} \
 --sysconfdir=%{_sysconfdir}/leafnode \

make check

# first clean out any prior aborted runs

# We actually do not want filters to be installed in /etc/leafnode
%if 0%{?suse_version}
rm -vf $RPM_BUILD_ROOT/%{_fillupdir}/sysconfig.%{name}/filter*
rm -vf $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/leafnode/filter*

%if %{with systemd}
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
install -p systemd/%{name}@.service $RPM_BUILD_ROOT/%{_unitdir}/
install -p systemd/%{name}.socket $RPM_BUILD_ROOT/%{_unitdir}/
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/xinetd.d
install -p %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/xinetd.d/leafnode

# Templates for cronjobs
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.hourly
install -p %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir}/cron.hourly/leafnode.cron
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily
install -p %{SOURCE5} $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/leafnode.cron

mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
cat >$RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/leafnode << EOS
# Change the value of the following variable to "yes" to get hourly
# automatic fetching of all news from the configured sources
# Change the value of the following variable to "no" to switch off daily
# maintenance of the leafnode spool (recommended: leave it as it is).

for file in $RPM_BUILD_ROOT/%{_sysconfdir}/leafnode/*.example ; do
   NEWFN=$(basename $file .example);
   mv $file $RPM_BUILD_ROOT/%{_sysconfdir}/leafnode/$NEWFN

# When building without runas_user, then we need to set this
# parameter explicitly.
sed -i -e "s/^#\s*run_as_user.*\$/run_as_user = %{runas_user}/" \

touch $RPM_BUILD_ROOT/%{_sysconfdir}/leafnode/local.groups

%if 0%{?suse_version}

%if %{with systemd}
%if 0%{?suse_version}
%set_permissions %spooldir/leaf.node
%systemd_post leafnode@.service
service xinetd condrestart
if [ $1 -eq 1 ] ; then
    chown -R news:news %spooldir
    chmod -R 775 %spooldir

%if %{with systemd}
%if 0%{?suse_version}
%systemd_preun leafnode@.service
service xinetd condrestart

%if %{with systemd}
%if 0%{?suse_version}
%systemd_postun_with_restart leafnode@.service
service xinetd condrestart

%doc config.example filters.example COPYING COPYING.LGPL CREDITS
%doc README-FQDN.tex TODO ChangeLog AUTHORS README-leaf.node README.html

%config %{_sysconfdir}/leafnode/
%config(noreplace) %attr(640,root,news) %{_sysconfdir}/leafnode/config
%if 0%{?suse_version}
%config(noreplace) %{_fillupdir}/sysconfig.%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/leafnode
%if %{with systemd}
%attr(644,root,root) %{_unitdir}/%{name}*
%config(noreplace) %{_sysconfdir}/xinetd.d/leafnode
%config(noreplace) %attr(640,root,news) %{_sysconfdir}/leafnode/uucp
%config(noreplace) %attr(640,root,news) %{_sysconfdir}/leafnode/local.groups
%attr(751,root,root) %{_sysconfdir}/cron.*/leafnode.cron
%attr(755,root,root) %{_bindir}/leafnode-version
%attr(755,root,root) %{_bindir}/
%attr(755,root,root) %{_bindir}/newsq
%attr(755,root,root) %{_sbindir}/applyfilter
%attr(755,root,root) %{_sbindir}/checkgroups
%attr(755,root,root) %{_sbindir}/fetchnews
%attr(755,root,root) %{_sbindir}/leafnode
%attr(755,root,root) %{_sbindir}/rnews
%attr(755,root,root) %{_sbindir}/sendbatch.bash
%attr(755,root,root) %{_sbindir}/texpire
%doc %{_mandir}/man1/*
%doc %{_mandir}/man5/*
%doc %{_mandir}/man8/*
%attr(755,%{runas_user},%{runas_group}) %spooldir


* Tue Nov 22 2016 Matěj Cepl <> - 2.0.0.alpha20140727b-0.0.14.vcs0433b24
- systemd unit files are not executable anymore
- rebase on the top of the upstream Gitlab checkout.

* Thu Jan 08 2015 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.13.vcs0433b24
- Don't install default filters and fix xinetd configuration.

* Thu Jan 08 2015 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.12.vcs0433b24
- Make cronjobs into proper scripts and add proper configuration file.

* Mon Dec 29 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.11.vcs0433b24
- Add patch converting fetchnews(8) to UTF-8.

* Sat Dec 27 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.10.vcs0433b24
- Fix all FSF addresses in all license attributions.

* Sat Dec 27 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.9.vcs0433b24
- Use the patch for systemd posted upstream.

* Sat Dec 27 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.7.vcs0433b24
- Make it buildable on RHEL-6 (apparently just decreasing required
  autoconf is enough).

* Fri Dec 26 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.6.vcs0433b24
- Add a crontab job fetching news.

* Fri Dec 26 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.5.vcs0433b24
- Set run_as_user parameter in /etc/leafnode/config explicitly.

* Mon Dec 15 2014 Matej Cepl <> - 2.0.0.alpha20140727b-0.0.1
- Update to the latest upstream

* Thu Jul 24 2014 Matěj Cepl <> - 2.0.0.alpha-0.0.vcs20140724git3f38b2b
- Update to the latest upstream

* Wed May 23 2007 Matej Cepl <> - 2.0.0.alpha20070108a-3
- Added support for croning of texpire daily

* Thu Apr 26 2007 Matej Cepl <> - 2.0.0.alpha20070108a-2
- Add pcre-devel to Build-Requires; thanks for catching this.
- Add /etc/leafnode/local.groups

* Fri Mar 23 2007 Matej Cepl <> - 2.0.0.alpha20070108a-1
- new upstream release
- enabled pam

* Mon Jan 02 2006 Matěj Cepl <> 2.0.0.alpha20061010a-0
- experimental build