#
# spec file for package fcron
#

#norootforbuild

Name:           fcron
Version:        3.2.1
Release:        2.3
Summary:        A scheduler, that aims at replacing Vixie Cron.
License:        GPL
Group:          System/Daemons
URL:            http://fcron.free.fr/
Source:         http://fcron.free.fr/archives/fcron-%{version}.src.tar.gz
BuildRequires:  readline-devel
BuildRequires:  audit-devel
BuildRequires:  pam-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build




%description
Fcron is a scheduler. It aims at replacing Vixie Cron, so it
implements most of its functionalities.

But contrary to Vixie Cron, fcron does not need your system to be up 7
days a week, 24 hours a day: it also works well with systems which are
not running neither all the time nor regularly (contrary to
anacrontab).

In other words, fcron does both the job of Vixie Cron and anacron, but
does even more and better :)) ...

To do so, fcron allows you to use the standard mode in which you tell
it to execute one command at a given date and hour and to make it run
a command according to its time of execution, which is normally the
same as system up time. For example:

  Run the task 'save /home/ directory' every 3h15 of system up time.

and, of course, in order to make it really useful, the time remaining
until next execution is saved each time the system is stopped. You can
also say:

  run that command once between 2am and 5am

which will be done if the system is running at any time in this
interval.

Fcron also includes a useful system of options, which can be applied
either to every lines following the declaration or to a single line.
Some of the supported options permit to:

  * run jobs one by one (fcrontab option serial),
  * set the max system load average value under which the job should
    be run (fcrontab option lavg),
  * set a nice value for a job (fcrontab option nice),
  * run jobs at fcron's startup if they should have been run during
    system down time (fcrontab option bootrun),
  * mail user to tell him a job has not run and why (fcrontab option
    noticenotrun),
  * a better management of the mailing of outputs ...


%prep
%setup -q

# set the default path without /usr/local
pushd doc/en/man
    sed -i 's#/usr/local##g' *
popd

# do not change owner and grp with user rights
sed -i '/install:/s/perms//' Makefile.in 


export SENDMAIL=/usr/sbin/sendmail
if [ ! f /usr/sbin/sendmail
then
    su - root -c "cd /usr/sbin ; touch sendmail ; chmod 0755 sendmail"
#touch /usr/sbin/sendmail
#chmod 755 /usr/sbin/sendmail
fi
%build

%configure \
--localstatedir=/var \
--sysconfdir=/etc \
--with-sendmail=/usr/sbin/sendmail \
--with-piddir=/run \
--with-fifodir=/run \
--with-boot-install=no \
--with-editor=/usr/bin/joe

%{__make}

%install
# make_install
make DESTDIR=%{buildroot} ROOTNAME=`id -un` ROOTGROUP=`id -gn` install
#\
#    ETC=%{buildroot}%{_sysconfdir} \
#    DESTBIN=%{buildroot}%{_bindir} \
#    DESTSBIN=%{buildroot}%{_sbindir} \
#    DESTMAN=%{buildroot}%{_mandir} \
#    DESTDOC=%{buildroot}%{_docdir}/%{name} \
#    FCRONTABS=%{buildroot}/var/spool/fcron 
#    ROOTNAME=`id -un` ROOTGROUP=`id -gn`

%{__install} -d -m 0755 %{buildroot}/var/spool/fcron
%{__install} -d -m 0755 %{buildroot}/run
#
%{__install} -D -m 0755 script/sysVinit-launcher %{buildroot}%{_initrddir}/fcron
%{__install} -D -m 0755 convert-fcrontab %{buildroot}%{_bindir}
#
%{__install} -D -m 0755 debian/fcron-update-crontabs %{buildroot}%{_sbindir}/
%{__install} -D -m 0644 debian/fcron-update-crontabs.1 %{buildroot}%{_mandir}/man1/
#
%{__install} -D -m 0644 files/fcron.pam %{buildroot}%{_sysconfdir}/pam.d/fcron
%{__install} -D -m 0644 files/fcrontab.pam %{buildroot}%{_sysconfdir}/pam.d/fcrontab
#
#%{__perl} -p -i -e "s|^pidfile.*|pidfile = /run/fcron\.pid|g" %{buildroot}%{_sysconfdir}/fcron.conf
#%{__perl} -p -i -e "s|^fifofile.*|fifofile = /run/fcron\.fifo|g" %{buildroot}%{_sysconfdir}/fcron.conf
#
%{__mv} %{buildroot}%{_docdir}/%{name}-%{version} %{buildroot}%{_docdir}/%{name}
%{__rm} -f %{buildroot}%{_sysconfdir}/pam.conf
#
%{__chmod} 755 %{buildroot}%{_bindir}/*
%{__chmod} 755 %{buildroot}%{_sbindir}/*

%clean
%{__rm} -rf %{buildroot}

if [ ! -f /usr/lib/sendmail ]
then
    su - root -c "cd /usr/sbin ; rm -f sendmail"
fi

%pre
/usr/sbin/groupadd -r %{name} &> /dev/null ||:
/usr/sbin/useradd  -g %{name} -s /bin/true -r -c "fcron"  -d /var/spool/fcron %{name} &> /dev/null ||:

%preun
%stop_on_removal xbt_tracker

%post
%fillup_and_insserv -f xbt_tracker

%postun
%insserv_cleanup
%restart_on_update xbt_tracker

%files
%defattr(-,root,root)
%{_initrddir}/fcron
%attr(640,root,fcron) %config(noreplace) %{_sysconfdir}/fcron.allow
%attr(640,root,fcron) %config(noreplace) %{_sysconfdir}/fcron.conf
%attr(640,root,fcron) %config(noreplace) %{_sysconfdir}/fcron.deny
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/fcron
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/fcrontab
%{_bindir}/convert-fcrontab
%{_bindir}/fcronsighup
%{_bindir}/fcrondyn
%{_bindir}/fcrontab
%{_sbindir}/fcron
%{_sbindir}/fcron-update-crontabs
#%dir %attr(770,fcron,fcron) /var/spool/fcron
#%dir %attr(0755,root,root) /var/run/fcron
#
%{_mandir}/fr/man1/fcrondyn.1*
%{_mandir}/fr/man1/fcrontab.1*
%{_mandir}/fr/man3/bitstring.3*
%{_mandir}/fr/man5/fcron.conf.5*
%{_mandir}/fr/man5/fcrontab.5*
%{_mandir}/fr/man8/fcron.8*
%{_mandir}/man1/fcron-update-crontabs.1*
%{_mandir}/man1/fcrondyn.1*
%{_mandir}/man1/fcrontab.1*
%{_mandir}/man3/bitstring.3*
%{_mandir}/man5/fcron.conf.5*
%{_mandir}/man5/fcrontab.5*
%{_mandir}/man8/fcron.8*
#
%doc %{_docdir}/%{name}

%changelog
* Thu Feb 07 2018 holgerbruenjes@gmx.net
- update version 3.2.1
* Fri May 06 2016 holgerbruenjes@gmx.net
- rebuild for LibC-2.15
* Sun Nov 30 2014 holgerbruenjes@gmx.net
- update version 3.2.0
* Mon Jan 20 2014 holgerbruenjes@gmx.net
- update version 3.1.2
* Mon Apr 16 2007 mrueckert@suse.de
- first try. not meant for production use.