description="Userspace server and client tools necessary to use the kernel's NFS abilities."
url="http://nfs.sourceforge.net"

packager="Spiky <spiky@nutyx.org>"

makedepends=(util-linux libtirpc rpcbind rpcsvc-proto)
run=(rpcbind)

name=nfs-utils
version=2.6.2

runyx_version=20201011

source=(http://downloads.tuxfamily.org/nutyx/files/runyx-${runyx_version}.tar.xz
	http://downloads.sourceforge.net/nfs/$name-$version.tar.gz)

run=(rpcbind)

prepare() {

if ! (getent group nogroup > /dev/null); then
   groupadd -g 99 nogroup
fi
if ! (getent passwd nobody > /dev/null); then
   useradd -c "Unprivileged Nobody" -d /dev/null \
   -g nogroup -s /bin/false -u 99 nobody
fi
}
build() {
# build package

cd $name-$version
./configure --prefix=/usr \
--sysconfdir=/etc         \
--sbindir=/sbin           \
--disable-nfsv4           \
--disable-gss

make
mkdir $PKG/sbin
make DESTDIR=$PKG install
chmod u+w,go+r $PKG/sbin/mount.nfs
chown nobody.nogroup $PKG/var/lib/nfs

# Services
cd ../runyx-${runyx_version}
make DESTDIR=$PKG install-sysv-nfs-server

make DESTDIR=$PKG install-runyx-nfs-server
sed -i s@install-nfs@install-sysd-nfs@ services/sysd/Makefile
sed -i s@/usr/sbin@/sbin@ \
$PKG/lib/init/services/nfs-server/finish
sed -i s@/usr/sbin@/sbin@ \
$PKG/lib/init/services/nfs-server/run

sed -i 's@rpc.mountd@rpc.mountd --foreground@' \
$PKG/lib/init/services/nfs-server/run


make DESTDIR=$PKG install-sysd-nfs-server
}
