#!/bin/bash
#Auteur : Mav
#Contact : maveryck@jabber-fr.net
#Version : 16/02/08
#Changelog
# 16/02/08 : ajout des paquets libxxf86vm-dev et libx11-dev danss les dépendances
# 12/02/08 : ajout de la fonction de desinstallation de Glitz
# modification de la fonction de vérification des erreurs lors de l'install
DEBUG=0 # Attention, ne pas oublier de modifier !!!
DIR=$(pwd)
LOG_CAIRO_DOCK=$DIR/log.txt
LOG_CAIRO_GLITZ=$DIR/log_glitz.txt
SCRIPT_CAIRO_WITH_GLITZ=$DIR/script_cairo_dock_with_glitz.sh
SCRIPT="cairo-dock_svn.sh"
SCRIPT_SAVE="cairo-dock_svn_en.sh.save"
SCRIPT_NEW="cairo-dock_svn.sh.new"
HOST="http://svn.glx-dock.org"
LIBCAIRO="cairo-1.4.14"
GLITZ="glitz-0.5.6"
PIXMAN="pixman-0.9.6"
PLUGINS="alsaMixer clock dustbin gnome-integration logout rhythmbox rendering terminal systray powermanager shortcuts Xgamma weather xmms showDesklets wifi tomboy mail"
PLUGINS_TO_INSTALL=""
NEEDED="subversion libtool build-essential automake1.9 autoconf m4 autotools-dev pkg-config libtool libcairo2-dev libgtk2.0-dev librsvg2-dev libglitz1-dev libcairo2 librsvg2-2 libglitz1 libglitz-glx1 libglitz-glx1-dev libdbus-glib-1-dev libgnomevfs2-dev libgnomeui-dev zenity intltool gettext libvte-dev libxxf86vm-dev libx11-dev libalsa-ocaml libalsa-ocaml-dev libasound2-dev"
UPDATE=0
UPDATE_PLUG_INS=0
UPDATE_CAIRO_DOCK=0
ALREADY_LOGUED=0
CAIRO_GLITZ_OK=0
ERROR=0
HTTP_TYPE="http"
NORMAL="\\033[0;39m"
BLEU="\\033[1;34m"
VERT="\\033[1;32m"
ROUGE="\\033[1;31m"
install_cairo_dock() {
if [ $ALREADY_LOGUED -ne 1 ]; then
if [ -f $LOG_CAIRO_DOCK ]; then
rm -Rf $LOG_CAIRO_DOCK > /dev/null
ALREADY_LOGUED=1
echo "Cairo-Dock is installed since `date`" > $LOG_CAIRO_DOCK
fi
fi
echo "" >> $LOG_CAIRO_DOCK
echo -e "$BLEU""Installation of cairo-dock"
echo ""
install_cairo >> $LOG_CAIRO_DOCK 2>&1
if [ $? -ne 0 ]; then
ERROR=1
echo -e "$ROUGE""Error"
else
echo -e "$VERT""Completed"
fi
echo -e "$NORMAL"
echo "" >> $LOG_CAIRO_DOCK
}
install_cairo_dock_plugins() {
echo -e "$BLEU""Plugin installation $1"
if [ $ALREADY_LOGUED -ne 1 ]; then
if [ -f $LOG_CAIRO_DOCK ]; then
rm -Rf $LOG_CAIRO_DOCK > /dev/null
ALREADY_LOGUED=1
echo "Cairo-Dock is installed since `date`" > $LOG_CAIRO_DOCK
echo "" >> $LOG_CAIRO_DOCK
fi
fi
echo "Plugin installation" $1 "du `date`" >> $LOG_CAIRO_DOCK
echo "" >> $LOG_CAIRO_DOCK
echo ""
install_plugins $1 >> $LOG_CAIRO_DOCK 2>&1
if [ $? -ne 0 ]; then
ERROR=1
echo -e "$ROUGE""Error"
else
echo -e "$VERT""Completed"
fi
echo -e "$NORMAL"
echo "" >> $LOG_CAIRO_DOCK
}
install_cairo() {
cd $DIR/cairo-dock
autoreconf -isvf && ./configure --prefix=/usr $OPTIONS && make clean all
if [ $? -ne 0 ]; then
return 1
fi
sudo make install
cd ..
}
install_plugins() {
cd $DIR/plug-ins
cd $1
autoreconf -isvf && ./configure --prefix=/usr $OPTIONS && make clean all
if [ $? -ne 0 ]; then
return 1
fi
sudo make install
cd ..
}
install_cairo_with_glitz() {
cd $DIR
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
install_glitz > $LOG_CAIRO_GLITZ 2>&1
}
install_glitz() {
wget $HOST/$GLITZ.tar.gz
wget $HOST/$PIXMAN.tar.gz
wget $HOST/$LIBCAIRO.tar.gz
cd $DIR && tar xzvf $PIXMAN.tar.gz && rm -Rf $PIXMAN.tar.gz && cd $PIXMAN
./configure --prefix=/usr/local && make
sudo make install
cd $DIR && tar xzvf $GLITZ.tar.gz && rm -Rf $GLITZ.tar.gz && cd $GLITZ
./configure --prefix=/usr/local && make
sudo make install
cd $DIR && tar xzvf $LIBCAIRO.tar.gz && rm -Rf $LIBCAIRO.tar.gz && cd $LIBCAIRO
./configure --prefix=/usr/local --enable-glitz && make
sudo make install
cd $DIR
}
check() {
echo -e "$NORMAL""Verifying installation"
sleep 1
egrep -i "( error| Error)" $1
if [ $? -eq 0 ]; then
echo -e "$ROUGE"
echo "Errors detected during installation process."
test "$1" == $LOG_CAIRO_GLITZ
if [ $? -eq 0 ]; then
echo "Cairo failed to install with the Glitz option enabled. Please check log_glitz_NOK.txt for more details"
mv $LOG_CAIRO_GLITZ $DIR/log_glitz_NOK.txt
else
echo "Please check log.txt to get more information and go to the cairo-dock forum to post a bug report in the SVN subsection"
echo -e "$NORMAL"
fi
exit
elif [ $ERROR -ne 0 ]; then
echo -e "$ROUGE""Errors were detectected during the proces, but it's impossible to identify them. Please check log.txt to get more information and go to the cairo-dock forum to post a bug report in the SVN subsection"
exit
else
echo -e "$VERT"
echo "Installation Successful"
echo -e "$NORMAL"
test "$1" == $LOG_CAIRO_GLITZ
if [ $? -eq 0 ]; then
create_launch_script
sleep 5
else
zenity --info --title=Cairo-Dock --text="Click OK to close the terminal"
exit
fi
fi
}
check_new_script() {
cp $SCRIPT $SCRIPT_SAVE #pour moi :)
echo -e "$NORMAL"""
echo "Searching for script update"
wget $HOST/$SCRIPT -q -O $SCRIPT_NEW
diff $SCRIPT $SCRIPT_NEW >/dev/null
if [ $? -eq 1 ]; then
echo -e "$ROUGE"
echo "Please relaunch the script, the update has been downloaded"
echo -e "$NORMAL"
mv $SCRIPT_NEW $SCRIPT
sudo chmod u+x $SCRIPT
zenity --info --title=Cairo-Dock --text="Click OK to close the terminal."
exit
else
echo ""
echo -e "$VERT""You already have the latest version"
fi
echo -e "$NORMAL"
rm $SCRIPT_NEW
}
create_launch_script() {
echo "Creating a script to launch cairo-dock with Glitz"
echo "export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}" > $SCRIPT_CAIRO_WITH_GLITZ
echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}" >> $SCRIPT_CAIRO_WITH_GLITZ
echo "cairo-dock --glitz" >> $SCRIPT_CAIRO_WITH_GLITZ
sudo chmod u+x $SCRIPT_CAIRO_WITH_GLITZ
echo -e "$ROUGE""Please use this script to launch cairo :" $SCRIPT_CAIRO_WITH_GLITZ
}
uninstall() {
cd $DIR/cairo-dock
sudo make uninstall
cd ..
for plugins in $PLUGINS
do
cd $DIR/plug-ins
cd $plugins
sudo make uninstall
cd ..
done
}
uninstall_glitz() {
if [ -d $DIR/$LIBCAIRO ]; then
cd $DIR/$LIBCAIRO
sudo make uninstall
else
return $?
fi
if [ -d $DIR/$GLITZ ]; then
cd $DIR/$GLITZ
sudo make uninstall
else
return $?
fi
if [ -d $DIR/$PIXMAN ]; then
cd $DIR/$PIXMAN
sudo make uninstall
else
return $?
fi
}
if [ $DEBUG -ne 1 ]; then
check_new_script
fi
test "$1" == "--help"
if [ $? -eq 0 ]
then
echo "Usage :"
echo "$0 Update your cairo dock version" # Pour mettre à jour le SVN et installer cairo-dock
echo "$0 --force-install Reinstall Cairo-Dock" #Si vous avez effectué des modifications dans le SVN par vous-même et souhaitez installer cairo-dock
echo "$0 --enable-glitz Update your version and install it with Glitz enbled option "
echo "$0 --force-install --enable-glitz Reinstall your version and install it with Glitz enbled option"
echo "$0 --https Récupérer cairo-dock en https "
echo "$0 --uninstall Uninstall Cairo-Dock "
echo "$0 --uninstall-glitz Uninstall Cairo libs with GLITZ option enabled"
echo "$0 --help Display help menu "
echo ""
echo "Auteur : Mav"
echo "Contact : mav@vef.fr"
exit
fi
test "$1" == "--force-install"
if [ $? -eq 0 ]; then
test "$2" == "--enable-glitz"
if [ $? -eq 0 ]; then
OPTIONS="--enable-glitz"
fi
install_cairo_dock
for plugins in $PLUGINS
do
install_cairo_dock_plugins $plugins
done
check $LOG_CAIRO_DOCK
fi
test "$1" == "--enable-glitz"
if [ $? -eq 0 ]; then
OPTIONS="--enable-glitz"
fi
test "$1" == "--uninstall"
if [ $? -eq 0 ]; then
echo "Uninstalling cairo-dock and plugins"
uninstall > $LOG_CAIRO_DOCK 2>&1
echo "Uninstallation done."
echo ""
echo "Your config file still in your home folder."
echo "You can find it in the hidden .cairo-dock folder"
echo "You can safely delete this folder after the unistallation completed"
zenity --info --title=Cairo-Dock --text="Cairo-Dock has been uninstalled, Please check the messages in terminal"
exit
fi
test "$1" == "--uninstall-glitz"
if [ $? -eq 0 ]; then
echo "Uninstallation of Cairo with GLITZ option enabled"
uninstall_glitz > $LOG_CAIRO_GLITZ 2>&1
if [ $? -eq 0 ]; then
echo "Uninstallation completed"
zenity --info --title=Cairo-Dock --text="=Cairo libs with Glitz option were uninstalled"
else
echo "Problems with uninstalling. Please check" $LOG_CAIRO_GLITZ
fi
exit
fi
test "$1" == "--https"
if [ $? -eq 0 ]; then
HTTP_TYPE="https"
fi
echo -e "$BLEU""Verifying all dependencies needed for compiling "
for tested in $NEEDED
do
dpkg -s $tested |grep installed |grep "Install ok" > /dev/null
if [ $? -eq 1 ]; then
echo -e "$ROUGE""package $tested uninstalled""$NORMAL"""
sudo apt-get install $tested
fi
done
echo ""
echo -e "$VERT""Verification OK""$NORMAL"""
if [ -d $DIR ]; then
echo ""
else
mkdir -p $DIR
fi
cd $DIR
if [ -d $DIR/cairo-dock ]; then
if [ -d $DIR/plug-ins ]; then
echo "" > /dev/null
fi
else
UPDATE=2
fi
if [ ! -f $LOG_CAIRO_GLITZ ]; then
echo -e "$BLEU""Do you want to install cairo-dock with gltiz enabled option ?"
echo ""
echo -e "$BLEU""This option will make the dock faster by using gpu instead of your cpu, but it may cause slowness and some random bugs"
echo -e "$ROUGE""Attention! Bugs were reported with ATI cards or some mobile chipsets"
echo ""
echo -e "$ROUGE""Do you really want to execute this operation? (y/n)"
read answer_cairo_dock_glitz
test "$answer_cairo_dock_glitz" == "y"
if [ $? -eq 0 ]; then
echo ""
echo -e "$BLEU""You must hav lib cairo already installed with Gltiz, 3 packages will be downloaded and installed to complete the process"
echo -e "$ROUGE""Do you really want to execute this operation? (y/n)"
read answer_cairo_glitz
test "$answer_cairo_glitz" == "y"
if [ $? -eq 0 ]; then
OPTIONS="--enable-glitz"
echo -e "$NORMAL"""
echo -e "$BLEU""Downloading and installation of lib Cairo with glitz. Downloading and installing Cairo with option --glitz"
echo -e "$ROUGE""This will take few minutes!"
install_cairo_with_glitz
echo -e "$VERT""Done"
echo -e "$NORMAL"""
check $LOG_CAIRO_GLITZ
echo -e "$NORMAL"""
echo -e "$BLEU""Cairo-Dock with Glitz recompiling"
echo -e "$NORMAL"""
if [ $UPDATE -ne 2 ]; then
install_cairo_dock
for plugins in $PLUGINS
do
install_cairo_dock_plugins $plugins
done
check $LOG_CAIRO_DOCK
fi
fi
fi
else
OPTIONS="--enable-glitz"
echo -e "$VERT""Cairo is already compiled with glitz"
echo -e "$NORMAL"""
fi
if [ $UPDATE -ne 2 ]; then
echo -e "$BLEU""Checking for cairo-dock updates"
echo -e "$NORMAL"
svn update cairo-dock | egrep -i "(Actualis|rest|Upda)" && UPDATE_CAIRO_DOCK=1 || UPDATE_CAIRO_DOCK=0
if [ $UPDATE_CAIRO_DOCK -eq 1 ]; then
echo -e "$VERT""Updates are available"
echo -e "$NORMAL"
sleep 1
install_cairo_dock
UPDATE=1
fi
for plugins in $PLUGINS
do
if [ -d $DIR/plug-ins/$plugins ]; then
echo -e "$BLEU""Check update for" $plugins
echo -e "$NORMAL"
cd $DIR
svn update plug-ins/$plugins | egrep -i "(Actualis|rest|Upda)" && UPDATE_PLUG_INS=1 || UPDATE_PLUG_INS=0
if [ $UPDATE_PLUG_INS -eq 1 ]; then
echo -e "$VERT""Plugin update $plugins available"
sleep 1
echo -e "$NORMAL"
install_cairo_dock_plugins $plugins
UPDATE=1
fi
else
echo -e "$BLEU""Downloading new plugin" $plugins
cd $DIR/plug-ins
svn checkout $HTTP_TYPE://svn.berlios.de/svnroot/repos/cairo-dock/trunk/plug-ins/$plugins
sleep 1
echo -e "$NORMAL"
install_cairo_dock_plugins $plugins
UPDATE=1
fi
done
if [ $UPDATE_CAIRO_DOCK -eq 1 ]; then
echo -e "$VERT""plugins must be reinstalled after cairo dock is updated"
for plugins in $PLUGINS
do
install_cairo_dock_plugins $plugins
done
fi
fi
if [ $UPDATE -eq 0 ]; then
echo -e "$BLEU"
echo "No updates available"
echo -e "$NORMAL"
zenity --info --title=Cairo-Dock --text="Clic OK to close the terminal."
exit
fi
if [ $UPDATE -eq 2 ]; then
echo -e "$BLEU"
echo "It's the first time you are installing Cairo-Dock from SVN"
echo ""
echo "Downloading data. This can take few minutes"
echo -e "$NORMAL"
sleep 2
svn checkout $HTTP_TYPE://svn.berlios.de/svnroot/repos/cairo-dock/trunk/cairo-dock
if [ $? -ne 0 ]; then
echo -e "$ROUGE""Unable to connect to the svn server, check your internet connection or try later"
exit
fi
svn checkout $HTTP_TYPE://svn.berlios.de/svnroot/repos/cairo-dock/trunk/plug-ins/
if [ $? -ne 0 ]; then
echo -e "$ROUGE""Unable to connect to the svn server, check your internet connection or try later"
exit
fi
echo ""
echo -e "$BLEU""Downloaded data. Starting the install process"
echo "This process can take few minutes and slow down your system"
echo -e "$NORMAL"
sleep 5
install_cairo_dock
for plugins in $PLUGINS
do
install_cairo_dock_plugins $plugins
done
check $LOG_CAIRO_DOCK
fi
if [ $UPDATE -eq 1 ]; then
check $LOG_CAIRO_DOCK
fi