# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=csync2
pkgver=2.0
pkgrel=5
pkgdesc="Cluster synchronization tool"
url="https://github.com/LINBIT/csync2"
arch="all"
license="GPL-2.0-or-later"
options="!check"  # tests needs to modify system's network config
makedepends="autoconf automake bison flex gnutls-dev librsync-dev sqlite-dev"
depends="bash"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/LINBIT/$pkgname/archive/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	fix-build-ppc64le.patch
	CVE-2019-15522.patch
	CVE-2019-15523.patch"
builddir="$srcdir/$pkgname-$pkgname-$pkgver"

# secfixes:
#   2.0-r3:
#     - CVE-2019-15522
#     - CVE-2019-15523

prepare() {
	default_prepare

	sh ./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/csync2 \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

package() {
	make DESTDIR="$pkgdir" -j1 install
	install -m 755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
7555e2d958d6213e29cfa8b3b7415eea9a9868036865c519d724ae404006d913fba4aeeb61a916d3fc95669a6ca12160d4f52dc7d15bd59403e8a7de50ee8094  csync2-2.0.tar.gz
e2df7f2993781709dadd0ce24bc31e16259382c8b3c432c47c3790f78b37124d38fb5036e87a06747538d864fdf68b8984bf2d4bce09158cddd58c10f4411d9f  csync2.initd
4566ba1139615e5011c881e670d8976d3b5226e27521fd6ced126a5a3687683c145931fa89a9b6b0ab967f982bf778c33148e6c9f7ee29ef5154593ae02efb2a  fix-build-ppc64le.patch
f36e46630e39bfae536884bfa0c4f585b3b93e4b7fd9d1c134f5b777ff10609378a47bbd4db96b6eed9c985fab8482781db5d3a0481e7e2f7e086a74f34a204b  CVE-2019-15522.patch
a2b26fcb8f76451b898b2e6858ca5b6b93a16d54d188f75eac18d84b4f226fb0e4ade77c1c338f012a4e573e3bbd4ec88f0dd1dde78504237dca5d7806774288  CVE-2019-15523.patch
"
