#!/usr/bin/make -f

GDM_VERSION = $(shell dpkg-query --showformat='$${Version}' --show gdm)
NEW_GDM = $(shell dpkg --compare-versions $(GDM_VERSION) ge '2.25.2~' && echo y)
EVENT_D = $(shell test -f /etc/event.d/tty1 && echo y)

DEB_DIVERT_EXTENSION = .debathena
ifneq ($(wildcard /etc/gdm/gdm.conf-custom.debathena),)
    GDM_CONFFILE = /etc/gdm/gdm.conf-custom.debathena.debathena
else
    GDM_CONFFILE = /etc/gdm/gdm.conf.debathena.debathena
endif
DEB_UNDIVERT_FILES_debathena-cluster-login-config += \
	/etc/default/kexec.debathena
DEB_UNDIVERT_VERSION_/etc/default/kexec.debathena = 1.23~

ifneq ($(NEW_GDM),y)
    DEB_TRANSFORM_FILES_debathena-cluster-login-config += \
	${GDM_CONFFILE}
else
    DEB_REMOVE_FILES_debathena-cluster-login-config += \
	/usr/share/xsessions/gnome-failsafe.desktop \
	/usr/share/xsessions/xterm.desktop
endif

DEB_REMOVE_FILES_debathena-cluster-login-config += \
    /usr/lib/indicator-session/indicator-users-service

DEB_DIVERT_FILES_debathena-cluster-login-config += \
	/sbin/getty.debathena

ifeq ($(EVENT_D),y)
    DEB_UNREMOVE_FILES_debathena-cluster-login-config += \
	/etc/event.d/tty1 \
	/etc/event.d/tty2 \
	/etc/event.d/tty3 \
	/etc/event.d/tty4 \
	/etc/event.d/tty5 \
	/etc/event.d/tty6
    DEB_UNREMOVE_VERSION_/etc/event.d/tty1 = 1.24~
    DEB_UNREMOVE_VERSION_/etc/event.d/tty2 = 1.24~
    DEB_UNREMOVE_VERSION_/etc/event.d/tty3 = 1.24~
    DEB_UNREMOVE_VERSION_/etc/event.d/tty4 = 1.24~
    DEB_UNREMOVE_VERSION_/etc/event.d/tty5 = 1.24~
    DEB_UNREMOVE_VERSION_/etc/event.d/tty6 = 1.24~
else
    DEB_UNREMOVE_FILES_debathena-cluster-login-config += \
	/etc/init/tty1.conf \
	/etc/init/tty2.conf \
	/etc/init/tty3.conf \
	/etc/init/tty4.conf \
	/etc/init/tty5.conf \
	/etc/init/tty6.conf
    DEB_UNREMOVE_VERSION_/etc/init/tty1.conf = 1.24~
    DEB_UNREMOVE_VERSION_/etc/init/tty2.conf = 1.24~
    DEB_UNREMOVE_VERSION_/etc/init/tty3.conf = 1.24~
    DEB_UNREMOVE_VERSION_/etc/init/tty4.conf = 1.24~
    DEB_UNREMOVE_VERSION_/etc/init/tty5.conf = 1.24~
    DEB_UNREMOVE_VERSION_/etc/init/tty6.conf = 1.24~
endif

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/config-package.mk
