# -*- 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.2.1
revision            3
categories          sysutils
platforms           darwin
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            https://web.archive.org/web/20190804123648/http://fcron.free.fr/
# This archives still works
master_sites        http://fcron.free.fr/archives
# The official git repo is now https://github.com/yo8192/fcron; nothing there ATM
extract.suffix      .src.tar.gz

checksums           rmd160  a3c17af13e2b6fd9e30e9365822e6609c3d79464 \
                    sha256  6114d0a39a32853669c0c0ba0f96d92920e7cabca3ff1edf37d25750403e5f6a

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      none
