# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lsyncd
pkgver=2.2.3
pkgrel=0
_luaver=5.3
pkgdesc="Live Syncing (Mirror) Daemon"
url="https://github.com/axkibe/lsyncd"
arch="all"
license="GPL-2.0-or-later"
depends="rsync"
makedepends="$depends_dev cmake lua$_luaver lua$_luaver-dev"
options="!check" # needs passwordless ssh access to localhost
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/axkibe/lsyncd/archive/release-$pkgver.tar.gz
	fix-realpath.patch
	fix-mandir.patch
	$pkgname.initd"
builddir="$srcdir"/lsyncd-release-$pkgver

build() {
	cd "$builddir"
	cmake -DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DLUA_COMPILER=/usr/bin/luac$_luaver \
		-DLUA_EXECUTABLE=/usr/bin/lua$_luaver \
		-DLUA_INCLUDE_DIR=/usr/include/lua$_luaver \
		-DLUA_LIBRARY=/usr/lib/lua$_luaver/liblua.so
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir/etc/lsyncd"
	cp "$builddir"/examples/*.lua \
		"$pkgdir"/etc/lsyncd/
	install -Dm755 "$srcdir/$pkgname.initd" \
		"$pkgdir/etc/init.d/$pkgname"

}

sha512sums="2193a342f8aa7d8cfb55378c9c59ca61d2d8e4026263fd6e6560c730c712cef1f189305a3f9bca58f5b9c9ffae5af12e1d75e5355d5bdae86a47ad9595b8169a  lsyncd-2.2.3.tar.gz
2cebaf59d960321c2eda4ef1e0d850f62eb7eedb7ba8922a5db33a7f78c769d1a52839fbb597ae06ba576632e2abc7b92a6ba2eaf58b71b93bc877db83e25576  fix-realpath.patch
6283f973768467942a69cb4fd835cfef81ffd1d9acccdea21b1f40730f67d5ff0e8db33772f28be2a6abb352c9596a01dbf215aa228072f7439b69ad8c691c61  fix-mandir.patch
441b76ec944d9d74100dfca55efe871e9092b37cd49ec79a2a94e281dc0326b4def1645a827f7d3edcddc95d6e74c99621b62991396fb3693b1832c42fd86cdc  lsyncd.initd"
