# Maintainer: Szilárd Pfeiffer <coroner@pfeifferszilard.hu>

_base=cryptoparser
pkgname=python-${_base}
pkgver=1.6.1
# shellcheck disable=SC2034
pkgrel=1
# shellcheck disable=SC2034
pkgdesc="Multi-protocol cryptographic message parser and generator"
# shellcheck disable=SC2034
arch=(any)
url="https://gitlab.com/coroner/${_base}"
# shellcheck disable=SC2034
license=(MPL-2.0)
# shellcheck disable=SC2034
depends=(python
         python-asn1crypto
         python-attrs
         "python-cryptodatahub>=1.6.1"
         python-urllib3)
# shellcheck disable=SC2034
makedepends=(python-build python-installer python-setuptools python-setuptools-scm python-wheel)
# shellcheck disable=SC2034
checkdepends=(python-pyfakefs)

_builddir=${_base}-v${pkgver}

# shellcheck disable=SC2034
source=("${pkgname}-${pkgver}.tar.gz::${url}/-/archive/v${pkgver}/${_builddir}.tar.gz")
# shellcheck disable=SC2034
sha256sums=(SKIP)

build() {
  cd ${_builddir} || exit
  python -m build --wheel --no-isolation
}

check() {
  cd ${_builddir} || exit
  python -m unittest discover
}

package() {
  cd ${_builddir} || exit
  # shellcheck disable=SC2154
  python -m installer --destdir="${pkgdir}" dist/*.whl
  install -Dm644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
  install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
}
