#!/bin/sh

NAME=phpfreechat-`cat ../version.txt`
PFCSETUPNAME=pfcsetup-`cat ../version.txt`

echo "-- creating archive $NAME --"
echo "-> copying files"
rm -rf ./$NAME
svn export .. ./$NAME
rm -rf ./$NAME/contrib
rm -rf ./$NAME/admin
rm -rf ./$NAME/lib/pear/.registry

#echo "-> downloading documentation"
#wget http://www.phpfreechat.net/pages/fr/install.html   -q -O ./$NAME/install.fr.html
#wget http://www.phpfreechat.net/pages/en/install.html   -q -O ./$NAME/install.en.html
#wget http://www.phpfreechat.net/pages/fr/faq.html       -q -O ./$NAME/faq.fr.html
#wget http://www.phpfreechat.net/pages/en/faq.html       -q -O ./$NAME/faq.en.html
#wget http://www.phpfreechat.net/pages/fr/overview.html  -q -O ./$NAME/overview.fr.html
#wget http://www.phpfreechat.net/pages/en/overview.html  -q -O ./$NAME/overview.en.html
#wget http://www.phpfreechat.net/pages/ar/overview.html  -q -O ./$NAME/overview.ar.html
#wget http://www.phpfreechat.net/pages/es/overview.html  -q -O ./$NAME/overview.es.html
#wget http://www.phpfreechat.net/pages/zh/overview.html  -q -O ./$NAME/overview.zh.html
#wget http://www.phpfreechat.net/pages/fr/customize.html -q -O ./$NAME/customize.fr.html
#wget http://www.phpfreechat.net/pages/en/customize.html -q -O ./$NAME/customize.en.html
#wget http://www.phpfreechat.net/pages/fr/changelog.html -q -O ./$NAME/changelog.fr.html
#wget http://www.phpfreechat.net/pages/en/changelog.html -q -O ./$NAME/changelog.en.html

echo "-> creating checkmd5.php file"
./checkmd5 ./$NAME ./$NAME/checkmd5.php

echo "-> creating $NAME.tar.gz"
tar czfp $NAME.tar.gz ./$NAME 
echo "-> creating $NAME.zip"
zip -Tq9r $NAME.zip ./$NAME
echo "-> creating $NAME-setup.php"
php ./createwebinstaller.php `cat ../version.txt` > /dev/null

#echo "-> creating $PFCSETUPNAME.tar.gz"
#rm -rf ./$PFCSETUPNAME
#svn export ../contrib/pfcInstaller2 $PFCSETUPNAME
#rm -rf ./$PFCSETUPNAME/.registry
#rm -rf ./$PFCSETUPNAME/.depdblock
#rm -rf ./$PFCSETUPNAME/.lock
#rm -rf ./$PFCSETUPNAME/.channels
#rm -rf ./$PFCSETUPNAME/tmp
#rm -rf ./$PFCSETUPNAME/bin
#rm -rf ./$PFCSETUPNAME/PEAR
#rm -rf ./$PFCSETUPNAME/System.php
#rm -rf ./$PFCSETUPNAME/peclcmd.php
#rm -rf ./$PFCSETUPNAME/pearcmd.php
#rm -rf ./$PFCSETUPNAME/pear.sh
#rm -rf ./$PFCSETUPNAME/pearrc
#rm -rf ./$PFCSETUPNAME/OS
#echo "$NAME.tar.gz" > $PFCSETUPNAME/archivename
#echo `pwd` >> $PFCSETUPNAME/mirrors
#tar czfp $PFCSETUPNAME.tar.gz ./$PFCSETUPNAME
#echo "-> creating $PFCSETUPNAME.zip"
#zip -Tq9r $PFCSETUPNAME.zip ./$PFCSETUPNAME
#rm -rf ./$PFCSETUPNAME

echo "-> removing temporary files"
rm -rf ./$NAME
echo "-- creating archive $NAME, done --"
