wesnoth/utils/mp-server/update_server
Gunter Labes 7fa4661094 send error messages to STDERR
get the server port from the redirect.cfg (which needs to be changed anyway)
2008-04-26 18:10:52 +00:00

86 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
if [ $# -gt 2 -o $# -lt 1 ]; then
echo "Syntax: $0 <server version> [<revision>]" >&2
exit 1
fi
SERVER=$1
SERVERBASE=$HOME/servers/$SERVER
SOURCE=$HOME/source
SOCKET=$SERVERBASE/build/var/run/socket
if ! [ -d $SERVERBASE ]; then
echo "$SERVER server not found." >&2
exit 1
fi
if ! [ -d $SOURCE ]; then
echo "$SOURCE not found." >&2
exit 1
fi
# only really needed on server.wesnoth.org
CXXFLAGS="$CXXFLAGS -I$HOME/tools/include"
LDFLAGS="$LDFLAGS -L$HOME/tools/lib"
case $SERVER in
1.2 ) cd $SOURCE/1.2 || exit 1
CXXFLAGS="$CXXFLAGS -ggdb3"
;;
1.4 ) cd $SOURCE/1.4 || exit 1
CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7"
SCONS=yes
;;
* ) cd $SOURCE/trunk || exit 1
CXXFLAGS="$CXXFLAGS -ggdb3 -DNUM_SHARDS=7 -O0"
SCONS=yes
;;
esac
REVISION=""
if [ "$2" != "" ]; then
REVISION="-r $2"
fi
echo -n 'svn update... '
svn up $REVISION > /dev/null
rev=$(svnversion -cn src/ | cut -d: -f2)
echo "to $rev"
if [ "$rev" = "" ]; then
echo "No revision information found." >&2
exit 1
fi
# reminder for local changes
#svn status
DIR=wesnothd-svn-${rev}_$SERVER
BUILD=$HOME/servers/builds/$DIR
mkdir -p $BUILD
if [ "$SCONS" = "yes" ]; then
mkdir -p $BUILD/var/run
# need to remove .scons-option-cache when parameters get removed!
CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" scons install-wesnothd prefix=$BUILD fifodir=$BUILD/var/run boostdir=$HOME/tools/include boostlibdir=$HOME/tools/lib boost_suffix=-mt raw_sockets=1 profile=0 fribidi=0 python=0 localedir= prefsdir= | tee $BUILD/scons.log || exit 1
echo "adding '$SERVER' suffix..."
mv $BUILD/bin/wesnothd $BUILD/bin/wesnothd-$SERVER || exit 1
else
echo 'autogen.sh and configure...'
./autogen.sh > $BUILD/autogen.log
./configure --prefix=$BUILD --program-suffix=-$SERVER --enable-server --enable-raw-sockets --disable-game --with-fifodir=$BUILD/var/run --disable-nls --enable-lite --enable-profile --with-boost=$HOME/tools > $BUILD/configure.log CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" || exit 1
make clean > /dev/null
echo 'make...'
make > $BUILD/make.log || exit 1
echo 'make install...'
make install > $BUILD/install.log || exit 1
fi
# remove the man pages
rm -rf $BUILD/share/
cd $SERVERBASE
if [ -p $SOCKET ]; then
rm -f oldbuild
mv build oldbuild
else #the server under build has never been started, keep the oldbuild link to the (currently) running server
rm -f build
fi
ln -s ../builds/$DIR/ build