#!/bin/bash # # Planeshift CVS installer # install and build planeshift from cvs for debian (or debian like) systems # by beedauchon with some help from http://icarus.uic.edu/~ssenne1/ # CODATE="2005-05-18" intRevision="12" doMysql=false help=false noPsup=false noUpdate=false version=false psupmode=false sqlOnly=false # MYOS=`/bin/uname -s` if [ $MYOS != "Linux" ] || [ ! -e "/usr/bin/apt-get" ]; then echo "...you're not running a debian gnu/linux compatible system ! exiting..." exit; fi if [ $USER = "root" ]; then echo "...installing required packages..." apt-get install bison-1.35 flex-old libmng-dev libmikmod2-dev libogg-dev libvorbis-dev zlib1g-dev libpng3-dev libjpeg62-dev xlibmesa-glu-dev python2.3-dev autoconf automake1.8 libcurl3-dev jam cvs exit; elif [ ! -e "/usr/bin/jam" ]; then echo "...jam not found, please run this script as root to install required packages, exiting..." exit; else MYPSHOME=/home/$USER/ps fi # define funs showUsage() { echo "Usage: `basename $0` [OPTION]..." echo "Install and build planeshift from cvs for debian (or debian like) systems" echo "Run it as root to install required packages" echo "Run it as a normal user to checkout and build" echo "Once built if you want to reconfigure" echo " you have to remove manually the Jamfile or the Makefile in the chosen target dir" echo "Options :" echo " -p, --path the path where you want to checkout and build planeshift components" echo " if not specified it defaults to /home/$USER/ps" echo "--psver=MB install planeshift Molecular Blue" echo "--psver=HEAD install bleeding edge planeshift" echo "--codate=YYYY-MM-DD install with date rev" echo "--nocvsup do not update from CVS if dirs exist" echo "--nopsup do not run planeshift updater at exit" echo " -u, --mysqluser= mysql username" echo " -p, --mysqlpassword= mysql password" echo " (should prompt if one is needed and not specified)" echo "--domysql setup mysql database" echo " note: if the database already exists, the database will be DELETED" echo "--dbonly deletes old mysql database and installs new one, then quits" echo " -h, --help show the help" echo " -v, --version show the name and version" } showVersion() { echo "`basename $0` v$intRevision" } getParams() { ac_prev= for ac_option do # If the previous option needs an argument, assign it if test -n "$argument"; then eval "$argument=\$option" ac_prev= continue fi userInput=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos case $ac_option in -help | --help | -h) help=true;; -version | --version | -v) version=true;; -path=* | --path=* | --pat=* | --pa=* | --p=*) export target=$userInput ;; -ve | -verbose | --verbose | --verbos | --verbo | --verb) verbose=3 ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q) verbose=2 ;; -s | -silent | --silent | --silen | --sile | --sil) verbose=1 ;; -psversion=* | --psversion=* | -psv=* | -psv* | --psver=*) psversion=$userInput ;; --mysqluser=* | -u* | --user=* |--mysql=*) mysqluser=$userInput ;; --mysqlpassword=* | -p* | --password=*) mysqlpassword=$userInput;; --domysql | --do-mysql | --dodb | --dodatabase) doMysql=true;; --nopsup | --skippsup | --ignorepsup) noPsup=false;; --nocvsup | --skipcvsup | --ignorecvsup) noUpdate=true;; --dbonly | --databaseonly | --mysqlonly) sqlOnly=true;; --debug) mode=--enable-debug;; esac done } parseParams() { if [ $help = "true" ]; then showUsage exit; elif [ $version = "true" ]; then showVersion exit; fi echo "Planeshift CVS installer revision $intRevision started..." if [ -n "$mysqluser" ] ; then export MYSQLPARAM="-u $mysqluser" fi if [ -n "$mysqlpassword" ]; then export MYSQLPARAM="$MYSQLPARAM -p $mysqlpassword" fi if [ $sqlOnly = "true" ]; then buildDatabase exit; fi if [ -n "$target" ]; then PSHOME=$target elif [ -z $PSHOME ]; then PSHOME=$MYPSHOME fi if [ -d $PSHOME ]; then echo "...found ps home dir..." else echo "...creating ps home dir..." mkdir -p $PSHOME fi if [ -z $psversion ]; then psversion=" " export VERSION="$CODATE" export CALD3DARG="-D$CODATE" export PSARG="-D$CODATE" export CSARG="-D$CODATE" export CELARG="-D$CODATE" elif [ $psversion = "MB" ]; then export VERSION="MB" export CALD3DARG="-D2003-05-16" export PSARG="-rMB010" export CSARG="-rPRE_THING_FACTORIES" export CELARG="-D2003-05-16" elif [ $psversion = "HEAD" ]; then export VERSION="HEAD" export CALD3DARG="" export PSARG="" export CSARG="" export CELARG="" fi } doExports() { export LD_LIBRARY_PATH=$PSHOME/cal3d/src/cal3d/.libs/:$LD_LIBRARY_PATH export CRYSTAL=$PSHOME/CS export CEL=$PSHOME/cel export CSCONFPATH=$PSHOME/cel } getFromCvs() { ################################### #$1=directory name (on server) #$2=modulename #$3=arguments ################################### cd $PSHOME export CVSROOT=:pserver:anonymous@cvs.sourceforge.net:/cvsroot/$1 skipCvs=false if [ -d $PSHOME/$2 ] && [ $noUpdate = "false" ]; then echo "...found $2, using update..." cd $PSHOME CVSMODE="update -PAdC" psupmode=true elif [ $noUpdate = "true" ]; then echo "...found $2, skipping update..." skipCvs=true else echo "...the $2 directory has not been found, using checkout" cd $PSHOME CVSMODE=checkout fi if [ $skipCvs = "false" ]; then cvs -z3 -Q -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/$1 $CVSMODE $3 $2 while [ $? != 0 ]; do echo "...failed to $CVSMODE $2, retrying in 5 seconds..." sleep 5 cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/$1 $CVSMODE $3 $2 done fi } BuildCal3d() { cd $PSHOME/cal3d if [ ! -e "Makefile" ]; then ./autogen.sh ./configure else echo "...cal3d Makefile, found skipping configure..." fi echo "...building cal3d..." make } BuildCs() { cd $PSHOME/CS if [ ! -e "Jamfile" ] || [ $psupmode = "true" ]; then ./configure --enable-debug --with-libcal3d=../cal3d/src/cal3d/.libs/ CPPFLAGS="-I ../cal3d/src/" else echo "...CS Jamfile found, skipping configure..." fi echo "...building CS..." jam libs jam plugins jam cs-config } BuildCel() { cd $PSHOME/cel if [ ! -e "Jamfile" ] || [ $psupmode = "true" ]; then ./configure --enable-debug else echo "...cel Jamfile found, skipping configure..." fi echo "...building cel..." jam -a } BuildPlaneshift() { cd $PSHOME/planeshift if [ -h $PSHOME/planeshift/cal3d ]; then echo "...found cal3d link in planeshift dir..." else ln -s ../cal3d/src/cal3d/ cal3d fi if [ ! -e "Jamfile" ] || [ $psupmode = "true" ]; then ./autogen.sh ./configure --enable-debug --with-libcal3d=$PSHOME/cal3d else echo "...planeshift Jamfile found, skipping configure..." fi echo "...building planeshift..." jam -a } RunPsUpdater() { # planeshift updater if [ $noPsup = "false" ]; then cd $PSHOME/planeshift if [ -e "updater" ]; then echo "...running planeshift updater..." ./updater --auto else echo "...updater not found..." fi cd .. fi } buildDatabase() { echo "...creating planeshift database..." mysql $MYSQLPARAM --exec="drop database planeshift;" mysql $MYSQLPARAM --exec="create database planeshift;" mysql $MYSQLPARAM --exec="GRANT ALL PRIVILEGES ON *.* TO planeshift@localhost IDENTIFIED BY 'planeshift' WITH GRANT OPTION;" cd $PSHOME/planeshift/src/server/database/mysql/ mysql -u planeshift -pplaneshift --exec="source create_all.sql;" } theEnd() { cd $PSHOME #this makes the file that runs the client, works well for version control #instead of exporting variables from ~/.bashrc, this #allows the user to have both cvs and molecular blue installed if [ ! -e "run_ps_client" ]; then echo "#!/bin/bash" > run_ps_client echo "export CRYSTAL=$PSHOME/CS" >> run_ps_client echo "export CEL=$PSHOME/cel/" >> run_ps_client echo "export CSCONFPATH=$PSHOME/cel/" >> run_ps_client echo "cd $PSHOME/planeshift" >> run_ps_client echo "./psclient \$@" >> run_ps_client chmod +x run_ps_client fi #this makes the file that runs the server, works well for version control if [ ! -e "run_ps_server" ]; then echo "#!/bin/bash" > run_ps_server echo "export CRYSTAL=$PSHOME/CS" >> run_ps_server echo "export CEL=$PSHOME/cel/" >> run_ps_server echo "export CSCONFPATH=$PSHOME/cel/" >> run_ps_server echo "cd $PSHOME/planeshift" >> run_ps_server echo "./psserver \$@" >> run_ps_server chmod +x run_ps_server fi # TODO make one of these for the npcclient echo "============================" echo " to run planeshift client :" echo " cd $PSHOME" echo " ./run_ps_client" echo "============================" echo " to run planeshift server :" echo " cd $PSHOME" echo " ./run_ps_server" echo "============================" } # main getParams $@ parseParams doExports # checkout sources echo "...checking sources for version $VERSION..." getFromCvs cal3d cal3d "$CALD3DARG" getFromCvs crystal CS "$CSARG" getFromCvs cel cel "$CELARG" getFromCvs planeshift planeshift "$PSARG" # build targets echo "...building all targets..." if [ $psupmode = "true" ]; then echo "...update mode, all configure script will be rerunned..." fi BuildCal3d BuildCs BuildCel BuildPlaneshift if [ $doMysql = "true" ]; then buildDatabase fi RunPsUpdater theEnd echo "...all tasks finished"