# Contributor: Bart Ribbers <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-plasma
maintainer="team/kde <bribbers@disroot.org>"
pkgname=plasma-desktop
pkgver=6.2.4
pkgrel=0
pkgdesc="KDE Plasma Desktop"
# armhf blocked by qt6-qtdeclarative
# s390x blocked by plasma-workspace
arch="all !armhf !s390x"
url='https://kde.org/plasma-desktop/'
license="GPL-2.0-only AND LGPL-2.1-only"
depends="
	accountsservice
	font-noto-emoji
	ibus-emoji
	kirigami
	kirigami-addons
	plasma-workspace
	qqc2-desktop-style
	setxkbmap
	xdg-user-dirs
	"
makedepends="
	attica-dev
	baloo-dev
	eudev-dev
	extra-cmake-modules
	fontconfig-dev
	ibus-dev
	kauth-dev
	kcmutils-dev
	kcodecs-dev
	kconfig-dev
	kdbusaddons-dev
	kdeclarative-dev
	kdoctools-dev
	kglobalaccel-dev
	ki18n-dev
	kitemmodels-dev
	knewstuff-dev
	knotifications-dev
	knotifyconfig-dev
	kpeople-dev
	kpipewire-dev
	krunner-dev
	kwallet-dev
	kwin-dev
	libplasma-dev
	libxcursor-dev
	libxi-dev
	libxkbfile-dev
	plasma-activities-stats-dev
	plasma-workspace-dev
	plasma5support-dev
	qqc2-desktop-style-dev
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qtsvg-dev
	samurai
	sdl2-dev
	signon-plugin-oauth2-dev
	xf86-input-evdev-dev
	xf86-input-libinput-dev
	xf86-input-synaptics-dev
	xkeyboard-config-dev
	"
checkdepends="
	dbus
	iso-codes
	xvfb-run
	"

case "$CARCH" in
	x86|x86_64|armv7|aarch64)
		makedepends="$makedepends kaccounts-integration-dev"
		;;
esac

case "$pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
subpackages="
	$pkgname-dbg
	$pkgname-doc
	$pkgname-lang
	knetattach
	sddm-breeze:sddm_breeze
	"
_repo_url="https://invent.kde.org/plasma/plasma-desktop.git"
source="https://download.kde.org/$_rel/plasma/$pkgver/plasma-desktop-$pkgver.tar.xz
	sddm.conf
	"

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

check() {
	local tests="kcm-keyboard-keyboard_memory_persister_test"

	case "$CARCH" in
		aarch64) tests="$tests|tst_calibration" ;;
		riscv64|loongarch64|ppc64le) tests="$tests|tst_calibrationtool" ;;
	esac
	dbus-run-session -- xvfb-run -a ctest --test-dir build --output-on-failure -E "$tests"
}

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

knetattach() {
	pkgdesc="Wizard which makes it easier to integrate network resources with the Plasma Desktop"
	depends=""

	amove usr/bin/knetattach
	amove usr/share/applications/org.kde.knetattach.desktop
}

sddm_breeze() {
	pkgdesc="Breeze theme for SDDM"
	depends="
		breeze
		qt6-qtvirtualkeyboard
		"
	install_if="breeze sddm"

	amove usr/share/sddm

	install -Dm644 "$srcdir"/sddm.conf "$subpkgdir"/etc/sddm.conf
}

sha512sums="
9a766a2799bc96a803433a649884307fc40eb4e5d3c10578a3568ab433833b2a65462b5efb9275295dba5384eccb0365c52e7d98d42374c297adee9f42678f1e  plasma-desktop-6.2.4.tar.xz
affbeec6d236bf09ae95b7bf478015ead9b5eabcffa8291107e34463bc3f7563c01d4e444e035b7eb575700e64c4da9f5079950b254b8c24b305845f031eb17f  sddm.conf
"
