# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py-dnslib
_pkgname=dnslib
pkgver=0.9.6
pkgrel=1
pkgdesc="A simple library to encode/decode DNS wire-format packets"
url="https://bitbucket.org/paulc/dnslib/"
arch="noarch"
license="BSD"
makedepends="python2-dev python3-dev py-setuptools"
subpackages="py2-${pkgname#py-}:_py2 py3-${pkgname#py-}:_py3"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

build() {
	cd "$builddir"
	python2 setup.py build || return 1
	python3 setup.py build || return 1
}

package() {
	mkdir -p "$pkgdir"
}

_py2() {
	replaces="$pkgname"
	_py python2
}

_py3() {
	_py python3
}

_py() {
	local python="$1"
	pkgdesc="$pkgdesc (for $python)"
	depends="$depends $python"
	install_if="$pkgname=$pkgver-r$pkgrel $python"

	cd "$builddir"
	$python setup.py install --prefix=/usr --root="$subpkgdir"
}

md5sums="794028e9b92b8fad9712ac6655b7fb1d  dnslib-0.9.6.tar.gz"
sha256sums="6ba31ae2014644901a301727cc4e22844eb19295a959c362568f08aee9b3bfa8  dnslib-0.9.6.tar.gz"
sha512sums="c733803a9b25356c82afb4ce853a681545aebdb5fbd4f8a544eea9bb61ff354acc044a43357435e02b8b787a17fec99ea7e9f01b1c1e93a2e39945657c495105  dnslib-0.9.6.tar.gz"
