# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=open-iscsi
pkgver=%version%
pkgrel=%release%
pkgdesc='iSCSI userland tools'
arch=('x86_64')
url='https://www.open-iscsi.com/'
license=('GPL')
makedepends=('meson' 'systemd')
depends=('systemd-libs' 'util-linux-libs' 'kmod' 'openssl' 'open-isns')
install=$pkgname.install
backup=('etc/iscsi/iscsid.conf'
	'etc/iscsi/initiatorname.iscsi')
options=('docs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/open-iscsi/open-iscsi/archive/$pkgver.tar.gz")
sha256sums=('60e2a1e3058a8af7f702e86a5a0511b05b8754d29d3d2df4e0e301399b5cf70a')

build() {
  local _meson_options=(
    -Discsi_sbindir=/usr/bin/
    -Drulesdir=/usr/lib/udev/rules.d/
  )

  arch-meson "${pkgname}-${pkgver}" build "${_meson_options[@]}"

  meson compile -C build
}

package() {
  DESTDIR="${pkgdir}" meson install -C build

  # no initiatorname in package, initialized in install script
  echo -n > "${pkgdir}"/etc/iscsi/initiatorname.iscsi

  # install docs
  install -D -m0644 -t "${pkgdir}"/usr/share/doc/${pkgname}/ "${pkgname}-${pkgver}"/{Changelog,README}
}
