# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Max Rees <maxcrees@me.com>
pkgname=nextcloud-client
pkgver=2.5.3
pkgrel=0
pkgdesc="Nextcloud desktop client"
url="https://github.com/nextcloud/desktop"
arch="all"
license="GPL-2.0+ AND LGPL-2.1+ AND Public-Domain AND MIT AND (Custom:Digia-Qt OR LGPL-2.1-only WITH Qt-LGPL-exception-1.1) AND (Custom:Digia-Qt OR LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR GPL-3.0-only)"
depends=""
makedepends="cmake qt5-qttools-dev qtkeychain-dev zlib-dev
	openssl-dev sqlite-dev qt5-qtsvg-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/nextcloud/desktop/archive/v$pkgver.tar.gz
	no-webengine.patch
	openssl.patch"
builddir="$srcdir/desktop-$pkgver"

build() {
	cmake \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_SYSCONFDIR="/etc/$pkgname" \
		-DNO_SHIBBOLETH=1 \
		-DWITH_CRASHREPORTER=bool:OFF \
		-DUNIT_TESTING=bool:ON \
		-DNO_SHIBBOLETH=bool:ON
	make
}

check() {
	# ChunkingTestNg fails sporadically when run with the other tests based
	# on a timeout, but runs fine on its own
	make test || make test ARGS="--rerun-failed --output-on-failure"
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="998e38278472e87e9606fad407ba7b1295594a777845c6fa7413ffb485b3a3b7a26ad8212a1161e1d695d9ecfa066e9090aa633b4ec4af84700c28bc1321b710  nextcloud-client-2.5.3.tar.gz
17e6a8437d33a2bb1305e45405aee4e23f233e00c232669a1f8317355032d88329899d3f7b65d1069cf1612029b589a575b0f64018b9b23d239a73c5f4bed2ce  no-webengine.patch
e323a1074f8ac96667a420f076fdfc988e2fd97cdacd05d83ac54b467b567f5adbf635e7c4fb0414af0012b4016cc4c13441cb35ed3976bc970e514e81b65fd4  openssl.patch"