# Template file for 'dracut'
pkgname=dracut
version=047
revision=4
build_style=configure
configure_args="--prefix=/usr --sysconfdir=/etc"
hostmakedepends="asciidoc pkg-config"
makedepends="libkmod-devel"
depends="bash coreutils cpio psmisc"
conf_files="/etc/dracut.conf"
make_dirs="
	/etc/dracut.conf.d 0755 root root
	/usr/lib/dracut/dracut.conf.d 0755 root root"
homepage="http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html"
short_desc="A new initramfs infrastructure"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2.0-or-later"
distfiles="${KERNEL_SITE}/utils/boot/$pkgname/$pkgname-$version.tar.xz"
checksum=b0afd3bdd886b2f756743c91a00a155da9df0644625b1c565c3d5ef78cd76ab2

case "$XBPS_TARGET_MACHINE" in
*-musl) # Add musl-fts implementation
	makedepends+=" musl-fts-devel"
	;;
esac

do_build() {
	case "$XBPS_TARGET_MACHINE" in
		*-musl) make ${makejobs} LDLIBS="${XBPS_CROSS_BASE}/usr/lib/libfts.a";;
	esac
}

do_check() {
	# Requires the distfile to be a git repository
	:
}

post_install() {
	# kernel hooks.
	vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-dracut
	vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-dracut
	# We don't need the systemd stuff.
	rm -rf ${DESTDIR}/usr/lib/dracut/modules.d/*systemd*
	rm -f ${DESTDIR}/usr/share/man/man8/*.service.*
	rm -rf ${DESTDIR}/usr/lib/kernel
}

dracut-network_package() {
	depends="dhclient dracut-${version}_${revision}"
	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
	}
}
