# Maintainer: Kyle Fuller <kyle@fuller.li>
# Contributor: George Rawlinson <grawlinson@archlinux.org>

pkgname=znc-palaver
pkgver=1.2.1
pkgrel=1
pkgdesc="ZNC module for push notifications from Palaver"
arch=('x86_64')
url="https://github.com/cocodelabs/znc-palaver"
license=('MIT')
depends=('znc=1.8.2') # modules require recompilation on every version change
makedepends=(
  'git'
  'python'
  'cmake'
)
checkdepends=(
  'python-pytest'
  'python-pytest-asyncio'
  'python-semantic-version'
)
_commit='825cb6814d64006ca0f85fec23fa0a8a3a2d14ca'
source=(
  "git+https://github.com/cocodelabs/znc-palaver.git#commit=$_commit"
  'fix-deprecated-loop-argument.patch::https://patch-diff.githubusercontent.com/raw/cocodelabs/znc-palaver/pull/65.patch'
  'use-xunit2-for-pytest.patch::https://patch-diff.githubusercontent.com/raw/cocodelabs/znc-palaver/pull/66.patch'
)
b2sums=('SKIP'
        'c764435ddcbe2ae6a00b4c937e030b5bb9f8c5f612d97dab6c655c4658523b66dcd8b0bf99a00dbcaffca704e61e191b2bcce43abbd79952b1f156e47bff2564'
        'c56e25f2961257f2a02e6f50d22542c484285460c51cba2b7e7ae9b115a182d79a2f1f2785f5bbc64381bf33062c0d2ffcad2569670e139f8360c769470fe136')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"


  # fix failing tests
  patch -p1 -i ../fix-deprecated-loop-argument.patch
  patch -p1 -i ../use-xunit2-for-pytest.patch
}

build() {
  cd "$pkgname"

  make
}

check() {
  cd "$pkgname"

  make test-integration
}

package() {
  cd "$pkgname"

  install -vDm755 -t "$pkgdir/usr/lib/znc" palaver.so

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}