# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           legacysupport 1.0

# for strndup
legacysupport.newest_darwin_requires_legacy 10

name                fcron
version             3.4.1
revision            0
categories          sysutils
license             GPL-2
maintainers         {khindenburg @kurthindenburg} openmaintainer
description         fcron is an alternative scheduler aka cron daemon
long_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).

homepage            http://fcron.free.fr/
master_sites        http://fcron.free.fr/archives
# The official git repo is now https://github.com/yo8192/fcron
extract.suffix      .src.tar.gz

checksums           rmd160  119ca00c096c93b4d46ae0e8eeb030fe8bf89992 \
                    sha256  75717e3916cbcefbcde58e7bfd515150d75f7632385b2db6bdd2fbc24289ecd5 \
                    size    624543

depends_build-append    port:perl5
depends_lib-append      port:readline

configure.args      --with-boot-install=no \
                    --with-pam=no \
                    --with-selinux=no

set startup_root ""
startupitem.create  yes
startupitem.name    fcron
startupitem.start   "\[ -x ${prefix}/sbin/fcron \] && ${prefix}/sbin/fcron -b"
startupitem.stop    "\[ -r ${prefix}/var/run/fcron.pid \] \\" \
                    "&& kill -KILL `cat ${prefix}/var/run/fcron.pid`"

destroot.keepdirs   ${destroot}${prefix}/var/spool/fcron

add_users fcron group=fcron shell=/bin/bash realname=fcronServer

post-patch {
    # LDFLAGS was not used before; combined it with LIBS
    reinplace -W "${worksrcpath}" "s|@LIBS@|@LIBS@ @LDFLAGS@|g" Makefile.in

    reinplace -W "${worksrcpath}/script" "s|/usr/bin/env perl|${prefix}/bin/perl5|" has_usrgrp.pl gen-in.pl
}

post-destroot {
    if {${os.major} >= 17} {
        file attributes ${destroot}${prefix}/sbin/fcron -permissions +s
        file attributes ${destroot}${prefix}/bin/fcrontab -permissions +s
        file attributes ${destroot}${prefix}/bin/fcrondyn -permissions +s
        file attributes ${destroot}${prefix}/bin/fcronsighup -permissions +s
    }

    foreach file [glob ${destroot}${prefix}/etc/fcron*] {
        file rename ${file} ${file}.sample
    }
}

notes "
Before starting ${name}, create the configuration file ${prefix}/etc/fcron.conf\
by using ${prefix}/etc/fcron.conf.sample as a reference.

Before starting ${name}, create the file ${prefix}/etc/fcron.allow\
by using ${prefix}/etc/fcron.allow.sample as a reference.

If you get errors while using 'fcrontab -e', you must have EDITOR set.
Try 'EDITOR=/usr/bin/vi fcrontab -e', if that works, set EDITOR in your
shells config.
"

livecheck.type      regex
livecheck.regex     "${name} (\\d+(?:\\.\\d+)+)"
