# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=kmail
pkgver=24.08.1
pkgrel=0
# armhf blocked by extra-cmake-modules
# ppc64le, s390x, riscv64 and armv7 blocked by qt6-qtwebengine
# loongarch64 blocked by pimcommon
arch="all !armhf !ppc64le !s390x !riscv64 !armv7 !loongarch64"
url="https://kontact.kde.org/components/kmail/"
pkgdesc="Email client, supporting POP3 and IMAP mailboxes"
license="GPL-2.0-or-later"
# TODO: Replace gnupg with specific gnupg subpackages that kmail really needs.
depends="
	gnupg
	kdepim-runtime
	kmail-account-wizard
	"
makedepends="
	akonadi-contacts-dev
	akonadi-dev
	akonadi-mime-dev
	akonadi-search-dev
	extra-cmake-modules
	gpgme-dev
	kbookmarks-dev
	kcalendarcore-dev
	kcalutils-dev
	kcmutils-dev
	kcodecs-dev
	kconfig-dev
	kconfigwidgets-dev
	kcontacts-dev
	kcrash-dev
	kdbusaddons-dev
	kdoctools-dev
	kguiaddons-dev
	ki18n-dev
	kiconthemes-dev
	kidentitymanagement-dev
	kio-dev
	kitemviews-dev
	kjobwidgets-dev
	kldap-dev
	kmailtransport
	kmime-dev
	knotifications-dev
	knotifyconfig-dev
	kontactinterface-dev
	kparts-dev
	kpimtextedit-dev
	kservice-dev
	kstatusnotifieritem-dev
	ktextwidgets-dev
	ktnef-dev
	kuserfeedback-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	libgravatar-dev
	libkdepim-dev
	libkleo-dev
	libksieve-dev
	mailcommon-dev
	messagelib-dev
	pimcommon-dev
	qt6-qtbase-dev
	qt6-qtwebengine-dev
	samurai
	sonnet-dev
	"
checkdepends="xvfb-run"
subpackages="$pkgname-doc $pkgname-lang"
_repo_url="https://invent.kde.org/pim/kmail.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/kmail-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	# akonadi-sqlite-tagselectdialogtest, akonadi-sqlite-kmcommandstest,
	# akonadi-sqlite-unifiedmailboxmanagertest and akonadi-mysql-unifiedmailboxmanagertestrequire
	# running dbus server
	local skipped_tests="("
	local tests="
		akonadi-sqlite-tagselectdialogtest
		akonadi-sqlite-kmcommandstest
		akonadi-sqlite-unifiedmailboxmanagertest
		akonadi-mysql-unifiedmailboxmanagertest"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)"
	xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
50ec9d700f524a8cc47d851da5949dde95f2346b26d2f3244bab7d90c8af39049e1e8399f46b04ae964b5eb00994e2d3bdb87fd606bf39d7771d66901356e34e  kmail-24.08.1.tar.xz
"
