# Template file for 'nfs-utils'
pkgname=nfs-utils
version=1.3.3
revision=4
build_style=gnu-configure
configure_args="--with-statduser=nobody --enable-gss --enable-nfsv4
 --with-statedir=/var/lib/nfs --enable-libmount-mount --enable-gss
 --enable-uuid --enable-ipv6 --without-tcp-wrappers
 --with-tirpcinclude=$XBPS_CROSS_BASE/usr/include/tirpc
 --with-krb5=$XBPS_CROSS_BASE"
short_desc="Network File System utilities"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2"
homepage="http://nfs.sourceforge.net"
distfiles="${KERNEL_SITE}/utils/${pkgname}/${version}/${pkgname}-${version}.tar.xz"
checksum=700d689c5622c87953c34102e5befafc4d3c811e676852238f0dd79c9c0c084d

hostmakedepends="pkg-config libtirpc-devel"
makedepends="libblkid-devel libmount-devel libtirpc-devel
 libnfsidmap-devel keyutils-devel libevent-devel mit-krb5-devel
 libevent-devel device-mapper-devel libcap-devel sqlite-devel"
depends="rpcbind"
conf_files="/etc/exports /etc/idmapd.conf"
make_dirs="
 /var/lib/nfs/rpc_pipefs	0755	root	root
 /var/lib/nfs/sm		0750	root	root
 /var/lib/nfs/v4recovery 	0755    root    root
 /etc/exports.d			0750	root	root
"

pre_build() {
	if [ "$CROSS_BUILD" ]; then
		sed -i '/SUBDIRS/s,tools,,' Makefile.in
	fi
	case "$XBPS_TARGET_MACHINE" in
	*-musl)
		cd tools/rpcgen
		make CC=cc CFLAGS= CPPFLAGS= LDFLAGS= ${makejobs}
		;;
	esac
}
post_install() {
	mv ${DESTDIR}/sbin/* ${DESTDIR}/usr/bin
	# conffiles
	vconf ${FILESDIR}/exports
	vconf ${FILESDIR}/idmapd.conf
	# runit services
	vsv statd
	vsv nfs-server

	rm -rf ${DESTDIR}/var/lib/nfs
}

rpcgen_package() {
	build_style=meta
	short_desc="A RPC protocol compiler"
	pkg_install() {
		case "$XBPS_TARGET_MACHINE" in
		*-musl)
			cd ${wrksrc}/tools/rpcgen
			make clean
			make CC_FOR_BUILD="$CC"
			vbin ${wrksrc}/tools/rpcgen/rpcgen
			;;
		esac
	}
}
