# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=dnstwist
pkgver=20240812
pkgrel=0
pkgdesc="Domain name permutation engine"
url="https://dnstwist.it"
arch="noarch"
license="Apache-2.0"
depends="
	py3-dnspython
	py3-geoip2
	py3-idna
	py3-requests
	py3-tld
	py3-whois
	python3
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
subpackages="$pkgname-dictionaries $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/elceef/dnstwist/archive/$pkgver.tar.gz"
options="!check" # no testsuite

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

dictionaries() {
	pkgdesc="Dictionaries for dnstwist"
	depends=""

	mkdir -p "$subpkgdir"/usr/share/dnstwist/dictionaries
	for dict in "$builddir"/dictionaries/*.dict; do
		install -Dm0644 "$dict" "$subpkgdir"/usr/share/dnstwist/dictionaries/"$(basename $dict)"
	done
}

sha512sums="
5f8dbe146e6d6ee213f289987a5991d4071ac4528aa0c25152ff5011bc17d2b59f2dad1e764c06cb11f38fc4cbe3954c881e19d3fac9546444c10b15b5c60a98  dnstwist-20240812.tar.gz
"
