# Contributor: A. Wilcox <awilfox@adelielinux.org>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=kscreenlocker
pkgver=5.8.7
pkgrel=1
pkgdesc="Secure X11 screen locker"
url="https://www.kde.org/"
arch="all"
license="LGPL-2.1"
options="!check"  # requires loginctl
depends="linux-pam"
depends_dev="qt5-qtbase-dev qt5-qtdeclarative-dev kcrash-dev kdeclarative-dev
	kglobalaccel-dev ki18n-dev kidletime-dev kcmutils-dev solid-dev
	knotifications-dev ktextwidgets-dev kwindowsystem-dev kxmlgui-dev
	kwayland-dev libxi-dev libxcursor-dev"
makedepends="$depends_dev cmake extra-cmake-modules python3 gettext-dev
	libx11-dev libxext-dev libxcb-dev linux-pam-dev"
install=""
subpackages="$pkgname-dev $pkgname-lang"
source="http://download.kde.org/stable/plasma/$pkgver/kscreenlocker-$pkgver.tar.xz
	kscreenlocker-5.8.5-stop-using-getpass.patch
	kde.pam
	kde-np.pam"
builddir="$srcdir/kscreenlocker-$pkgver"

build() {
	cd "$builddir"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		${CMAKE_CROSSOPTS}
	make
}

check() {
	cd "$builddir"
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	install -D -m644 "$srcdir"/kde.pam "$pkgdir"/etc/pam.d/kde.pam
	install -m644 "$srcdir"/kde-np.pam "$pkgdir"/etc/pam.d/kde-np.pam
}

sha512sums="cee66e85efaafd5629c9e2b1eea1522cff960d7b9922be7b6d5f767c231fcb762cf80585d5528fdb5fc3684881bf2fa4a59da3136a1d23341ceb218da3f69e11  kscreenlocker-5.8.7.tar.xz
44bbf365555668f7ef2f354a06d08b4b83c556f6e78ead028acd727363c287cfecc2e3eb4d0bb137feb2939da0fa21db694af6b10f8a3878d7071ad4e3b8d4e8  kscreenlocker-5.8.5-stop-using-getpass.patch
56e87d02d75c4a8cc4ed183faed416fb4972e7f223b8759959c0f5da32e11e657907a1df279d62a44a6a174f5aca8b2ac66a5f3325c5deb92011bcf71eed74c3  kde.pam
565265485dd7466b77966d75a56766216b8bcc187c95a997e531e9481cf50ddbe576071eb0e334421202bcab19aa6de6b93e042447ca4797a24bf97e1d053ffd  kde-np.pam"