# Template file for 'lightdm'
pkgname=lightdm
version=1.32.0
revision=7
build_style=gnu-configure
build_helper="gir"
configure_args="--sbindir=/usr/bin --with-greeter-session=lightdm-gtk-greeter
 --with-greeter-user=lightdm --disable-static --disable-tests
 $(vopt_enable gir introspection)"
hostmakedepends="pkg-config intltool itstool $(vopt_if gir 'gobject-introspection vala')
 qt5-host-tools"
makedepends="dbus-glib-devel libxklavier-devel libxml2-devel
 gtk+3-devel libxcb-devel libXdmcp-devel pam-devel vala-devel
 libgcrypt-devel accountsservice-devel qt5-devel"
depends="dbus accountsservice virtual?lightdm-greeter"
short_desc="Light Display Manager"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-3.0-or-later, LGPL-2.0-or-later"
homepage="https://github.com/CanonicalLtd/lightdm"
changelog="https://raw.githubusercontent.com/CanonicalLtd/lightdm/master/NEWS"
distfiles="https://github.com/CanonicalLtd/lightdm/releases/download/${version}/lightdm-${version}.tar.xz"
checksum=12f5ab432748f0387c7cf8b94430495a558a035a4f8465e5181af6faff133e4b
conf_files="/etc/${pkgname}/*.conf /etc/pam.d/*"
system_accounts="lightdm"
lightdm_homedir="/var/lib/lightdm"
make_dirs="
	/var/lib/lightdm 0755 lightdm lightdm
	/var/lib/lightdm-data 0755 lightdm lightdm"

build_options="gir"
build_options_default="gir"

post_install() {
	# Remove provided init file and use our own.
	rm -rf ${DESTDIR}/etc/init
	vsv lightdm
	vinstall ${FILESDIR}/lightdm.rules 644 usr/share/polkit-1/rules.d
	vinstall ${FILESDIR}/xsession 755 etc/lightdm Xsession
	# make pam_systemd optional
	for f in ${DESTDIR}/etc/pam.d/*; do
		sed 's|\(.*pam_systemd.*\)|-\1|' -i $f
		echo "-session optional pam_ck_connector.so nox11" >> $f
	done
	sed 's|\#session-wrapper=.*|session-wrapper=/etc/lightdm/Xsession|' -i ${DESTDIR}/etc/lightdm/lightdm.conf
	sed "s|pam_systemd\.so|pam_elogind.so|" -i ${DESTDIR}/etc/pam.d/*
}

liblightdm-gobject_package() {
	short_desc+=" - GObject support library"
	pkg_install() {
		vmove "usr/lib/liblightdm-gobject*.so.*"
		if [ "$build_option_gir" ]; then
			vmove usr/lib/girepository-1.0
		fi
	}
}

liblightdm-qt5_package() {
	short_desc+=" - QT 5.x support library"
	pkg_install() {
		vmove "usr/lib/liblightdm-qt5*.so.*"
	}
}

lightdm-devel_package() {
	depends="libglib-devel liblightdm-gobject-${version}_${revision}
	 libxklavier-devel libX11-devel liblightdm-qt5-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/share/gtk-doc
		vmove "usr/lib/*.so"
		if [ "$build_option_gir" ]; then
			vmove usr/share/vala
			vmove usr/share/gir-1.0
		fi
	}
}
