# 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-plasma
pkgname=plasma-desktop
pkgver=6.1.4
pkgrel=0
pkgdesc="KDE Plasma Desktop"
# armhf blocked by qt6-qtdeclarative
# ppc64le, s390x, riscv64 and loongarch64 blocked by qt6-qtwebengine -> kaccounts-integration
arch="all !armhf !ppc64le !s390x !loongarch64"
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/stable/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() {
	# kcm-keyboard-keyboard_memory_persister_test is broken
	dbus-run-session -- xvfb-run ctest --test-dir build --output-on-failure -E "(foldermodel|positioner|kcm-keyboard-keyboard_memory_persister_)test"
}

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="
59e24d0443aac91e09aef7b255f8c5540d32e0cca372fc2a8d399800eaa461a257f0bf2584560680015d2e5b4344faab4b46524f65031ae7e6ff541a65214b42  plasma-desktop-6.1.4.tar.xz
affbeec6d236bf09ae95b7bf478015ead9b5eabcffa8291107e34463bc3f7563c01d4e444e035b7eb575700e64c4da9f5079950b254b8c24b305845f031eb17f  sddm.conf
"
