# Template file for 'lightdm'
pkgname=lightdm
version=1.4.1
revision=1
build_style=gnu-configure
configure_args="--with-greeter-session=lightdm-gtk-greeter
 --with-greeter-user=lightdm --disable-static --disable-tests"
short_desc="Light Display Manager"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-3, LGPL-3"
homepage="https://launchpad.net/lightdm"
distfiles="https://launchpad.net/lightdm/1.4/$version/+download/$pkgname-$version.tar.gz"
checksum=f9ca1c03c3330b6265d03048f1ebafda596c436f279b5382bda656ab3a619439
long_desc="
 An X display manager that:
  * Has a lightweight codebase
  * Is standards compliant (PAM, ConsoleKit, etc)
  * Has a well defined interface between the server and user interface
  * Fully themeable (easiest with the webkit interface)
  * Cross-desktop (greeters can be written in any toolkit)"

makedepends="pkg-config intltool dbus-glib-devel libxklavier-devel libxml2-devel
 qt-devel gtk+3-devel libxcb-devel libXdmcp-devel pam-devel vala-devel
 gobject-introspection itstool gnome-icon-theme dbus"

post_install() {
	# Remove provided init file and use our own.
	rm -rf ${DESTDIR}/etc/init
	vinstall ${FILESDIR}/lightdm.service 644 usr/lib/systemd/system
	vinstall ${FILESDIR}/lightdm.pam 644 etc/pam.d lightdm
	vinstall ${FILESDIR}/lightdm-autologin.pam 644 etc/pam.d lightdm-autologin
	vinstall ${FILESDIR}/xsession 755 etc/lightdm

	vinstall ${FILESDIR}/lightdm.rules 644 usr/share/polkit-1/rules.d

	# Minimum UID shall be 1000 for ordinary users.
	sed -i -e "s|^\(minimum-uid=\).*|\11000|" \
		${DESTDIR}/etc/lightdm/users.conf
	# Fix path to nologin.
	sed -i -e "s|/usr/sbin/nologin|/sbin/nologin|g" \
		${DESTDIR}/etc/lightdm/users.conf
	# Provide a working session wrapper.
	sed -i -e "s|#session-wrapper=lightdm-session|session-wrapper=/etc/lightdm/xsession|g" \
		${DESTDIR}/etc/lightdm/lightdm.conf
	# Provide a working PAM autologin service.
	sed -i -e "s|#autologin-session=UNIMPLEMENTED|#autologin-session=UNIMPLEMENTED\n#pam-service=lightdm-autologin|g" \
		${DESTDIR}/etc/lightdm/lightdm.conf
}

liblightdm-gobject_package() {
	short_desc="${short_desc} - GObject support library"
	pkg_install() {
		vmove "usr/lib/liblightdm-gobject*.so*"
		vmove usr/lib/girepository-1.0
	}
}

liblightdm-qt_package() {
	short_desc="${short_desc} - QT support library"
	pkg_install() {
		vmove "usr/lib/liblightdm-qt*.so*"
	}
}

lightdm-devel_package() {
	depends="libglib-devel liblightdm-gobject-${version}_${revision}
		liblightdm-qt-${version}_${revision}"
	short_desc="${short_desc} - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove usr/share/gtk-doc
		vmove usr/share/vala
		vmove usr/share/gir-1.0
	}
}

lightdm_package() {
	conf_files="
		/etc/lightdm/keys.conf
		/etc/lightdm/lightdm.conf
		/etc/lightdm/users.conf
		/etc/pam.d/lightdm
		/etc/pam.d/lightdm-autologin"
	system_accounts="lightdm"
	lightdm_homedir="/var/cache/lightdm"
	systemd_services="lightdm.service off"
	make_dirs="/var/cache/lightdm 0755 lightdm lightdm"
	depends="gnome-icon-theme dbus accountsservice upower"
	pkg_install() {
		vmove etc
		vmove usr
	}
}
