# Maintainer: Lex Black <autumn-wind at web dot de>
# Contributor: patlefort <northon_patrick3 at yahoo dot ca>
# Contributor: Daniel Larsson <znixen@live.se>

pkgname=patool
pkgver=4.0.5
pkgrel=1
pkgdesc="portable command line archive file manager"
arch=('any')
url="https://wummel.github.io/${pkgname}"
license=('GPL-3.0-or-later')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools' 'python-setuptools-reproducible' 'python-argcomplete')
optdepends=(
	"lz4: extracting LZ4 archives"
	"p7zip: extracting ZIP and 7z files"
	"unarchiver: extracting various formats"
	"unrar: extracting RAR files"
	"zstd: extracting ZSTANDARD files"
)
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/wummel/${pkgname}/archive/${pkgver}.tar.gz")
sha256sums=('57d83a60a5dc6e4c2a2ede045a394e82e8162117505359a681b7fdebed4f816f')

build() {
	cd "${pkgname}-${pkgver}/"
	python -m build --wheel --no-isolation
}

package() {
	cd "${pkgname}-${pkgver}/"
	python -m installer --destdir="${pkgdir}" dist/*.whl

	install -dm755 "${pkgdir}/usr/share/bash-completion/completions/"
	register-python-argcomplete patool >"${pkgdir}/usr/share/bash-completion/completions/patool"

	install -Dm644 'doc/patool.1' -t "${pkgdir}/usr/share/man/man1/"
	install -Dm644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}/"
	install -d "${pkgdir}/usr/share/doc/${pkgname}/"
	cp -r doc/* "${pkgdir}/usr/share/doc/${pkgname}/"
}
