maintainer="Michał Polański <michal@polanski.me>"
pkgname=borgmatic
pkgver=2.0.5
pkgrel=0
pkgdesc="Simple, configuration-driven backup software for servers and workstations"
url="https://torsion.org/borgmatic/"
license="GPL-3.0-or-later"
arch="noarch"
depends="
	borgbackup
	py3-colorama
	py3-jsonschema
	py3-packaging
	py3-requests
	py3-ruamel.yaml
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	apprise
	py3-flexmock
	py3-pytest
	py3-pytest-cov
	"
subpackages="$pkgname-bash-completion $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://projects.torsion.org/borgmatic-collective/borgmatic/archive/$pkgver.tar.gz"
builddir="$srcdir/borgmatic"

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

	python3 -m venv --clear --without-pip --system-site-packages .venv
	.venv/bin/python3 -m installer \
		.dist/borgmatic-$pkgver-py3-none-any.whl
	.venv/bin/borgmatic --bash-completion >$pkgname.bash
}

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

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/borgmatic-$pkgver-py3-none-any.whl

	install -Dm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
}

sha512sums="
87fc2a42d3663fefeef22b4fb3aed4e7ddd88ad47fdd991857b35a84476934e70015762377d427f8174c4345e5ed04dc6b77514c2a2d2e5d7d13f053a861251e  borgmatic-2.0.5.tar.gz
"
