# Maintainer: Diaz Devera Victor <vitronic2@gmail.com>

pkgname=fcron
pkgver=3.2.0
pkgrel=2
pkgdesc="periodical command scheduler for systems not always up"
url="http://fcron.free.fr/"
install="fcron.pre-install"
options="suid !check"
pkgusers="fcron"
pkggroups="fcron"
arch="all"
license="GPL"
depends=""
makedepends="readline-dev perl"
subpackages="$pkgname-pam $pkgname-doc"
source="http://fcron.free.fr/archives/${pkgname}-${pkgver}.src.tar.gz
	systab.orig
	fcron.initd"

_builddir="$srcdir"/${pkgname}-${pkgver}

prepare() {
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./configure --prefix=/usr \
		--with-editor=/usr/bin/vi \
		--with-spooldir=/var/spool/fcron \
		--sysconfdir=/etc/fcron \
		--with-answer-all=no \
		--with-boot-install=no \
		--localstatedir=/var \
		--with-piddir=/run \
		--with-sendmail=no \
		--with-selinux=no \
		--with-systemdsystemunitdir=no \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir/" install
	install -Dm775 ${srcdir}/fcron.initd ${pkgdir}/etc/init.d/fcron
	rm -r ${pkgdir}/var/run
	#for some reason it man/fr is not compressed, for that reason I erase
	rm -r ${pkgdir}/usr/share/man/fr
	install -Dm640 "${srcdir}/systab.orig" "${pkgdir}/var/spool/fcron/systab.orig"
}

pam() {
	cd "$_builddir"
	arch="noarch"
	pkgdesc="PAM configuration file for fcron package."
	depends="fcron"
	mkdir $subpkgdir
	install -Dm644 files/fcron.pam "$subpkgdir/etc/pam.d/fcron"
	install -Dm644 files/fcrontab.pam "$subpkgdir/etc/pam.d/fcrontab"
}

md5sums="4b031c2fba32a98fa814d1557158b0e9  fcron-3.2.0.src.tar.gz
64ece6028dc5d552107ca536dc11395b  systab.orig
225694ccc395fc21956593fa47959064  fcron.initd"
sha256sums="eb13b86ed96805d117e19847f1da30b834f1990f7ef4c38f5007234d44679564  fcron-3.2.0.src.tar.gz
d341910feee898102c810dcc73dfce48884f1662d9b0dfe3c8c4ca8228c4a497  systab.orig
ee83fd59107c6aad60c06c6b58d154697c17fc30686533fdf2a6269a577bef2d  fcron.initd"
sha512sums="97b200dfec02ca0aba76abf3cf71f54608fbadf46aa29d81d7316920fb1bebbba81d0118925f658cd9062f362b6075467c7f595e736b47616995a95958ae776b  fcron-3.2.0.src.tar.gz
7516c9a51b1f6c29f1256c4697028b47f7883bf5fb08ccc585cf49e4edc7598a9730a225a03aaf3749698a94b9d01dda76cd3f352c0c868960fd09374df44199  systab.orig
070f8bbcbb3c5ccfed6bbe2ca85ef959426d58ee1615dcee4b0289f62fb7c151895da78fa63218e3bcc8428ed18acf7c591b09981171040f5dfada685dd9b1c1  fcron.initd"
