# Template file for 'dracut'
pkgname=dracut
version=034
revision=1
hostmakedepends="libxslt docbook-xsl asciidoc"
makedepends="psmisc cpio xz systemd"
homepage="http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html"
short_desc="A new initramfs infrastructure"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
distfiles="${KERNEL_SITE}/utils/boot/$pkgname/$pkgname-$version.tar.xz"
checksum=6a03d054f78bdf6e0ff6b66f374a24381fe12537f9e86a383f4486db48d1caeb

do_build() {
	make ${makejobs} sysconfdir=/etc systemdsystemunitdir=/usr/lib/systemd/system
}

do_install() {
	# fix path to busybox.
	sed -i "s|/sbin/busybox|/bin/busybox|g" modules.d/05busybox/module-setup.sh

	make DESTDIR=${DESTDIR} sysconfdir=/etc systemdsystemunitdir=/usr/lib/systemd/system install

	# kernel hooks.
	vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 10-dracut
	vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 10-dracut
}

dracut-network_package() {
	depends="dracut>=${version}"
	short_desc+=" - network modules"
	noarch=yes
	pkg_install() {
		for f in 40network 90livenet 95fcoe 95iscsi \
		    95nbd 95nfs 95zfcp 95znet; do
			vmove usr/lib/dracut/modules.d/${f}
		done
	}
}

dracut_package() {
	depends="psmisc>=22.14_2 cpio xz systemd>=206"
	conf_files="/etc/dracut.conf"
	make_dirs="
		/etc/dracut.conf.d 0755 root root
		/usr/lib/dracut/dracut.conf.d 0755 root root"
	pkg_install() {
		vmove all
	}
}
