PortSystem		1.0
PortGroup                   makefile 1.0

name			anacron
version	 		2.3
revision                    4
checksums                   rmd160  613de5f8612871d92f6059c6cd324899f6fb8fcb \
                            sha256  5ceee6f22cd089bdaf1c0841200dbe5726babaf9e2c432bb17c1fc95da5ca99f \
                            size    24140

categories		sysutils
license	 		GPL-2+
maintainers		nomaintainer
description		Schedules periodic jobs on systems that are not permanently up
long_description	Anacron is a periodic command scheduler. It executes \
					commands at intervals specified in days. Unlike \
					cron, it does not assume that the system is running \
					continuously.
platforms		darwin
homepage		http://sourceforge.net/projects/anacron
master_sites	sourceforge:project/anacron/anacron/${version}

patchfiles                  Makefile.patch \
                            README.patch \
                            anacron.8.patch \
                            anacrontab.5.patch \
                            gregor.c.patch \
                            log.c.patch \
                            main.c.patch \
                            matchrx.c.patch \
                            readtab.c.patch

post-patch {
    reinplace -W ${worksrcpath} "s|__PREFIX|${prefix}|g" \
        README anacron.8 anacrontab.5
    xinstall -W ${filespath} -m 0644 obstack.c obstack.h ${worksrcpath}
}

# obstack.c:406:5: error: implicitly declaring library function 'abort' with type 'void (void) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
# obstack.c:486:3: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
configure.cflags-append     -DHAVE_STDLIB_H

makefile.has_destdir        no
makefile.override-append    PREFIX

destroot.keepdirs	${destroot}${prefix}/etc/cron.daily \
					${destroot}${prefix}/etc/cron.weekly \
					${destroot}${prefix}/etc/cron.monthly \
					${destroot}${prefix}/var/spool/anacron

post-destroot {
    xinstall -m 0755 ${filespath}/run-parts ${destroot}${prefix}/bin/
	xinstall -m 0644 ${filespath}/anacrontab.sample \
		${destroot}${prefix}/etc/anacrontab-dist
	reinplace "s|__PREFIX|${prefix}|g" \
		${destroot}${prefix}/etc/anacrontab-dist
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	xinstall -m 0644 -W ${worksrcpath} ChangeLog COPYING README TODO \
		${destroot}${prefix}/share/doc/${name}

	# Create startup rc script (if non-Darwin)
	if {${os.platform} ne "darwin"} {
		xinstall -d -m 0755 ${destroot}${prefix}/etc/rc.d
        xinstall -m 0755 -c ${filespath}/anacron.sh \
			${destroot}${prefix}/etc/rc.d/
		reinplace "s|__PREFIX|${prefix}|g" \
			${destroot}${prefix}/etc/rc.d/anacron.sh
	}
}

post-activate {
	# If no anacrontab already installed, copy sample file
	if {![file exists ${prefix}/etc/anacrontab]} {
		xinstall -m 0644 ${prefix}/etc/anacrontab-dist ${prefix}/etc/anacrontab
	}
}

platform darwin {
	startupitem.create			yes
	startupitem.name			Anacron
	startupitem.start			"\[ -n \"`grep anacron /etc/crontab`\" \] \\"
	startupitem.start-append	"\t|| echo \"10  *  *  *  *  root  ${prefix}/sbin/anacron -s\" >>/etc/crontab"
	startupitem.start-append	"${prefix}/sbin/anacron -s"
	startupitem.stop			"/usr/bin/killall -SIGUSR1 anacron"
}
