# SliTaz package receipt.

PACKAGE="checkers"
VERSION="1.0"
CATEGORY="games"
SHORT_DESC="Checkers game in javascript"
MAINTAINER="pascal.bellard@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.lzma"
WEB_SITE="http://thierry.franquin.free.fr/jeudame/Dames.htm"

# Rules to configure and make the package.
compile_rules()
{
	
	if [ -f $SOURCES_REPOSITORY/$TARBALL ]; then
		unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf -
	else
		mkdir -p $src/$PACKAGE-$VERSION
		for i in Dames.htm black.gif gray.gif \
			 me1k.gif me2k.gif you1k.gif you2k.gif \
			 me1.gif me2.gif you1.gif you2.gif ; do
			[ -s $i ] || wget -O $src/$PACKAGE-$VERSION/$i $(dirname $WEB_SITE)/$i
		done
		cd $src
		tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
		mv $PACKAGE-$VERSION/* .
		rm -rf $PACKAGE-$VERSION
	fi
		
	cd $src
	grep -qs Dames_htm_smartbutton1 Dames.htm || return 0
	sed -i  -e 's|TITLE>.*</TITLE|TITLE>Checkers</TITLE|' \
		-e 's|background="nth_brown_bg.gif" ||' \
		-e 's|cellpadding=0|& align=center|' \
		-e '/Vous devez commencer/d' \
		-e '/version = 1.0;/,/Checkers Game/d' \
		-e '/wrap=virtual/d' \
		-e '/marrer le jeu/d' \
		-e '/Dames_htm_smartbutton1/d' \
		-e 's|table><br>"|&);|' \
			Dames.htm
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
        mkdir -p $fs/var/www/checkers $fs/usr/share/applications
	cp $src/* $fs/var/www/checkers
	mv $fs/var/www/checkers/Dames.htm $fs/var/www/checkers/index.html
	chown -R 80.80 $fs/var/www/checkers
	cat > $fs/usr/share/applications/checkers.desktop <<EOT
[Desktop Entry]
Type=Application
Name=Checkers
Exec=browser file:///var/www/checkers/index.html
Icon=checkers
Terminal=false
Categories=Game;
Comment=Checkers game
EOT
}