# 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.3.5
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
	libwacom-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-qtdeclarative-private-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
	xwayland-run
	"

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

case "$pkgver" in
	*.*.9*) _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
	org.kde.timezone.rules
	"

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 wlheadless-run -- ctest --test-dir build -E "$tests"
}

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

	install -Dm644 "$srcdir"/org.kde.timezone.rules "$pkgdir"/usr/share/polkit-1/rules.d/org.kde.timezone.rules
}

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="
d4eaad8211325042f22769dcb42b17aa2175e7faf16499ddfb0d015164afb610ef02d1b2dd9e645003206fabc0c60c2e930223cdd94578774f8850ebb061f439  plasma-desktop-6.3.5.tar.xz
affbeec6d236bf09ae95b7bf478015ead9b5eabcffa8291107e34463bc3f7563c01d4e444e035b7eb575700e64c4da9f5079950b254b8c24b305845f031eb17f  sddm.conf
1bada9221c309583111c7bcdbc841b771e682957023eefd8b921a9848e19aee27071316aac9cbb712a26ec657c0b024e459e09001efe654d9e72a6d99fe9ee76  org.kde.timezone.rules
"
