#!/bin/bash
#
# Copyright 2005, 2006 Scott Harmon
# Available under the terms of the GNU GPL.
#

NAME="gdm"
VERSION="3.6.1"
REVISION="1"

PKG_SOURCEURL='ftp://ftp.gnome.org/mirror/gnome.org/sources/${NAME}/${VER_MAJ}.${VER_MIN}/${NAME}-${VERSION}.tar.xz'
PKG_SANIFYNOTOUCH="yes"

PKG_PATCH[0]="xinitrc.gnome"
PKG_PATCH[1]='blackbox.desktop'
PKG_PATCH[2]='fluxbox.desktop'
PKG_PATCH[3]='fvwm2.desktop'
PKG_PATCH[4]='kde.desktop'
PKG_PATCH[5]='twm.desktop'
PKG_PATCH[6]='windowmaker.desktop'
PKG_PATCH[7]='gdmsetup-pam'
PKG_PATCH[8]='gdmsetup-security'

. $DLG_ROOT/etc/config
. $DLG_ROOT/lib/dl-base

cflags
prepare
analyzesource

# Because of configure: WARNING: unregcognized options: --disable-schemas-install
PKG_GCONFTWO=""

configure --enable-authentication-scheme=pam \
	--with-log-dir=/var/log/gdm
make
makeinstall install-strip

configfile $PKG_SYSCONFDIR/gdm/custom.conf
createroleaccount gdm 42 42

# Install the xinitrc.gnome file that starts GNOME *correctly*
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/xinit
findpatch filename ${PKG_PATCH[0]}
spewdo "install -m 755 $filename $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/xinit/"
spewdo "cd $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/xinit/ && ln -sf xinitrc.gnome xinitrc"

# Copy all those little .desktop files (for the things Slackware ships only)
spewdo "createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/sessions"
for (( idx=1; idx <= 6; idx++ )); do
	findpatch filename ${PKG_PATCH[idx]}
	spewdo "install -m 755 $filename $PKG_STAGEROOT$PKG_DATADIR/xsessions"
done

# Add the files that consolekit and userhelper require to make gdmsetup
# work with a non-root user
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/pam.d
findpatch filename ${PKG_PATCH[7]}
spewdo "install -m 644 $filename $PKG_STAGEROOT$PKG_SYSCONFDIR/pam.d/gdmsetup"
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/security/console.apps
findpatch filename ${PKG_PATCH[8]}
spewdo "install -m 644 $filename $PKG_STAGEROOT$PKG_SYSCONFDIR/security/console.apps/gdmsetup"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
