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

_base=cryptodatahub
pkgname=python-${_base}
pkgver=1.6.1
# shellcheck disable=SC2034
pkgrel=1
# shellcheck disable=SC2034
pkgdesc="Multi-protocol cryptographic data repository"
# 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-dateutil
         python-urllib3)
# shellcheck disable=SC2034
optdepends=("python-beautifulsoup4: update-ct-log, update-oqs and update-trust-stores"
            "python-yaml: update-oqs")
# shellcheck disable=SC2034
makedepends=(python-build python-installer python-setuptools python-setuptools-scm python-wheel)
# shellcheck disable=SC2034
checkdepends=(python-beautifulsoup4 python-pyfakefs python-yaml)

_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
  CRYPTODATAHUB_TEST_SKIP_LIVE_SERVER=1 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"
}
