# Template file for 'cronie'
pkgname=cronie
version=1.7.2
revision=2
build_style=gnu-configure
configure_args="--with-inotify --without-selinux --with-pam
 --enable-anacron --enable-pie --enable-relro"
makedepends="pam-devel"
depends="run-parts"
short_desc="Runs specified programs at scheduled times"
maintainer="Orphaned <orphan@voidlinux.org>"
license="BSD-2-Clause"
homepage="https://github.com/cronie-crond/cronie"
changelog="https://raw.githubusercontent.com/cronie-crond/cronie/master/NEWS"
distfiles="${homepage}/releases/download/cronie-${version}/cronie-${version}.tar.gz"
checksum=f1da374a15ba7605cf378347f96bc8b678d3d7c0765269c8242cfe5b0789c571
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/cron 0755 root root
	/var/spool/anacron 0755 root root"
conf_files="/etc/anacrontab /etc/pam.d/crond /etc/cron.deny /etc/default/anacron"
provides="cron-daemon-0_1"

alternatives="
 crond:crond:/etc/sv/cronie
 crond:crond:/usr/bin/cronie-crond
 crond:crontab:/usr/bin/cronie-crontab
 crond:crontab.1:/usr/share/man/man1/cronie-crontab.1
 crond:crond.8:/usr/share/man/man8/cronie-crond.8
"

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	makedepends+=" musl-obstack-devel"
fi

pre_configure() {
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		export LIBS="-lobstack"
	fi
}

post_install() {
	vsv cronie cron
	vinstall ${FILESDIR}/crond.pam 644 etc/pam.d crond

	# Add /etc/cron.deny empty, to allow all users.
	touch ${DESTDIR}/etc/cron.deny
	chmod 644 ${DESTDIR}/etc/cron.deny

	# Install anacron related files
	vinstall contrib/anacrontab 644 etc
	vinstall contrib/0hourly 644 etc/cron.d
	vinstall contrib/0anacron 755 etc/cron.hourly
	vinstall ${FILESDIR}/anacron 644 etc/default

	# crontab must be setuid
	chmod u+s ${DESTDIR}/usr/bin/crontab

	# All licenses are here
	vlicense COPYING

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