# Description: Adaptive readahead daemon.
# URL: http://sourceforge.net/projects/preload/
# Maintainer: Danny Rawlins, romster at shortcircuit dot net dot au
# Packager: Mark Rosenstand, mark at borkware dot net
# Depends on: glib help2man

name=preload
version=0.4
release=4
source=(http://dl.sourceforge.net/sourceforge/preload/preload-$version.tar.gz \
	rc.preload)

build() {
	cd preload-$version

	# preload(8) is generated by help2man if available, otherwise
	# it only contains "help2man is required to generate this file."
	##rm -rv usr/man
	if [ -z "$(pkginfo -i |grep 'help2man ')" ]; then
		echo 'Install help2man.'
		exit 0
	fi

	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var

	make -j1
	make DESTDIR=$PKG install

	cd $PKG
	rm -r etc/{rc.d,logrotate.d,sysconfig}
	rm -r usr/share/doc
	rmdir usr/share
	
	# preload.state is installed 644 but changed to 640 on first run,
	# so we change the mode in the package to avoid rejmerge.
	chmod -v 640 var/lib/preload/preload.state
	
	# install services rc script
	install -D -m755 $SRC/rc.preload $PKG/etc/rc.d/preload
}

