# Maintainer: John Lane <archlinux at jelmail dot com>
# Contributor: Johannes Dewender  arch at JonnyJD dot net

pkgname=targetcli-fb
pkgver=3.0.2
pkgrel=1
pkgdesc="free branch of the targetcli LIO administration shell (iSCSI + Co)"
arch=('any')
url="https://github.com/open-iscsi/targetcli-fb"
license=('Apache-2.0')
groups=()
depends=(
  'python'
  'python-rtslib-fb'
  'python-configshell-fb'
  'python-gobject'
)
makedepends=(
  'python-build'
  'python-hatch-vcs'
  'python-hatchling'
  'python-installer'
  'python-wheel'
)
optdepends=()
provides=('targetcli')
backup=()
options=()
install=
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/open-iscsi/${pkgname}/archive/v${pkgver}.tar.gz)
sha512sums=('9b7dbf2a924f3811895efa366ea69d846422da9a9e6d470c11d3eb0e04a41b6b9102999aadf98889a04cfac78fe01f5f4969a74088e3c8a12a86d1dad9b29a51')

build() {
  cd "$srcdir/$pkgname-$pkgver"
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation
  gzip --stdout targetcli.8 > "targetcli.8.gz"
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -d -m 750 "${pkgdir}/etc/target"
  install -D -m 644 targetcli.8.gz "$pkgdir/usr/share/man/man8/targetcli.8.gz"
  install -D -m 644 systemd/targetclid.service "$pkgdir/usr/lib/systemd/system/targetclid.service"
  install -D -m 644 systemd/targetclid.socket "$pkgdir/usr/lib/systemd/system/targetclid.socket"
  install -D -m 644 README.md "$pkgdir/usr/share/doc/targetcli/README.md"
  install -D -m 644 THANKS "$pkgdir/usr/share/doc/targetcli/THANKS"
}
