# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
# Contributor: 7heo <7heo@mail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=dvtm
pkgver=0.15_git20210309
_gitrev=7bcf43f8dbd5c4a67ec573a1248114caa75fa3c2
pkgrel=2
pkgdesc="Dynamic virtual terminal manager"
arch="all"
url="https://www.brain-dump.org/projects/dvtm/"
license="MIT"
depends="ncurses-terminfo"
makedepends="ncurses-dev ncurses" # we need ncurses for 'tic'
checkdepends="vis"
subpackages="$pkgname-doc $pkgname-copymode"
source="$pkgname-$pkgver.tar.gz::https://github.com/martanne/dvtm/archive/$_gitrev/dvtm-$_gitrev.tar.gz
	dvtm-editor-default-to-vis.patch
	"
builddir="$srcdir/dvtm-$_gitrev"

build() {
	make
}

check() {
	./testsuite.sh
}

package() {
	make PREFIX=/usr DESTDIR="$pkgdir" install
	install -Dvm644 README.md LICENSE \
		-t "$pkgdir"/usr/share/doc/$pkgname

	# Already provided by ncurses-terminfo
	rm -rf "$pkgdir"/usr/share/terminfo/
}

# copymode requires a supported editor and pager, it doesn't seem
# to work with busybox vi and less. another compatible pager is w3m.
copymode() {
	pkgdesc="$pkgdesc (copymode support)"
	depends=
	install_if="$pkgname=$pkgver-r$pkgrel vis less"
	amove usr/bin/dvtm-editor
	amove usr/bin/dvtm-pager
}

sha512sums="
56b768ef96f4952fbeb10adaf55afb795293c0b60a67f361cdd2759d9fe0c231afd2fb4c6c6d002a77841cddabf7c27bb557999498fe261f888dc94c02c8f1fd  dvtm-0.15_git20210309.tar.gz
322893d180c24b7369acaaff091ff9e0e72d647dce31e9775ed8f7d34f10f630db44ca2a3cd1a426a36d97b688608656b98d8f0076635385543bf63892695ab5  dvtm-editor-default-to-vis.patch
"
