#!/bin/sh
#
# Copyright 2004 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Copyright 2005-2007 Len Jacob <len.jacob@gmail.com>
# Available under the terms of the GNU GPL.
#
# gnome-screensaversettings.png icon downloaded from http://pixel-mixer.com/

NAME="gnome-screensaver"
VERSION="2.28.0"
REVISION="2"

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

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

# buildrequires gnome-screensaver # because it must migrate all the .desktop
#                                 # files so that this can use the hacks.

# PKG_PATCH[0]='gnome-screensaver-2.20.0-gnomekeyringfix.patch'
# PKG_PATCH[1]='gnome-screensaver-2.20.0-pamgnomekeyringfix.patch'

# ...and a temporary kludge.
if [ ! -n "`ls /usr/share/xscreensaver/config/*.xml 2>/dev/null`" ]; then
	die "You need to have xscreensaver installed for this to complete!"
fi

if [ "$DLG_ARCH" == "x86-64" ]; then
	export LDFLAGS="-L/usr/lib64"
else
	export LDFLAGS="-L/usr/lib"
fi

cflags
cxxflags
prepare
# applypatch 0 1
# applypatch 1 1
analyzesource
configure --with-libgl --with-xf86gamma-ext --enable-locking \
	--with-xscreensaverhackdir=/usr/libexec/xscreensaver \
	--with-xscreensaverdir=/usr/share/xscreensaver/config \
	--with-gdm-config=/usr/share/gdm/defaults.conf \
	--with-mit-screensaver=no --enable-pam --with-shadow
make
makeinstall install-strip

spewdo "echo Creating xscreensaver .desktop files..."
spewdo "cd $PKG_STAGEROOT/usr/share/applications/screensavers"
spewdo "$PKG_WORKROOT/$NAME-$VERSION/data/migrate-xscreensaver-config.sh /usr/share/xscreensaver/config/*.xml >/dev/null"

# Let's use a different icon since it uses the same that xscreensaver. It
# can get confusing
spewdo "mkdir -p PKG_STAGEROOT/usr/share/pixmaps"
spewdo "install -D -m 0644 $DLG_COREREPOS/$NAME/gnome-screensaver-preferences.png $PKG_STAGEROOT/usr/share/pixmaps"
spewdo "sed 's/Icon=preferences-desktop-screensaver/Icon=gnome-screensaver-preferences/' $PKG_STAGEROOT$DLG_DATADIR/applications/gnome-screensaver-preferences.desktop > $PKG_STAGEROOT$DLG_DATADIR/applications/gnome-screensaver-preferences.desktop.new"
spewdo "mv $PKG_STAGEROOT$DLG_DATADIR/applications/gnome-screensaver-preferences.desktop.new $PKG_STAGEROOT$DLG_DATADIR/applications/gnome-screensaver-preferences.desktop"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
