vcmiinstall.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. hash make 2>&- || { echo >&2 "I require make but it's not installed. Aborting."; exit 1; }
  3. hash autoreconf 2>&- || { echo >&2 "I require aureconf but it's not installed. Aborting."; exit 1; }
  4. hash unzip 2>&- || { echo >&2 "I require unzip but it's not installed. Aborting."; exit 1; }
  5. hash svn 2>&- || { echo >&2 "I require svn but it's not installed. Aborting."; exit 1; }
  6. function errorcheck(){
  7. if [ "$?" -gt 0 ]; then
  8. echo "Error during $1"
  9. exit
  10. else
  11. echo "$1 successful"
  12. fi
  13. }
  14. function incusage(){
  15. echo "Incorrect usage; use --help for more info."
  16. exit
  17. }
  18. if [ "$1" = "reconf" ]; then
  19. cd vcmi
  20. autoreconf -i
  21. cd ..
  22. vcmi/configure --datadir=`pwd` --bindir=`pwd`vcmi --libdir=`pwd`
  23. exit
  24. fi
  25. if [ "$1" == "--install" ]; then
  26. if [ $# -lt 2 ]; then
  27. incusage
  28. fi
  29. if [ "$2" == "micro" ]; then
  30. unzip vcmipack.zip -d YourAI
  31. MAINVCMI_ROOT="/home/mateusz/vcmi_retl"
  32. ln -s "$MAINVCMI_ROOT/odpalarka"
  33. exit
  34. fi
  35. #only lean and full modes
  36. svn co https://vcmi.svn.sourceforge.net/svnroot/vcmi/branches/programmingChallenge/ vcmi
  37. errorcheck "fetching sources"
  38. cd vcmi
  39. if [ "$2" = "lean" ]; then
  40. mv "Makefile without client.am" Makefile.am
  41. mv "configure without client.ac" configure.ac
  42. rm client/Makefile.am
  43. echo "SUBDIRS = StupidAI" > AI/Makefile.am
  44. rm -rf AI/EmptyAI
  45. rm -rf AI/GeniusAI
  46. #find . -name ".svn" -exec rm -rf {} \;
  47. elif [ "$2" = "full" ]; then
  48. mv "Makefile with client.am" Makefile.am
  49. mv "configure with client.ac" configure.ac
  50. else
  51. incusage
  52. fi
  53. autoreconf -f
  54. errorcheck "autoreconf -f"
  55. wget http://sourceforge.net/apps/trac/vcmi/export/2443/branches/programmingChallenge/vcmipack.zip
  56. cd ..
  57. vcmi/configure --datadir=`pwd` --bindir=`pwd`vcmi --libdir=`pwd`
  58. errorcheck "configure"
  59. make
  60. errorcheck "make"
  61. unzip vcmi/vcmipack.zip -d vcmi
  62. errorcheck "pack unzip"
  63. ln -s "vcmi/b1.json"
  64. errorcheck "b1.json symlink"
  65. ln -s ../../AI/StupidAI/.libs/libStupidAI.so -t vcmi/AI
  66. errorcheck "StupidAI symlink"
  67. ln -s "Odpalarka/odpalarka"
  68. errorcheck "Odpalarka symlink"
  69. ln -s "VCMI_BattleAiHost/vcmirunner"
  70. errorcheck "runner symlink"
  71. ln -s "server/vcmiserver"
  72. errorcheck "server symlink"
  73. elif [ "$1" = "--clean" ]; then
  74. find . -name "*" -exec bash -c "if [[ {} != './vcmiinstall.sh' ]] && [[ {} != './vcmipack.zip' ]] && [[ {} != '.' ]] && [[ {} != '..' ]]; then rm -rf {} ; fi" \;
  75. elif [ "$1" = "--help" ]; then
  76. echo "VCMI programming challenge installation script"
  77. echo
  78. echo "Available commands: "
  79. echo "--clean removes all created files except this script."
  80. echo "--help displays this info."
  81. echo "--install full downloads and compiles full VCMI with graphical client; requires ffmpeg."
  82. echo "--install lean downloads and compiles most of VCMI (without graphical client)."
  83. echo "--install micro unpacks vcmipack.zip and makes appropriate symbolic links."
  84. else
  85. incusage
  86. fi