app=nfs-utils
version=2.5.1
build=1sml
homepage="https://mirrors.edge.kernel.org/pub/linux/utils/nfs-utils/"
download="https://mirrors.edge.kernel.org/pub/linux/utils/nfs-utils/2.5.1/nfs-utils-2.5.1.tar.xz"
desc="Network File System daemons and utilities"
requires="libtirpc keyutils"

build() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version 
  fixbuilddirpermissions

  applypatch $srcdir/musl-configure_ac.patch
  applypatch $srcdir/musl-getservbyport.patch
  applypatch $srcdir/musl-svcgssd-sysconf.patch
  applypatch $srcdir/musl-time64.patch

  ./configure \
    --prefix="" \
    --sysconfdir=/etc \
    --bindir=/bin \
    --sbindir=/bin \
    --enable-static=no \
    --enable-ipv6 \
    --enable-nfsv4 \
    --enable-uuid \
    --enable-libmount-mount \
    --disable-gss \
    --with-rpcgen=internal \
    --without-tcp-wrappers 

  make
  make -j1 install DESTDIR=$pkg 

  cp COPYING $pkgdocs/

  ( 
   if [ -d $pkg/sbin ] ; then 
     cd $pkg ; mv sbin/* bin/ ; rmdir sbin 
   fi
  )

  mkdir -p $pkg/var/log/nfsd
  install -Dm 644 $srcdir/exports $pkg/etc/exports.new
  install -Dm 644 $srcdir/rc.nfsd $pkg/etc/rc.d/rc.nfsd.new
  install -Dm 644 $srcdir/nfs.default $pkg/etc/default/nfs.new

  # These might be in use:
  ( 
    cd $pkg/var/lib/nfs
    for config_file in etab rmtab state ; do
        mv ${config_file} ${config_file}.new
    done
  )

  mkfinalpkg
}

sha512sums="
b332bb20461a90262855b8860e3e018a375a8d982ef9caed6359eb069b8332a15c6404fea1817c7bec10366d0c3dc30b2e10a9253fadf3768a19ab1554c549c0  nfs-utils-2.5.1.tar.lz
3f245b1870a47998d90cee191dba528dede7d2e18abad3f045864f95039057cda5a22708d89fcc086eeed452729c397a0284c73c1c7037277943a9890504e250  musl-configure_ac.patch
94d7ba23164660f1da9298494dff75c57f5a300cb32b2922bc2226fcdaded7eaaa0c50a59a145ac7c75639d177558b5f5594fb1f03a50f60f4c577c93b135748  musl-getservbyport.patch
52eeade44753f2002bf99d58ad4982086aab74ef8b14de46be547f23508197f58a6ff529145f96de7f031ac0bb7779b648d05fd981cdd91556dd13d068dfe57b  musl-svcgssd-sysconf.patch
8efc48cdc6f8cfafe476241f95ca8dc89ac7b3402d4230d20ef1e066990c542b8350f9b11f495cc261f25f1a705e35445fa89ca729f0d162e0ed44b0d8a47344  musl-time64.patch
"
