# Maintainer: Justin Kromlinger <hashworks@archlinux.org>

pkgname=python-geoipsets
pkgver=2.4
pkgrel=2
pkgdesc='Tool to generate country-specific IP ranges for iptables/ipset and nftables'
arch=('any')
license=('GPL3')
url='https://github.com/chr0mag/geoipsets/tree/main/python'
depends=(
  'python-requests'
  'python-beautifulsoup4'
)
makedepends=(
  'python-setuptools'
)
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/chr0mag/geoipsets/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('3bb7f6714254d2ba8cc2f4c69b6407b65e23afa3c8f8016179cdd16020d3adeac32414b5ae7f0c5b4026f23608d9beb79adb9467aa019787ffec3386f4d35fc8')

build() {
  cd "geoipsets-$pkgver/python"

  python setup.py build
}

check() {
  cd "geoipsets-$pkgver/python"

  python -m pytest
}

package() {
  cd "geoipsets-$pkgver/python"

  python setup.py install --root="$pkgdir" --optimize=1

  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README_python.md"
  install -Dm644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 ../README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  install -Dm644 ../systemd/update-geoipsets.service "${pkgdir}/usr/lib/systemd/system/update-geoipsets.service"
  install -Dm644 ../systemd/update-geoipsets.timer "${pkgdir}/usr/lib/systemd/system/update-geoipsets.timer"
}
