#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=nbd
pkgver=3.24
pkgrel=01
pkgdesc='tools for network block devices, allowing you to use remote block devices over TCP/IP w/o systemd'
arch=('x86_64')
url='https://nbd.sourceforge.io/'
depends=('glib2' 'gnutls' 'libnl')
backup=('etc/nbd-server/config')
source=("https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.xz"
        'config'
        'sysusers_nbd.conf')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --enable-syslog \
    --disable-systemd
  make
}

# checks still fail...
#check() {
#  cd "${srcdir}/${pkgname}-${pkgver}"
#
#  make check
#}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install
  install -D -m0644 systemd/nbd@.service "${pkgdir}"/usr/lib/systemd/system/nbd@.service

  install -D -m0644 "${srcdir}"/config "${pkgdir}"/etc/nbd-server/config
#  install -D -m0644 "${srcdir}"/nbd.service "${pkgdir}"/usr/lib/systemd/system/nbd.service
  install -D -m0644 "${srcdir}"/sysusers_nbd.conf "${pkgdir}"/usr/lib/sysusers.d/nbd.conf

  install -D -m0644 doc/README "${pkgdir}"/usr/share/doc/nbd/README
  rm -rf $pkgdir/usr/lib/systemd
}

#---- license gpg-key sha256sums ----

license=('GPL')

sha256sums=(6877156d23a7b33f75eee89d2f5c2c91c542afc3cdcb636dea5a88539a58d10c # nbd-3.24.tar.xz
	ee2e9fbbeb8a8b9b71d16b6f32eb41788f6def9d00cc4a47897ed3cb97cdde7c # config
	3fd98fe87d0b31b82126dc669f00355865f58fae81af3fccbc0d06504baef6cd) # sysusers_nbd.conf
