Posted by nakem on Sun 17th Jan 21:59
Modification of post by nakem | view diff | download
- #!/bin/bash
- #
- ##############################################
- # Planeshift Build Script by nakem & tereay #
- ##############################################
- #
- #
- # Fixing wrong linewraps... (I have to do it in one line to avoid failing because of the wrong linewraps.)
- a="$(echo -en "\r\n")"; grep "$a" "$0" > /dev/null && echo "Fixing..." && sed -i s/"$a"/"$(echo "")"/g "$0" && sh "$0" && exit "$?"
- ## BEGIN - OS specific
- function has_pkg_installer() {
- is_cmd zypper # add the package manager for your system with " || is_cmd <command>"
- return "$?"
- }
- function install_pkgs() {
- if is_cmd zypper; then
- sudo zypper install subversion libtool autoconf automake make jam libpng-devel libjpg-devel libmng-devel openal-devel mesa-devel cg-devel $1
- # Please add the equivalent command for your system like shown here:
- # else if is_cmd <package manager>; then
- # <command>
- #
- fi
- }
- # END - OS specific
- function set_var() {
- eval "$1=\"\$2\""
- }
- function get_var() {
- local __answer__
- echo -n "$3 [$2]: "
- read __answer__
- [[ "$2" != "" ]] && [ "$__answer__" = "" ] && __answer__="$2"
- set_var "$1" "$__answer__"
- }
- function get_cmd() {
- cmd="$(which "$1" 2>/dev/null)"
- if [ "$?" = "1" ]; then
- cmd=""
- fi
- }
- function is_cmd() {
- which "$1" > /dev/null 2>/dev/null
- return "$?"
- }
- function run() {
- if [ "$BUILD_VERBOSE" = "yes" ]; then
- "$@"
- else
- "$@" > /dev/null
- fi
- }
- function _test() {
- run "$@"
- if [ ! "$?" = "0" ]; then
- echo ""
- echo "Test failed!"
- exit 1
- fi
- }
- function cs_test() {
- if [ "$1" = "--notice" ]; then
- notice="yes"
- shift
- else
- notice="no"
- fi
- if ! grep "cs_cv_$1=yes" config.log > /dev/null 2> /dev/null; then
- echo "$1 is missing!"
- [ "$notice" = "no" ] && abort="yes"
- fi
- }
- echo "###########################################"
- echo "# Welcome to the Planeshift Build Script! #"
- echo "###########################################"
- echo ""
- echo "Before the automated build process can start, we have to ask some questions."
- get_var CLEAN "no" "Shall I do a clean build? (build EVERYTHING again?)"
- get_var BUILD_DIR "$HOME/planeshift_build" "Where do you want the files to be placed?"
- #get_var BUILD_INSTALL "no" "Do you want it to be installed?"
- get_var BUILD_SERVER "no" "Shall I compile the server, too?"
- get_var BUILD_VERBOSE "yes" "Do you want me to show all messages?"
- ART_TYPE="none"
- get_var answer "no" "Do you want me to create the art directory?"
- if [ "$answer" = "yes" ]; then
- get_var answer "no" "Do you have the official client installed?"
- if [ "$answer" = "yes" ]; then
- while true; do
- get_var path "/opt/PlaneShift" "Where?"
- if [ -d "$path/art" ]; then
- break
- else
- echo "Wrong directory! Couldn't find $path/art !"
- fi
- done
- ART_TYPE="copy"
- ART_PATH="$path/art"
- else
- get_var answer "yes" "Do you want me to download the art? (will take MUCH time)"
- if [ "$answer" = "yes" ]; then
- ART_TYPE="dl"
- else
- echo "I won't create the art directory because I can't get its content."
- fi
- fi
- fi
- if [[ "$ART_TYPE" != "dl" ]]; then
- get_var PATCH "yes" "Do you want me to fix the PS files (if there are any errors) after compilation?"
- fi
- INSTALL_RPM="no"
- has_pkg_installer && get_var INSTALL_RPM "yes" "Do you want me to install the needed packages(with zypper) automatically?"
- echo "***************************************"
- echo "Running install..."
- [ ! "$(echo "$BUILD_DIR" | cut -b 1)" = "/" ] && BUILD_DIR="$PWD/$BUILD_DIR" # It's a relative path. Make it absolute!
- echo ""
- echo -n "Checking dependencies... "
- add=""
- [ "$BUILD_SERVER" = "yes" ] && add="libmysqlclient-devel"
- if has_pkg_installer; then
- if [ "$INSTALL_RPM" = "yes" ]; then
- echo "I'll install all needed packages now..."
- #sudo zypper install subversion libtool autoconf automake make jam libpng-devel libjpg-devel libmng-devel openal-devel mesa-devel cg-devel $add
- install_pkgs "$add"
- fi
- else
- list=""
- for name in svn libtool autoconf make jam; do
- if ! is_cmd "$name"; then
- list="$name $list"
- fi
- done
- if ! is_cmd cginfo; then
- list="cg-devel $list"
- fi
- if [[ "$list" != "" ]]; then
- echo ""
- echo "You need to following packages to start compiling: $list"
- echo "You will also need these libraries to compile: libpng-devel libjpg-devel libmng-devel openal-devel mesa-devel cg-devel $add"
- echo "Please note: These package names are taken from openSuse packages..."
- echo "Please install them yourself!"
- exit 1
- fi
- fi
- echo "Creating file structure..."
- [ ! -d "$BUILD_DIR" ] && mkdir "$BUILD_DIR"
- cd "$BUILD_DIR"
- if [ "$CLEAN" = "yes" ]; then
- echo "Cleaning directory..."
- echo -n "cal3d "
- rm -Rf cal
- echo -n "cs "
- rm -Rf cs
- echo -n "planeshift "
- rm -Rf planeshift
- echo ""
- fi
- echo "Starting downloads..."
- echo "Cal3D: http://svn.gna.org/svn/cal3d/trunk/cal3d"
- run svn co -r 507 http://svn.gna.org/svn/cal3d/trunk/cal3d cal3d
- echo "Crystal Space: https://crystal.svn.sourceforge.net/svnroot/crystal/CS/trunk"
- run svn co https://crystal.svn.sourceforge.net/svnroot/crystal/CS/trunk cs
- echo "Planeshift: https://planeshift.svn.sourceforge.net/svnroot/planeshift/trunk"
- run svn co https://planeshift.svn.sourceforge.net/svnroot/planeshift/trunk planeshift
- echo "Configuring cal3d..."
- cd cal3d
- sed -i 's/AM_USE_UNITTESTCPP/\# AM_USE_UNITTESTCPP/' configure.in
- if [ "$CLEAN" = "yes" ]; then
- run autoreconf --install --force
- else
- run autoreconf --install
- fi
- run ./configure --prefix="$BUILD_DIR/cal3d"
- if [ "$?" = "1" ]; then
- echo "Failed to configure cal3d!"
- echo "Aborting!"
- exit 1
- fi
- echo "Compiling cal3d..."
- run make
- if [ ! "$?" = "0" ]; then
- echo "Failed to compile cal3d!"
- echo "Aborting!"
- exit 1
- fi
- run make install
- if [ ! "$?" = "0" ]; then
- echo "Failed to install cal3d!"
- echo "Aborting!"
- exit 1
- fi
- echo "Running tests..."
- cd tests
- echo -n "Test 1/4 ..."
- _test sh run converter/skeleton
- echo -en "\rTest 2/4 ..."
- _test sh run converter/mesh
- echo -en "\rTest 3/4 ..."
- _test sh run converter/material
- echo -en "\rTest 4/4 ..."
- _test sh run converter/animation
- ## Needs valgrind and caused too much trouble...
- #echo -e "\rTest 5/5 ..."
- #_test sh run ./quaternion
- cd ..
- export LD_LIBRARY_PATH="$BUILD_DIR/cal3d/lib:$LD_LIBRARY_PATH"
- echo "Configuring Crystal Space..."
- cd ../cs
- run ./configure --without-java --without-perl --without-python --without-3ds --with-cal3d="$BUILD_DIR/cal3d"
- if [ ! "$?" = "0" ]; then
- echo "Failed to configure Crystal Space!"
- echo "Aborting!"
- exit 1
- fi
- echo "Testing..."
- abort="no"
- cs_test libCg
- cs_test libCgGL
- cs_test libcal3d
- cs_test libgl
- cs_test libpng
- cs_test libjpeg
- cs_test liblcms
- cs_test libmng
- cs_test libogg
- cs_test libvorbis
- cs_test libvorbisfile
- # Dumb, isn't it ?
- cs_test libx11
- cs_test libz
- cs_test --notice libopenal
- cs_test --notice libasound
- if [ "$abort" = "yes" ]; then
- echo "Some libraries are missing!"
- echo "Aborting!"
- exit 1
- fi
- echo "Compiling Crystal Space..."
- if [ "$CLEAN" = "yes" ]; then
- run jam libs plugins cs-config walktest
- else
- run jam -aq libs plugins cs-config walktest
- fi
- export LD_LIBRARY_PATH="$BUILD_DIR/cs:$LD_LIBRARY_PATH"
- export CRYSTAL="$BUILD_DIR/cs"
- echo "Configuring Planeshift..."
- cd ../planeshift
- run ./autogen.sh
- run ./configure --with-cal3d="$BUILD_DIR/cal3d"
- if [ "$?" = "1" ]; then
- echo "Failed to configure Planeshift!"
- echo "Aborting!"
- exit 1
- fi
- echo "Compiling Planeshift..."
- if [ "$CLEAN" = "yes" ]; then
- run jam -aq client
- else
- run jam client
- fi
- if [ ! "$?" = "0" ]; then
- echo "Failed to build Planeshift!"
- echo "Aborting!"
- exit 1
- fi
- if [ "$BUILD_SERVER" = "yes" ]; then
- run jam server
- if [ ! "$?" = "0" ]; then
- echo "Failed to build the Server!"
- fi
- fi
- echo "Writing scripts..."
- # To prevent overwriting our compiled files!
- if ! grep "Update.Platform = false" pslaunch.cfg > /dev/null; then
- echo "Update.Platform = false" >> pslaunch.cfg
- fi
- # Template
- sc="#!/bin/bash
- export CRYSTAL=\"../cs\"
- export LD_LIBRARY_PATH=\"../cal3d/lib:../cs:\$LD_LIBRARY_PATH\""
- for script in psclient pslaunch pssetup psserver; do
- if [ -f "$script" ]; then
- mv "$script" "$script.bin"
- echo "$sc" > "$script"
- echo "./$script.bin \"\$@\"" >> "$script"
- chmod +x "$script"
- fi
- done
- if [ "$ART_TYPE" = "copy" ]; then
- echo "Copying art..."
- cp -R "$ART_PATH" art
- fi
- p="no"
- if [ "$ART_TYPE" = "dl" ]; then
- echo "Downloading art..."
- p="yes"
- else
- if [ "$PATCH" = "yes" ]; then
- echo "Patching install..."
- p="yes"
- fi
- fi
- [ "$p" = "yes" ] && echo "y" | ./pslaunch --console --repair
- echo "Updating..."
- echo "y" | ./pslaunch --console
- echo "Done!"
- echo "***********************************************"
- read
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.