Provides automatic installation scripts for OpenRA with Tiberian Sun & Red Alert 2 + Dune 2 (Windows, Linux)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
16 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. #!/bin/bash
  2. # Allow interruption of the script at any time (Ctrl + C)
  3. trap "exit" INT
  4. #*********************************************************************************************************
  5. ## VARIABLES USED IN THE SCRIPT
  6. #
  7. # Package name & version
  8. PACKAGE_NAME=openra-bleed-tibsunra2
  9. PACKAGE_VERSION=1
  10. PACKAGE=$PACKAGE_NAME-$PACKAGE_VERSION
  11. # Find out used Linux distribution
  12. RELEASE=$(lsb_release -d | sed 's/Description:\t//g')
  13. # Check if the used OS is Ubuntu 14.04 LTS/14.10 or Linux Mint
  14. RELEASE_VERSION=$(lsb_release -r | sed 's/[^0-9]*//g')
  15. RELEASE_MINT=$(lsb_release -i 2>/dev/null |grep -c "Mint")
  16. # Check for critical build dependencies (especially for Ubuntu 14.04 LTS/14.10 & Linux Mint)
  17. PKG1_CHECK=$(dpkg-query -W -f='${Status}' libnuget-core-cil 2>/dev/null | grep -c "ok installed")
  18. PKG2_CHECK=$(dpkg-query -W -f='${Status}' mono-devel 2>/dev/null | grep -c "ok installed")
  19. PKG3_CHECK=$(dpkg-query -W -f='${Status}' nuget 2>/dev/null | grep -c "ok installed")
  20. # Do we have any OpenRA packages on the system?
  21. PKG4_CHECK=$(dpkg-query -W -f='${Status}' openra 2>/dev/null | grep -c "ok installed")
  22. PKG5_CHECK=$(dpkg-query -W -f='${Status}' openra-playtest 2>/dev/null | grep -c "ok installed")
  23. PKG6_CHECK=$(dpkg-query -W -f='${Status}' openra-bleed 2>/dev/null | grep -c "ok installed")
  24. # Check for missing RA2 directories.
  25. RA2_MISSINGDIR1="$HOME/openra-master/$PACKAGE/mods/ra2/bits/vehicles"
  26. RA2_MISSINGDIR2="$HOME/openra-master/$PACKAGE/mods/ra2/bits/themes"
  27. # Check if we already have sudo password in memory (timeout/timestamp check)
  28. SUDO_CHECK=$(sudo -n uptime 2>&1|grep "load"|wc -l)
  29. BASH_CHECK=$(ps | grep `echo $$` | awk '{ print $4 }')
  30. bold_in='\e[1m'
  31. line_in='\e[4m'
  32. dim_in='\e[2m'
  33. green_in='\e[32m'
  34. red_in='\e[91m'
  35. out='\e[0m'
  36. #*********************************************************************************************************
  37. ## PRE-CHECK
  38. #
  39. # Check if we're using bash or sh to run the script. If bash, OK. If sh, ask user to run the script with bash.
  40. if [ ! $BASH_CHECK = "bash" ]; then
  41. echo "\nPlease run this script using bash (/usr/bin/bash).\n"
  42. exit 1
  43. fi
  44. # Check if we are root or not. If yes, then terminate the script.
  45. if [[ $UID = 0 ]]; then
  46. echo -e "\nPlease run this script as a regular user. Do not use root or sudo. Some commands used in the script require regular user permissions.\n"
  47. exit 1
  48. fi
  49. #If package dir exists already, delete it.
  50. if [ -d "$HOME/openra-master/" ]; then
  51. rm -rf "$HOME/openra-master"
  52. fi
  53. #If deb package exists already, delete it.
  54. if [ -f $HOME/$PACKAGE_NAME*.deb ]; then
  55. rm -f $HOME/$PACKAGE_NAME*.deb
  56. fi
  57. # Stop execution if we encounter an error
  58. set -e
  59. #*********************************************************************************************************
  60. ## PART 1/7
  61. #
  62. ## Installation of OpenRA compilation dependencies and user notification message
  63. echo -e "\n$bold_in***Welcome Comrade*** $out\n"
  64. echo -e "This script compiles and installs OpenRA from source with Tiberian Sun & Red Alert 2.\n
  65. - The script is NOT made by the developers of OpenRA and may contain bugs.
  66. - The script works only on Ubuntu, Linux Mint and similar Linux distributions. It creates a deb installation package using OpenRA source code and additional Red Alert 2 mod files from Github.\n\nNOTE: As the development of OpenRA & Red Alert 2 continues, this script will likely become unusable some day. Please, feel free to modify it if necessary."
  67. echo -e "$line_in\nThe script has been tested on:\n\nDistribution\t\tStatus$out\nUbuntu 16.04 LTS$green_in\tOK$out\nUbuntu 15.10$green_in\t\tOK$out\nUbuntu 15.04 LTS$green_in\tOK$out\nUbuntu 14.10$green_in\t\tOK$out\nUbuntu 14.04 LTS$green_in\tOK$out\nLinux Mint 17.3$green_in\t\tOK$out\nLinux Mint 17.2$green_in\t\tOK$out\nLinux Mint 17.1$green_in\t\tOK$out\nLinux Mint 16$red_in\t\tFailure$out$dim_in (can't find required packages)$out\n"
  68. echo -e "You are using $RELEASE.\n"
  69. read -r -p "Do you want to continue? [y/N] " response
  70. if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
  71. sleep 1
  72. echo -e "\nAllright, let's continue. Do you want $bold_in\n\n1.$out manually check which OpenRA build dependencies (packages) will be installed on your system and manually install OpenRA after compilation? $dim_in(manual apt-get + deb packages installation)$bold_in\n2.$out automatically accept the installation of the OpenRA build dependencies during the script execution and automatically install OpenRA after compilation? $dim_in(apt-get with -y option + automatic .deb packages installation)$out\n"
  73. read -r -p "Please type 1 or 2 (Default: 2): " number
  74. sleep 1
  75. if [[ $number -eq 1 ]]; then
  76. METHOD=''
  77. echo -e "\nSelected installation method:$bold_in Manual$out"
  78. else
  79. METHOD=-y
  80. echo -e "\nSelected installation method:$bold_in Automatic$out"
  81. fi
  82. if [ $SUDO_CHECK -eq 0 ]; then
  83. if [ -z $METHOD ]; then
  84. echo -e "\nOpenRA compilation requires that you install some packages first. Your permission for installation is asked (yes/no) everytime it's needed. This script asks for a required root password now, so you don't have to type it multiple times later on while the script is running.\n\nPlease type sudo/root password now.\n"
  85. else
  86. echo -e "\nOpenRA compilation requires that you install some packages first. This script asks for a required root password now, so you don't have to type it multiple times later on while the script is running.\n\nPlease type sudo/root password now.\n"
  87. fi
  88. sudo echo -e "\nRoot password OK."
  89. sleep 1
  90. else
  91. true
  92. fi
  93. ## Check if the user is running Ubuntu 14.04 LTS/14.10 or Linux Mint and whether required nuget packages are installed if these Linux versions are being used.
  94. if [ $RELEASE_VERSION == 1404 ] || [ $RELEASE_VERSION == 1410 ] || [ $RELEASE_MINT -eq 1 ] ; then
  95. echo -e "\nYou are running Ubuntu 14.04 LTS/14.10 or Linux Mint. We need to check if you have required NuGet packages installed.\nThese packages are not (longer available) from the official repository but they are provided by this package.\n"
  96. read -r -p "Press ENTER to proceed." enter
  97. if [ ${#enter} -eq 0 ]; then
  98. echo -e "$line_in\nChecking NuGet packages$out"
  99. fi
  100. #-----------------------------------------------------------------------------------------------------------------------------------------------------------
  101. ## Check existence of 'nuget', 'libnuget-core-lib' & 'mono-devel' packages on Ubuntu 14.04 LTS/14.10/Linux Mint based system.
  102. if [ $PKG2_CHECK -eq 1 ]; then
  103. echo -e "$green_in\nOK$out - 'mono-devel' found."
  104. else
  105. echo -e "$red_in\nWARNING$out - 'mono-devel' not found."
  106. fi
  107. if [ $PKG1_CHECK -eq 1 ]; then
  108. echo -e "$green_in\nOK$out - 'libnuget-core-cil' found."
  109. else
  110. echo -e "$red_in\nWARNING$out - 'libnuget-core-cil' not found."
  111. fi
  112. if [ $PKG3_CHECK -eq 1 ]; then
  113. echo -e "$green_in\nOK$out - 'nuget' found."
  114. else
  115. echo -e "$red_in\nWARNING$out - 'nuget' not found."
  116. fi
  117. if [ ! $PKG2_CHECK -eq 1 ]; then
  118. echo -e "$red_in\nWARNING$out - NuGet requires 'mono-devel' package which was not found.\n\nInstalling 'mono-devel' now."
  119. sleep 5
  120. echo -e "\nUpdating package lists with APT.\n"
  121. sleep 2
  122. sudo apt-get update && \
  123. sudo apt-get $METHOD install mono-devel
  124. fi
  125. if [ ! $PKG1_CHECK -eq 1 ]; then
  126. if [ $number = 1 ]; then
  127. echo
  128. read -r -p "Install 'libnuget-core-cil' now? [y/N] " response2
  129. if [[ $response2 =~ ^([yY][eE][sS]|[yY])$ ]]; then
  130. sudo dpkg -i ./nuget-14.04-14.10/libnuget-core-cil_2.8.5+md59+dhx1-1~getdeb1_all.deb
  131. else
  132. echo -e "\nOpenRA installation can't continue. Aborting.\n"
  133. exit 1
  134. fi
  135. else
  136. sudo dpkg -i ./nuget-14.04-14.10/libnuget-core-cil_2.8.5+md59+dhx1-1~getdeb1_all.deb
  137. fi
  138. fi
  139. PKG1_RECHECK=$(dpkg-query -W -f='${Status}' libnuget-core-cil 2>/dev/null | grep -c "ok installed")
  140. if [ ! $PKG3_CHECK -eq 1 ]; then
  141. if [ $number = 1 ]; then
  142. echo
  143. read -r -p "Install 'nuget' now? [y/N] " response3
  144. if [[ $response3 =~ ^([yY][eE][sS]|[yY])$ ]]; then
  145. sudo dpkg -i ./nuget-14.04-14.10/nuget_2.8.5+md59+dhx1-1~getdeb1_all.deb
  146. else
  147. echo -e "\nOpenRA installation can't continue. Aborting.\n"
  148. exit 1
  149. fi
  150. else
  151. sudo dpkg -i ./nuget-14.04-14.10/nuget_2.8.5+md59+dhx1-1~getdeb1_all.deb
  152. fi
  153. fi
  154. PKG3_RECHECK=$(dpkg-query -W -f='${Status}' nuget 2>/dev/null | grep -c "ok installed")
  155. if [ $PKG1_RECHECK -eq 1 ] && [ $PKG3_RECHECK -eq 1 ]; then
  156. echo -e "$green_in\nOK$out - All required NuGet packages are installed."
  157. else
  158. echo -e "$red_in\nWARNING$out - Can't find all required NuGet packages. Aborting.\n"
  159. exit 1
  160. fi
  161. else
  162. true
  163. fi
  164. sleep 2
  165. #-----------------------------------------------------------------------------------------------------------------------------------------------------------
  166. echo -e "$bold_in\n1/7 ***OpenRA build dependencies***\n$out"
  167. sleep 2
  168. echo -e "Updating package lists with APT.\n"
  169. sleep 2
  170. sudo apt-get update
  171. echo -e "\nInstalling required OpenRA build dependencies.\n"
  172. sleep 4
  173. sudo apt-get $METHOD install git dpkg-dev dh-make sed mono-devel libfreetype6-dev libopenal-data libopenal1 libsdl2-2.0-0 nuget curl liblua5.1-0-dev zenity xdg-utils build-essential gcc make libfile-fcntllock-perl
  174. mozroots --import --sync && \
  175. sudo apt-key update
  176. #*********************************************************************************************************
  177. ## PART 2/7
  178. #
  179. ## Download the latest OpenRA & Red Alert 2 source files from Github, create build directories to the user's home directory.
  180. ## Once Red Alert 2 source files have been downloaded, move them to the OpenRA parent source directory.
  181. ## Add several missing directories for Red Alert 2.
  182. echo -e "$bold_in\n2/7 ***Downloading OpenRA source code & Red Alert 2 mod files from Github***\n$out"
  183. sleep 2
  184. echo -e "Part 1 (OpenRA source code):\n"
  185. mkdir -p $HOME/openra-master/{$PACKAGE,ra2} && \
  186. git clone -b bleed https://github.com/OpenRA/OpenRA.git $HOME/openra-master/$PACKAGE
  187. echo -e "\nPart 2 (Red Alert 2 mod files):\n"
  188. git clone -b master https://github.com/OpenRA/ra2.git $HOME/openra-master/ra2 && \
  189. mv $HOME/openra-master/ra2/OpenRA.Mods.RA2 $HOME/openra-master/$PACKAGE && \
  190. mv $HOME/openra-master/ra2 $HOME/openra-master/$PACKAGE/mods/
  191. if [ ! -d "$RA2_MISSINGDIR1" ]; then
  192. mkdir "$RA2_MISSINGDIR1"
  193. fi
  194. if [ ! -d "$RA2_MISSINGDIR2" ]; then
  195. mkdir "$RA2_MISSINGDIR2"
  196. fi
  197. cp ./patches/{tibsun_ra2.patch,makefile-mcs.patch,ra2-csproj.patch} $HOME/openra-master/
  198. #*********************************************************************************************************
  199. ## PART 3/7
  200. #
  201. ## Patch several OpenRA source files (Makefile and such) for Tiberian Sun & Red Alert 2
  202. echo -e "$bold_in\n3/7 ***Preparing OpenRA source files for Tiberian Sun & Red Alert 2***\n$out"
  203. sleep 2
  204. patch -d $HOME/openra-master/$PACKAGE -Np1 -i $HOME/openra-master/makefile-mcs.patch
  205. patch -d $HOME/openra-master/$PACKAGE -Np1 -i $HOME/openra-master/tibsun_ra2.patch
  206. patch -d $HOME/openra-master/$PACKAGE -Np1 -i $HOME/openra-master/ra2-csproj.patch
  207. # Get version number for Red Alert 2 mod (Github)
  208. RA2_VERSION=git-$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  209. sed -i "s/Version: {DEV_VERSION}/Version: $RA2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/ra2/mod.yaml
  210. #*********************************************************************************************************
  211. ## PART 4/7
  212. #
  213. ## Compile the game
  214. echo -e "$bold_in\n4/7 ***Starting OpenRA compilation with Tiberian Sun & Red Alert 2***\n$out"
  215. sleep 2
  216. cd $HOME/openra-master/$PACKAGE && \
  217. make version && \
  218. make dependencies && \
  219. make all [DEBUG=false]
  220. echo -e "$bold_in\n5/7 ***Preparing OpenRA deb package. This takes a while. Please wait.***\n$out"
  221. dh_make --createorig -s -y && \
  222. echo -e "\noverride_dh_auto_install:\n\tmake install-all install-linux-shortcuts prefix='$HOME/openra-master/$PACKAGE/debian/$PACKAGE_NAME/usr'\n\tsed -i '2s%.*%cd /usr/lib/openra%' '$HOME/openra-master/$PACKAGE/debian/$PACKAGE_NAME/usr/bin/openra'\noverride_dh_usrlocal:\noverride_dh_auto_test:" >> $HOME/openra-master/$PACKAGE/debian/rules && \
  223. sed -i 's/Depends: ${shlibs:Depends}, ${misc:Depends}/Depends: libopenal1, mono-runtime (>= 2.10), libmono-system-core4.0-cil, libmono-system-drawing4.0-cil, libmono-system-data4.0-cil, libmono-system-numerics4.0-cil, libmono-system-runtime-serialization4.0-cil, libmono-system-xml-linq4.0-cil, libfreetype6, libc6, libasound2, libgl1-mesa-glx, libgl1-mesa-dri, xdg-utils, zenity, libsdl2 | libsdl2-2.0-0, liblua5.1-0/g' $HOME/openra-master/$PACKAGE/debian/control && \
  224. sed -i 's/<insert up to 60 chars description>/A multiplayer re-envisioning of early RTS games by Westwood Studios\nConflicts: openra, openra-playtest, openra-bleed/g' $HOME/openra-master/$PACKAGE/debian/control && \
  225. sed -i 's/ <insert long description, indented with spaces>/ ./g' $HOME/openra-master/$PACKAGE/debian/control && \
  226. dpkg-buildpackage -rfakeroot -b -nc -uc -us
  227. #*********************************************************************************************************
  228. ## PART 6/7
  229. #
  230. ## Remove temporary OpenRA build files & directories
  231. echo -e "$bold_in\n6/7 ***Compilation process completed. Moving compiled deb package into '$HOME'***\n$out"
  232. sleep 2
  233. mv $HOME/openra-master/$PACKAGE_NAME*.deb $HOME
  234. echo -e "Removing temporary files."
  235. rm -rf $HOME/openra-master
  236. #*********************************************************************************************************
  237. ## PART 7/7
  238. #
  239. ## Install OpenRA
  240. echo -e "$bold_in\n7/7 ***Starting OpenRA installation process***\n$out"
  241. sleep 2
  242. if [ $PKG4_CHECK -eq 1 ] || [ $PKG5_CHECK -eq 1 ] || [ $PKG6_CHECK -eq 1 ] ; then
  243. echo -e "\nCan't install '$PACKAGE_NAME' because of conflicting packages.\nPlease remove previously installed openra package from your system and try again.\nBuilt $PACKAGE_NAME deb package can be found in '$HOME'.\n"
  244. else
  245. if [ $number = 1 ]; then
  246. read -r -p "Install '$PACKAGE_NAME' now? [y/N] " response4
  247. if [[ $response4 =~ ^([yY][eE][sS]|[yY])$ ]]; then
  248. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  249. else
  250. echo -e "\nPlease install '$PACKAGE_NAME' manually. You find the compiled package in '$HOME'."
  251. sleep 2
  252. fi
  253. else
  254. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  255. fi
  256. fi
  257. #*********************************************************************************************************
  258. ## ADDITIONAL INFORMATION
  259. #
  260. ## Messages
  261. echo -e "\n***OpenRA installation script completed.\nPlease see further instructions below.***"
  262. sleep 4
  263. echo -e "$bold_in\n***TIBERIAN SUN & RED ALERT 2 - HOWTO***$out\n\nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so.\n\nTO PLAY RED ALERT 2: You must install language.mix, multi.mix, ra2.mix and theme.mix into '$HOME/.openra/Content/ra2/' folder. You find these files from original RA2 installation media (CD's):\n\n-theme.mix, multi.mix = RA2 CD Root folder\n-ra2.mix, language.mix = RA2 CD Root/INSTALL/Game1.CAB (inside that archive file)$bold_in\n\n***LAUNCHING OPENRA***$out\n\nTo launch OpenRA, simply type 'openra' (without quotations) in your terminal or use a desktop shortcut file.$bold_in\n\n***UNINSTALLATION***$out\n\nIf you want to remove OpenRA, just type 'sudo apt-get purge --remove $PACKAGE_NAME'\n\nYou can find deb package of $PACKAGE_NAME at '$HOME' for further usage.$bold_in\n\n***MULTIPLAYER***$out\n\nIt's recommended to use exactly same deb installation package for multiplayer usage to minimize possible version differences/conflicts between players. If your friends compiles this package with another operating system, please make sure they use exactly same source files for their OpenRA compilation process.\n\nHave fun!\n"
  264. else
  265. echo -e "\nAborted.\n"
  266. fi