# Description: NFS utilities 
# URL: http://nfs.sourceforge.net/
# Maintainer: Juergen Daubert, jue at crux dot nu
# Depends on: libdevmapper util-linux libcap rpcsvc-proto rpcbind libevent keyutils sqlite3

name=nfs-utils
version=2.6.4
release=1
source=(https://www.kernel.org/pub/linux/utils/$name/$version/$name-$version.tar.xz
	exports idmapd.conf
	nfs nfsclient nfsserver rpc.idmapd rpc.statd rpc.mountd rpc.nfsd nfsdcld)

build() {
	cd $name-$version

	CONFIG_SHELL=/bin/bash \
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libexecdir=/usr/sbin \
		--with-statedir=/var/lib/nfs \
		--with-modprobedir=/etc/modprobe.d \
		--with-systemd=no \
		--without-tcp-wrappers \
		--disable-gss \
		--enable-libmount-mount
	make
	make DESTDIR=$PKG install

	install -d $PKG/etc/rc.d

	install -m 755 $SRC/nfs{,client,server,dcld} $PKG/etc/rc.d/
	install -m 755 $SRC/rpc.* $PKG/etc/rc.d/
	install -m 644 $SRC/{exports,idmapd.conf} $PKG/etc/

	install -m 644 utils/mount/nfsmount.conf $PKG/etc/
	install -m 644 nfs.conf $PKG/etc/

	install -d $PKG/var/lib/nfs/{rpc_pipefs,v4recovery,nfsdcltrack,nfsdcld}
	install -d $PKG/etc/exports.d

	install -d $PKG/lib
	mv $PKG/usr/lib/udev $PKG/lib
	sed 's|libexec|sbin|' -i $PKG/lib/udev/rules.d/99-nfs.rules

	# force rpc.statd to run as user nobody
	chown nobody $PKG/var/lib/nfs
}
