# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Contributor: Ivan Tham <pickfire@riseup.net
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=taskd
pkgver=1.1.0
pkgrel=8
pkgdesc="Taskserver synchronises taskwarrior across multiple clients"
url="https://taskwarrior.org"
arch="all"
license="MIT"
depends="bash"
makedepends="gnutls-dev util-linux-dev cmake samurai"
pkgusers="taskd"
pkggroups="taskd"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-pki::noarch $pkgname-openrc"
source="https://github.com/GothenburgBitFactory/taskserver/releases/download/v$pkgver/taskd-$pkgver.tar.gz
	Path.cpp.patch
	Directory.cpp.patch
	taskd.initd
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -dm700 -o taskd -g taskd "$pkgdir"/var/lib/$pkgname
	install -Dm755 "$srcdir"/taskd.initd "$pkgdir"/etc/init.d/$pkgname

	mkdir -p "$pkgdir"/usr/share/taskd
	cp -a pki "$pkgdir"/usr/share/taskd
}

pki() {
	pkgdesc="Tools for taskd PKI management"
	depends="taskd=$pkgver-r$pkgrel gnutls-utils"

	amove usr/share/taskd/pki
}

sha512sums="
df2349c354258fd1b014b1a9c78f68dc10c9e5a48357e282e8a760cf4e4aaf4d36486796ad094ee2b050e7506195b778e3316c90ef543a2f8242de313daa13aa  taskd-1.1.0.tar.gz
51f9a384c3c76c2719f8dbc378fad0717b02e508dcf3d08fcabf2ebed002501bb7760723d49ee210f15ac65b077c35ea765c22ea8793ead04141bc6f6b2c8b3a  Path.cpp.patch
fa3c8bec063119e7a8321a1be26e3c16ae1d1cbb34aa06becc29830f1e78180514a68981d9fd4c34b63755ab9afa2c5a295efeeea6dbce263bdf9c010d7c28aa  Directory.cpp.patch
c120566bd8e33de3980a554d62f6156f0650656985d108e2c577508b5f94f1040e4b70dc52f82210f1a5aeb9492a61c54a8d6c063ed6a999a3de4562426c36c1  taskd.initd
"
