# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=raft-cowsql
pkgver=0.22.1
pkgrel=0
pkgdesc="Asynchronous C implementation of the Raft consensus protocol"
url="https://github.com/cowsql/raft"
arch="all"
license="LGPL-3.0-only WITH LGPL-3.0-linking-exception"
makedepends="linux-headers libuv-dev autoconf automake libtool"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/cowsql/raft/archive/refs/tags/v$pkgver.tar.gz
	unistd-include.patch
	disable-bind-address-test-segfaulting.patch
	fix-uv-tests.patch
	"
builddir="$srcdir/raft-$pkgver"

prepare() {
	default_prepare
	autoreconf -i
}

build() {
	./configure \
		--prefix=/usr \
		--without-lz4 \
		--enable-example=no
	make
}

check() {
	make check || {
		cat ./test-suite.log
		return 1
	}
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums="
fb4ea98321336daaa605e1c3cd55f672860fc8894d479fdff4e1862a4eb5622dbaf7a943e030dd2bcdaa14cc639e7e11ac43d71f00bdbd27f12c6b67653b70e4  raft-cowsql-0.22.1.tar.gz
1e0e82e42fb9a65e6135e47ef17494e40f973c9a1af8aab09ff10fdbee83b55183414ec6938205806a9f954bbefaaa5eee776bbd313072ac7ce0105f18a2be03  unistd-include.patch
b5c6e5a1ae1b6a06005cdbd3d3379e1d0bc6136307578089971f8ac48601958e9d1d31410d26da4cc91206813a56f01ee59fca64cd68e9a37a9921a339b6bf05  disable-bind-address-test-segfaulting.patch
a1411c8b0e47d8e593dae9d7380e56373399623476d98d5221a59674d380d790cca52bd57713010f600e614319d9f9a43743b3b941bf9d317a40b821676d41f2  fix-uv-tests.patch
"
