# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>

pkgname=moosefs
pkgver=3.0.116
pkgrel=1
pkgdesc='High performing and fault tolerant distributed file system'
url='https://moosefs.com/'
replaces=(mfs-master mfs-chunkserver mfs-client)
conflicts=(mfs-master mfs-chunkserver mfs-client)
arch=(x86_64)
license=(GPL2)
depends=(fuse2 libpcap python xfsprogs)
source=("$pkgname-$pkgver.tgz::https://github.com/moosefs/moosefs/archive/v$pkgver.tar.gz"
        moosefs.sysusers)
b2sums=('0740c53cfa8ebe59b32ca5edb792c67b0ac382a23da8ffae58b04591a762e35b4e3a8048f476afaedfc8ba58e1abae158eb34c2f2e2e2acb2fca76a1ce754341'
        '1d725b36f8c5d7ca458cc64166ebf8d1c477c32c51c652e8f521b37eeed942ca2f3ca098de2c1a65d524257308fc8758071bd129624c2d82022f38bda3823a5e')

build() {
  cd $pkgname-$pkgver
  ./configure \
    --localstatedir=/var/lib \
    --mandir=/usr/share/man \
    --prefix=/usr \
    --sysconfdir=/etc \
    --with-default-group=mfs \
    --with-default-user=mfs \
    --with-systemdsystemunitdir=/usr/lib/systemd/system
  make
}

package() {
  make DESTDIR="$pkgdir" -C $pkgname-$pkgver install

  # Move mount.moosefs from sbin to usr/bin. They end up in
  # /usr/bin just the same, but this silences a warning
  mv "$pkgdir/sbin/"* "$pkgdir/usr/bin/"
  mv "$pkgdir/usr/sbin/"* "$pkgdir/usr/bin/"
  rmdir "$pkgdir/sbin" "$pkgdir/usr/sbin"

  install -Dm644 "$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
}
