# Template file for 'dcron'
pkgname=dcron
version=4.5
revision=34
conf_files="/var/spool/cron/root"
short_desc="Dillon's lightweight cron daemon"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only"
homepage="https://github.com/dubiousjim/dcron"
changelog="https://raw.githubusercontent.com/dubiousjim/dcron/v${version}/CHANGELOG"
distfiles="https://github.com/dubiousjim/dcron/archive/v${version}.tar.gz"
checksum=7c047194b9339b781971b000bf5512c11e856d20a14fe5323d5a1823f04c2a3f
provides="cron-daemon-0_1"

alternatives="
 crond:crond:/etc/sv/dcron
 crond:crond:/usr/bin/dcrond
 crond:crontab:/usr/bin/dcrontab
 crond:crontab.1:/usr/share/man/man1/dcrontab.1
 crond:crond.8:/usr/share/man/man8/dcrond.8
"

make_dirs="
 /etc/cron.d 0755 root root
 /etc/cron.hourly 0755 root root
 /etc/cron.daily 0755 root root
 /etc/cron.weekly 0755 root root
 /etc/cron.monthly 0755 root root
 /var/spool/cronstamps 0755 root root"

do_configure() {
	sed -i 's,-[og] root,,g' Makefile
}

do_build() {
	make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
		PREFIX=/usr CRONTAB_GROUP=$(whoami) CRONTABS=/var/spool/cron \
		CRONSTAMPS=/var/spool/cronstamps ${makejobs}
}

do_install() {
	make SBINDIR=/usr/bin DESTDIR=${DESTDIR} install

	vbin extra/run-cron
	install -Dm600 extra/root.crontab ${DESTDIR}/var/spool/cron/root

	# crontab must be setuid for all users to work!
	chmod 4755 ${DESTDIR}/usr/bin/crontab

	vsv dcron

	# Fix conflicts with other packages
	mv ${DESTDIR}/usr/bin/crond ${DESTDIR}/usr/bin/dcrond
	mv ${DESTDIR}/usr/bin/crontab ${DESTDIR}/usr/bin/dcrontab
	mv ${DESTDIR}/usr/share/man/man1/crontab.1 ${DESTDIR}/usr/share/man/man1/dcrontab.1
	mv ${DESTDIR}/usr/share/man/man8/crond.8 ${DESTDIR}/usr/share/man/man8/dcrond.8
}
