# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Max Rees <maxcrees@me.com>
pkgname=nextcloud-client
pkgver=2.5.2
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="1000b420355d7a4104ca5b41e813d467dcb345b60c79c78ce532de9c58ea89cad10d5565a433409bd512f0f7771c18c7c27974b968c74f84ccfda1ed3510d3ae  nextcloud-client-2.5.2.tar.gz
17e6a8437d33a2bb1305e45405aee4e23f233e00c232669a1f8317355032d88329899d3f7b65d1069cf1612029b589a575b0f64018b9b23d239a73c5f4bed2ce  no-webengine.patch
e323a1074f8ac96667a420f076fdfc988e2fd97cdacd05d83ac54b467b567f5adbf635e7c4fb0414af0012b4016cc4c13441cb35ed3976bc970e514e81b65fd4  openssl.patch"