# Template file for 'OpenRC'
pkgname=OpenRC
version=20110211
revision=14
wrksrc=openrc-${version}
distfiles="http://xbps.nopcode.org/distfiles/openrc-$version.tar.bz2"
build_style=custom-install
short_desc="Universal init system"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://roy.marples.name/projects/openrc"
license="BSD"
checksum=16840a9635648e501e2f94464f6cf1c26b6bbdbbc7e3d9a1f8466117271885e1
long_desc="
 OpenRC is a dependency based init system that works with the system
 provided init program, normally /sbin/init. It is not a replacement for
 /sbin/init. OpenRC is 100% compatible with Gentoo init scripts, which
 means you can probably find one for the daemons you want to start in the
 Gentoo Portage Tree. OpenRC also provides an init script that runs BSD
 rc.d style scripts too, making it easy to port your BSD system to OpenRC." 

keep_empty_dirs=yes
conf_files="
/etc/rc.conf
/etc/conf.d/bootmisc
/etc/conf.d/consolefont
/etc/conf.d/dmesg
/etc/conf.d/fsck
/etc/conf.d/hostname
/etc/conf.d/hwclock
/etc/conf.d/keymaps
/etc/conf.d/locale
/etc/conf.d/network
/etc/conf.d/localmount
/etc/conf.d/modules
/etc/conf.d/staticroute
/etc/conf.d/urandom
/etc/inittab"

subpackages="$pkgname-devel"
 
Add_dependency run glibc
Add_dependency run psmisc
Add_dependency run sysvinit
Add_dependency build coreutils

_version="0.7.0-${version} #${revision}"
_branding="Void GNU/Linux"

do_build()
{
	# Install the "locale" service
	cp ${FILESDIR}/locale.rc ${wrksrc}/init.d/locale.in

	# Fix path for kbd stuff.
	for f in init.d/consolefont.in conf.d/consolefont; do
		sed -i -e "s|/usr/share|/lib/kbd|g" ${wrksrc}/${f}
	done

	make ${makejobs} VERSION="${_version}" BRANDING="${_branding}"
}

do_install()
{
	make DESTDIR=${DESTDIR} VERSION="${_version}" \
		BRANDING="${_branding}" install

	install -D -m755 ${wrksrc}/support/sysvinit/inittab \
		${DESTDIR}/etc/inittab
	install -D -m644 ${FILESDIR}/$pkgname.logrotate \
		${DESTDIR}/etc/logrotate.d/OpenRC
	install -D -m644 ${FILESDIR}/locale.confd \
		${DESTDIR}/etc/conf.d/locale
	#
	# Create a fake rc.d directory with links to mimic old sysvinit
	# runlevel stuff.
	install -d ${DESTDIR}/etc/init.d/fake-rc.d
	for f in 0 1 2 3 4 5 6; do
		cd ${DESTDIR}/etc/init.d && ln -s fake-rc.d rc${f}.d
	done

	chmod 755 ${DESTDIR}/lib/lib*
	chmod 755 ${DESTDIR}/usr/lib/lib*
	rmdir ${DESTDIR}/lib/rc/init.d
}