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

NAME="gdm"
VERSION="2.28.2"
REVISION="1"

PKG_SOURCEURL='http://ftp.gnome.org/pub/GNOME/sources/$NAME/$VER_MAJ.$VER_MIN/$NAME-$VERSION.tar.bz2'

PKG_PATCH[0]="xinitrc.gnome"

PKG_PATCH[1]='blackbox.desktop'
PKG_PATCH[2]='enlightenment.desktop'
PKG_PATCH[3]='fluxbox.desktop'
PKG_PATCH[4]='fvwm2.desktop'
PKG_PATCH[5]='kde.desktop'
PKG_PATCH[6]='twm.desktop'
PKG_PATCH[7]='windowmaker.desktop'
PKG_PATCH[8]='xfce.desktop'
PKG_PATCH[9]='gnome.desktop'

PKG_PATCH[10]='gdmsetup-pam'
PKG_PATCH[11]='gdmsetup-security'

PKG_PATCH[12]='TwoEighteen-GDM.tar.bz2'


. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh


cflags
cxxflags
prepare
analyzesource
configure \
  --enable-authentication-scheme=pam \
  --with-log-dir=/var/log/gdm --enable-debug
make
makeinstall install-strip

createroleaccount gdm 42 42

# Install the xinitrc.gnome file that starts GNOME *correctly*
createdir $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/xinit
findpatch filename xinitrc.gnome
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 <= 8; idx++ )); do
	findpatch filename ${PKG_PATCH[idx]}
	spewdo "install -m 755 $filename $PKG_STAGEROOT$PKG_SYSCONFDIR/X11/sessions"
done

# Throw out the /etc/dm directory we don't use.
removedir $PKG_STAGEROOT$PKG_SYSCONFDIR/dm

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

# A quick hack to install this theme
createdir $PKG_STAGEROOT$PKG_PREFIX/share/gdm/themes/
findpatch filename ${PKG_PATCH[12]}
unset PKG_PATCH[12]
# Bug in the engine breaks this.
PKG_SRCDIR=foo
opentarball $filename $PKG_STAGEROOT$PKG_PREFIX/share/gdm/themes/
mv $PKG_WORKROOT/TwoEighteen $PKG_STAGEROOT$PKG_PREFIX/share/gdm/themes/TwoEighteen/
mv $PKG_WORKROOT/TwoEighteen-wide $PKG_STAGEROOT$PKG_PREFIX/share/gdm/themes/TwoEighteen-wide/
sanifysource $PKG_STAGEROOT$PKG_PREFIX/share/gdm/themes/
sed -i "s/#GraphicalTheme=circles/GraphicalTheme=$DEFAULT_THEMENAME/;" $PKG_STAGEROOT$PKG_PREFIX/share/gdm/defaults.conf


tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup

#vim: ts=2
