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.

539 lines
24 KiB

  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
  8. PACKAGE=openra-bleed-tibsunra2
  9. PACKAGE_NAME=openra-bleed-tibsunra2
  10. # Get our Linux distribution
  11. DISTRO=$(cat /etc/os-release | sed -n '/PRETTY_NAME/p' | grep -o '".*"' | sed -e 's/"//g' -e s/'([^)]*)'/''/g -e 's/ .*//' -e 's/[ \t]*$//')
  12. UBUNTU="Ubuntu"
  13. DEBIAN="Debian"
  14. OPENSUSE="openSUSE"
  15. FEDORA="Fedora"
  16. # Get the current directory
  17. WORKING_DIR=$(pwd)
  18. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  19. # Find out used Linux distribution
  20. RELEASE=$(lsb_release -d | sed 's/Description:\t//g')
  21. # Check if the used OS is Ubuntu 14.04 LTS/14.10 or Linux Mint
  22. RELEASE_VERSION=$(lsb_release -r | sed 's/[^0-9]*//g')
  23. RELEASE_MINT=$(lsb_release -i 2>/dev/null |grep -c "Mint")
  24. # Check for critical build dependencies (especially for Ubuntu 14.04 LTS/14.10 & Linux Mint)
  25. PKG1_CHECK=$(dpkg-query -W -f='${Status}' libnuget-core-cil 2>/dev/null | grep -c "ok installed")
  26. PKG2_CHECK=$(dpkg-query -W -f='${Status}' mono-devel 2>/dev/null | grep -c "ok installed")
  27. PKG3_CHECK=$(dpkg-query -W -f='${Status}' nuget 2>/dev/null | grep -c "ok installed")
  28. # Do we have any OpenRA packages on the system?
  29. PKG4_CHECK=$(dpkg-query -W -f='${Status}' openra 2>/dev/null | grep -c "ok installed")
  30. PKG5_CHECK=$(dpkg-query -W -f='${Status}' openra-playtest 2>/dev/null | grep -c "ok installed")
  31. PKG6_CHECK=$(dpkg-query -W -f='${Status}' openra-bleed 2>/dev/null | grep -c "ok installed")
  32. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  33. # Find out used OpenSUSE version
  34. RELEASE=$(cat /etc/os-release | sed -n 4p | grep -o '".*"' | sed -e 's/"//g' -e s/'([^)]*)'/''/g -e 's/[ \t]*$//')
  35. # Do we have any OpenRA packages on the system?
  36. PKG1_CHECK=$(rpm -qa openra | wc -l)
  37. PKG2_CHECK=$(rpm -qa openra-playtest | wc -l)
  38. PKG3_CHECK=$(rpm -qa openra-bleed | wc -l)
  39. elif [[ $DISTRO =~ $FEDORA ]]; then
  40. # Find out used Fedora version
  41. RELEASE=$(cat /etc/os-release | sed -n '/PRETTY_NAME/p' | grep -o '".*"' | sed -e 's/"//g' -e s/'([^)]*)'/''/g -e 's/[ \t]*$//')
  42. # Do we have any OpenRA packages on the system?
  43. PKG1_CHECK=$(rpm -qa openra | wc -l)
  44. PKG2_CHECK=$(rpm -qa openra-playtest | wc -l)
  45. PKG3_CHECK=$(rpm -qa openra-bleed | wc -l)
  46. fi
  47. # Check for missing RA2 directories.
  48. RA2_MISSINGDIR1="$HOME/openra-master/$PACKAGE/mods/ra2/bits/vehicles"
  49. RA2_MISSINGDIR2="$HOME/openra-master/$PACKAGE/mods/ra2/bits/themes"
  50. # Check if we already have sudo password in memory (timeout/timestamp check)
  51. SUDO_CHECK=$(sudo -n uptime 2>&1|grep "load"|wc -l)
  52. BASH_CHECK=$(ps | grep `echo $$` | awk '{ print $4 }')
  53. bold_in='\e[1m'
  54. line_in='\e[4m'
  55. dim_in='\e[2m'
  56. green_in='\e[32m'
  57. yellow_in='\e[33m'
  58. red_in='\e[91m'
  59. out='\e[0m'
  60. #Distribution related dependencies
  61. DEBIAN_DEPS=("git" "dpkg-dev" "dh-make" "mono-devel" "libfreetype6" "libopenal1" "libsdl2-2.0-0" "curl" "liblua5.1-0" "zenity" "xdg-utils" "build-essential" "gcc" "make" "libfile-fcntllock-perl")
  62. OPENSUSE_DEPS=("rpm-build" "git" "mono-devel" "libfreetype6" "libopenal1" "libSDL2-2_0-0" "curl" "lua51" "liblua5_1" "zenity" "xdg-utils" "gcc" "make")
  63. FEDORA_DEPS=("rpm-build" "git" "mono-devel" "freetype" "openal-soft" "SDL2" "libgdiplus-devel" "libcurl" "compat-lua" "zenity" "xdg-utils" "gcc" "make")
  64. #*********************************************************************************************************
  65. ## PRE-CHECK
  66. #
  67. # 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.
  68. if [ ! $BASH_CHECK = "bash" ]; then
  69. echo "
  70. Please run this script using bash (/usr/bin/bash).
  71. "
  72. exit 1
  73. fi
  74. # Check if we are root or not. If yes, then terminate the script.
  75. if [[ $UID = 0 ]]; then
  76. 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"
  77. exit 1
  78. fi
  79. #If package dir exists already, delete it.
  80. if [ -d "$HOME/openra-master/" ]; then
  81. rm -rf "$HOME/openra-master"
  82. fi
  83. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  84. #If deb package exists already, delete it.
  85. if [ -f $HOME/$PACKAGE_NAME*.deb ]; then
  86. rm -f $HOME/$PACKAGE_NAME*.deb
  87. fi
  88. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  89. if [ -f $HOME/$PACKAGE_NAME*.rpm ]; then
  90. rm -f $HOME/$PACKAGE_NAME*.rpm
  91. fi
  92. fi
  93. # Stop execution if we encounter an error
  94. set -e
  95. #*********************************************************************************************************
  96. ## PART 1/7
  97. #
  98. ## Installation of OpenRA compilation dependencies and user notification message
  99. echo -e "\n$bold_in***Welcome Comrade*** $out\n"
  100. echo -e "This script compiles and installs OpenRA from source with Tiberian Sun & Red Alert 2. Optionally Dune 2 can be installed, too.\n
  101. - The script is NOT made by the developers of OpenRA and may contain bugs.
  102. - The script creates an installation package using OpenRA source code and additional Red Alert 2 (and optionally Dune 2) mod files from Github.\n\nNOTE: As the development of OpenRA & Red Alert 2 (& Dune 2) continues, this script will likely become unusable some day. Please, feel free to modify it if necessary."
  103. if [[ $DISTRO =~ $UBUNTU ]]; then
  104. echo -e "$line_in\nThe script has been tested on:\n\nDistribution\t\tStatus$out\nUbuntu 16.10$green_in\t\tOK$out\nUbuntu 16.04 LTS$green_in\tOK$out\nUbuntu 15.10$yellow_in\t\tOK (missing dependencies?)$out\nUbuntu 15.04 LTS$green_in\tOK$out\nUbuntu 14.10$yellow_in\t\tOK (missing dependencies?)$out\nUbuntu 14.04 LTS$yellow_in\tOK (missing dependencies?)$out\nLinux Mint 18$green_in\t\tOK$out\nLinux Mint 17.3$green_in\t\tOK$out\nLinux Mint 17.2$green_in\t\tOK$out\nLinux Mint 17.1$yellow_in\t\tOK (missing dependencies?)$out\nLinux Mint 16$red_in\t\tFailure$out$dim_in (missing dependencies)$out\n"
  105. elif [[ $DISTRO =~ $DEBIAN ]]; then
  106. echo -e "$line_in\nThe script has been tested on:\n\nDistribution\t\tStatus$out\nDebian 8.3 $green_in\t\tOK$out\n"
  107. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  108. echo -e "$line_in\nThe script has been tested on:\n\nDistribution\t\tStatus$out\nOpenSUSE Tumbleweed $green_in\tOK$out\nOpenSUSE Leap 42.1 $green_in\tOK$out\nOpenSUSE 13.2 $green_in\t\tOK$out\nOpenSUSE 13.1 $red_in\t\tFailure$out$dim_in (missing dependencies)$out\n"
  109. elif [[ $DISTRO =~ $FEDORA ]]; then
  110. echo -e "$line_in\nThe script has been tested on:\n\nDistribution\t\tStatus$out\nFedora 23 $green_in\t\tOK$out\nFedora 22 $green_in\t\tOK$out\n"
  111. fi
  112. echo -e "You are using $RELEASE.\n"
  113. read -r -p "Do you want to continue? [y/N] " response
  114. if [[ $(echo $response | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  115. sleep 1
  116. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  117. 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"
  118. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  119. 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 rpm 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(automatic installation of rpm packages)$out\n"
  120. fi
  121. read -r -p "Please type 1 or 2 (Default: 2): " number
  122. attempts=5
  123. while [[ ! $(echo $number | sed 's/ //g') -eq 1 && ! $(echo $number | sed 's/ //g') -eq 2 ]]; do
  124. attempts=$(($attempts -1))
  125. if [[ $attempts -eq 0 ]]; then
  126. echo -e "\nMaximum attempts reached. Aborting.\n"
  127. break
  128. fi
  129. echo -e "\nInvalid answer. Expected number 1 or 2. Please type again ($attempts attempts left):\n"
  130. read number
  131. let number=$(echo $number | sed 's/ //g')
  132. done
  133. sleep 1
  134. echo -e "\nDune 2 -- Question\n"
  135. read -r -p "Additionally, Dune 2 can be installed, too. Do you want to install it? [y/N] (Default: y) " dune2_install
  136. if [[ ! $(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | wc -l) -eq 0 ]]; then
  137. echo -e "\nHotfixes -- Question\n"
  138. echo -e "Use custom hotfixes if added by the user (Default: No)?\nNOTE: If you choose YES (y), be aware that your OpenRA/RA2 version will likely not be compatible with the other players unless they've applied exactly same hotfixes in their game versions, too!"
  139. echo -e "\nAvailable hotfixes are:\n"
  140. echo -e $green_in$(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | sed -e 's/.*\///' -e 's/\.[^\.]*$//')$out
  141. echo -e "\nMore information about hotfixes: https://github.com/Fincer/openra-tibsunra2/#about-patches--hotfixes\n"
  142. read -r -p "Use these hotfixes? [y/N] " hotfixes
  143. if [[ $(echo $hotfixes | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  144. echo -e "\nHotfixes applied. Continuing."
  145. sleep 2
  146. else
  147. echo -e "\nHotfixes ignored and skipped. Continuing."
  148. sleep 2
  149. fi
  150. fi
  151. if [[ $number -eq 1 ]]; then
  152. METHOD=''
  153. echo -e "\nSelected installation method:$bold_in Manual$out"
  154. else
  155. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]] || [[ $DISTRO =~ $FEDORA ]]; then
  156. METHOD=-y
  157. echo -e "\nSelected installation method:$bold_in Automatic$out"
  158. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  159. METHOD='--non-interactive --no-gpg-checks'
  160. echo -e "\nSelected installation method:$bold_in Automatic$out"
  161. fi
  162. fi
  163. if [[ $(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | wc -l) -eq 0 ]]; then
  164. echo -e "Available hotfixes:$bold_in None$out"
  165. else
  166. if [[ $(echo $hotfixes | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  167. echo -e "Use hotfixes:$bold_in Yes$out"
  168. else
  169. echo -e "Use hotfixes:$bold_in No$out"
  170. fi
  171. fi
  172. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  173. echo -e "Install Dune 2:$bold_in Yes$out"
  174. else
  175. echo -e "Install Dune 2:$bold_in No$out"
  176. fi
  177. sleep 3
  178. ################################################
  179. ##Sudo/Root check function for dependency packages installation process
  180. function sudocheck() {
  181. if [ $SUDO_CHECK -eq 0 ]; then
  182. if [[ -z $METHOD ]]; then
  183. echo -e "OpenRA 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"
  184. else
  185. echo -e "OpenRA 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"
  186. fi
  187. sudo echo -e "\nRoot password OK."
  188. sleep 1
  189. else
  190. true
  191. fi
  192. }
  193. ################################################
  194. ## PART 1/7
  195. #
  196. ## Install missing OpenRA dependencies for compilation process if needed.
  197. echo -e "$bold_in\n1/7 ***OpenRA build dependencies***\n$out"
  198. sleep 2
  199. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  200. if [[ ! $(dpkg-query -W -f='${Status}' "${DEBIAN_DEPS[@]}" | grep -c "not-installed") -eq 0 ]]; then #Find all dependency packages. If 'not-installed' string has match(es), then
  201. echo -e "Some dependencies are missing.\n"
  202. sudocheck
  203. echo -e "Updating package lists with APT.\n"
  204. sleep 2
  205. sudo apt-get update || true
  206. echo -e "Installing required OpenRA build dependencies."
  207. sleep 4
  208. sudo apt-get $METHOD install ${DEBIAN_DEPS[@]}
  209. mozroots --import --sync && \
  210. sudo apt-key update || exit 1
  211. else
  212. echo -e "All dependencies are met. Continuing."
  213. fi
  214. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  215. if [[ ! $(zypper info "${OPENSUSE_DEPS[@]}" | grep -c "Installed: No") -eq 0 ]]; then #Find all dependency packages. If 'Installed: No' string has match(es), then
  216. echo -e "Some dependencies are missing.\n"
  217. sudocheck
  218. if [[ ! $RELEASE = "openSUSE Leap 42.1" ]] || [[ ! $RELEASE = "openSUSE Tumbleweed" ]]; then
  219. sudo zypper $METHOD install ${OPENSUSE_DEPS[@]}
  220. else
  221. sudo zypper $METHOD install ${OPENSUSE_DEPS[@]}
  222. fi
  223. mozroots --import --sync
  224. else
  225. echo -e "All dependencies are met. Continuing."
  226. fi
  227. elif [[ $DISTRO =~ $FEDORA ]]; then
  228. if [[ ! $(dnf list installed "${FEDORA_DEPS[@]}" 2>&1 | grep -c "Error") -eq 0 ]]; then #Find all dependency packages. If "Error" string has match(es), then
  229. echo -e "Some dependencies are missing.\n"
  230. sudocheck
  231. sudo dnf $METHOD install ${FEDORA_DEPS[@]}
  232. cd /etc/yum.repos.d/
  233. if [[ $RELEASE = "Fedora 23" ]]; then
  234. sudo wget http://download.opensuse.org/repositories/games:openra/Fedora_23/games:openra.repo
  235. sudo dnf $METHOD --best --allowerasing install mono-core
  236. elif [[ $RELEASE = "Fedora 22" ]]; then
  237. sudo wget http://download.opensuse.org/repositories/games:openra/Fedora_22/games:openra.repo
  238. sudo dnf $METHOD --best --allowerasing install mono-core
  239. fi
  240. cd $WORKING_DIR
  241. mozroots --import --sync
  242. else
  243. echo -e "All dependencies are met. Continuing."
  244. fi
  245. fi
  246. sleep 2
  247. #*********************************************************************************************************
  248. ## PART 2/7 - 1
  249. #
  250. ## Download the latest OpenRA & Red Alert 2 source files from Github, create build directories to the user's home directory.
  251. ## Once Red Alert 2 source files have been downloaded, move them to the OpenRA parent source directory.
  252. ## Add several missing directories for Red Alert 2.
  253. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  254. echo -e "$bold_in\n2/7 ***Downloading OpenRA source code & Red Alert 2 + Dune 2 mod files from Github***\n$out"
  255. else
  256. echo -e "$bold_in\n2/7 ***Downloading OpenRA source code & Red Alert 2 mod files from Github***\n$out"
  257. fi
  258. sleep 2
  259. echo -e "Part 1 (OpenRA source code):\n"
  260. mkdir -p $HOME/openra-master/{$PACKAGE,ra2} && \
  261. git clone -b bleed https://github.com/OpenRA/OpenRA.git $HOME/openra-master/$PACKAGE
  262. echo -e "\nPart 2 (Red Alert 2 mod files):\n"
  263. git clone -b master https://github.com/OpenRA/ra2.git $HOME/openra-master/ra2 && \
  264. mv $HOME/openra-master/ra2/OpenRA.Mods.RA2 $HOME/openra-master/$PACKAGE && \
  265. mv $HOME/openra-master/ra2 $HOME/openra-master/$PACKAGE/mods/
  266. if [ ! -d "$RA2_MISSINGDIR1" ]; then
  267. mkdir "$RA2_MISSINGDIR1"
  268. fi
  269. if [ ! -d "$RA2_MISSINGDIR2" ]; then
  270. mkdir "$RA2_MISSINGDIR2"
  271. fi
  272. #*********************************************************************************************************
  273. ## OPTIONAL: PART 2/7 - 2
  274. #
  275. ## Download the latest Dune 2 mod files from Github
  276. ## Once Dune 2 source files have been downloaded, move them to the OpenRA parent source directory.
  277. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  278. echo -e "\nPart 3 (Dune 2 mod files):\n"
  279. git clone -b master https://github.com/OpenRA/d2.git $HOME/openra-master/d2 && \
  280. mv $HOME/openra-master/d2/OpenRA.Mods.D2 $HOME/openra-master/$PACKAGE && \
  281. mv $HOME/openra-master/d2 $HOME/openra-master/$PACKAGE/mods/
  282. fi
  283. #*********************************************************************************************************
  284. ## Apply patches & hotfixes
  285. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  286. #Copy all patch files excluding the one which modifies 'mods' string in the Linux Makefile (double patching it will cause conflicts between D2 and RA2)
  287. cp ./data/patches/linux/*.patch $HOME/openra-master/
  288. rm $HOME/openra-master/linux-ra2-make-modstrings.patch
  289. else
  290. #Copy all patch files excluding the ones for Dune 2.
  291. cp ./data/patches/linux/*.patch $HOME/openra-master/
  292. rm $HOME/openra-master/linux-d2*.patch
  293. fi
  294. if [[ $(echo $hotfixes | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  295. cp ./data/hotfixes/linux/*.patch $HOME/openra-master/
  296. fi
  297. #*********************************************************************************************************
  298. ## PART 3/7
  299. #
  300. ## Patch several OpenRA source files (Makefile and such) for Tiberian Sun & Red Alert 2
  301. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  302. echo -e "$bold_in\n3/7 ***Preparing OpenRA source files for Dune 2, Tiberian Sun & Red Alert 2***\n$out"
  303. else
  304. echo -e "$bold_in\n3/7 ***Preparing OpenRA source files for Tiberian Sun & Red Alert 2***\n$out"
  305. fi
  306. sleep 2
  307. for i in $HOME/openra-master/*.patch; do patch -d $HOME/openra-master/$PACKAGE -Np1 < $i; done
  308. # Get version number for Red Alert 2 mod files (Github)
  309. RA2_VERSION=git-$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  310. sed -i "s/Version: {DEV_VERSION}/Version: $RA2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/ra2/mod.yaml
  311. sed -i "s/maps\/ra2\/{DEV_VERSION}/maps\/ra2\/$RA2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/ra2/mod.yaml
  312. # Get OpenRA version number for package (Github)
  313. OPENRA_PKGVERSION=$(git ls-remote https://github.com/OpenRA/OpenRA.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  314. RA2_PKGVERSION=$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  315. # Get version number for Dune 2 mod files if the mod is about to be installed (Github)
  316. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  317. D2_VERSION=git-$(git ls-remote https://github.com/OpenRA/d2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  318. sed -i "s/Version: {DEV_VERSION}/Version: $D2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/d2/mod.yaml
  319. sed -i "s/maps\/ra2\/{DEV_VERSION}/maps\/ra2\/$D2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/d2/mod.yaml
  320. D2_PKGVERSION=$(git ls-remote https://github.com/OpenRA/d2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  321. fi
  322. #*********************************************************************************************************
  323. ## PART 4/7
  324. #
  325. ## Compile the game
  326. ##Change OpenRA version as it is in Github & change PACKAGE variable after that
  327. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  328. PACKAGE_VERSION=$(echo $OPENRA_PKGVERSION$RA2_PKGVERSION$D2_PKGVERSION | sed 's/[A-Za-z]*//g') #Remove letters for dh_make
  329. else
  330. PACKAGE_VERSION=$(echo $OPENRA_PKGVERSION$RA2_PKGVERSION | sed 's/[A-Za-z]*//g') #Remove letters for dh_make
  331. fi
  332. mv $HOME/openra-master/$PACKAGE $HOME/openra-master/$PACKAGE-$PACKAGE_VERSION
  333. PACKAGE=$PACKAGE_NAME-$PACKAGE_VERSION
  334. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  335. echo -e "$bold_in\n4/7 ***Starting OpenRA compilation with Dune 2, Tiberian Sun & Red Alert 2***
  336. $out"
  337. else
  338. echo -e "$bold_in\n4/7 ***Starting OpenRA compilation with Tiberian Sun & Red Alert 2***$out"
  339. fi
  340. sleep 2
  341. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  342. cd $HOME/openra-master/$PACKAGE && \
  343. make version && \
  344. make dependencies && \
  345. make all [DEBUG=false]
  346. ##Delete buildtime files:
  347. rm $HOME/openra-master/$PACKAGE/mods/cnc/OpenRA.Mods.Cnc.dll.mdb
  348. rm $HOME/openra-master/$PACKAGE/mods/common/OpenRA.Mods.Common.dll.mdb
  349. rm $HOME/openra-master/$PACKAGE/mods/d2k/OpenRA.Mods.D2k.dll.mdb
  350. rm $HOME/openra-master/$PACKAGE/mods/ra/OpenRA.Mods.RA.dll.mdb
  351. rm $HOME/openra-master/$PACKAGE/mods/ra2/{.gitattributes,.gitignore,.travis.yml,build.cake,OpenRA.Mods.RA2.dll.mdb,make.cmd,make.ps1,makefile}
  352. rm $HOME/openra-master/$PACKAGE/mods/ts/OpenRA.Mods.TS.dll.mdb
  353. if [[ ! $(echo $dune2_install | sed 's/ //g') =~ ^([nN][oO]|[nN])$ ]]; then
  354. rm $HOME/openra-master/$PACKAGE/mods/d2/OpenRA.Mods.D2.dll.mdb
  355. fi
  356. echo -e "$bold_in\n5/7 ***Preparing OpenRA deb package. This takes a while. Please wait.***\n$out"
  357. dh_make --createorig -s -y && \
  358. 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 && \
  359. 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 && \
  360. 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 && \
  361. sed -i 's/ <insert long description, indented with spaces>/ ./g' $HOME/openra-master/$PACKAGE/debian/control && \
  362. dpkg-buildpackage -rfakeroot -b -nc -uc -us
  363. #*********************************************************************************************************
  364. ## PART 6/7
  365. #
  366. ## Remove temporary OpenRA build files & directories
  367. echo -e "$bold_in\n6/7 ***Compilation process completed. Moving compiled deb package into '$HOME'***\n$out"
  368. sleep 2
  369. mv $HOME/openra-master/$PACKAGE_NAME*.deb $HOME
  370. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  371. echo -e "$bold_in\n5/7 ***Compiling OpenRA rpm package.***\n$out"
  372. mkdir -p $HOME/openra-master/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
  373. cp ./data/linux/opensuse/openra.spec $HOME/openra-master/rpmbuild/SPECS/
  374. cp ./data/linux/opensuse/{GeoLite2-Country.mmdb.gz,thirdparty.tar.gz} $HOME/openra-master/rpmbuild/SOURCES/
  375. ##Change OpenRA + RA2 (& Dune 2) version as it is in Github
  376. sed -i "s/Version: 1/Version: $PACKAGE_VERSION/g" $HOME/openra-master/rpmbuild/SPECS/openra.spec
  377. cd $HOME/openra-master
  378. tar -czf $HOME/openra-master/rpmbuild/SOURCES/$PACKAGE.tar.gz ./$PACKAGE
  379. cd $WORKING_DIR
  380. rpmbuild --define "_topdir $HOME/openra-master/rpmbuild" -bb --clean $HOME/openra-master/rpmbuild/SPECS/openra.spec
  381. echo -e "$bold_in\n6/7 ***Compilation process completed. Moving compiled rpm package into '$HOME'***\n$out"
  382. sleep 2
  383. mv $HOME/openra-master/rpmbuild/RPMS/noarch/$PACKAGE_NAME*.rpm $HOME
  384. fi
  385. echo -e "Removing temporary files."
  386. rm -rf $HOME/openra-master
  387. #*********************************************************************************************************
  388. ## PART 7/7
  389. #
  390. ## Install OpenRA
  391. echo -e "$bold_in\n7/7 ***Starting OpenRA installation process***\n$out"
  392. sleep 2
  393. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  394. if [ $PKG4_CHECK -eq 1 ] || [ $PKG5_CHECK -eq 1 ] || [ $PKG6_CHECK -eq 1 ] ; then
  395. 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"
  396. else
  397. if [[ $number -eq 1 ]]; then
  398. read -r -p "Install '$PACKAGE_NAME' now? [y/N] " response4
  399. if [[ $(echo $response4 | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  400. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  401. else
  402. echo -e "\nPlease install '$PACKAGE_NAME' manually. You find the compiled package in '$HOME'."
  403. sleep 2
  404. fi
  405. else
  406. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  407. fi
  408. fi
  409. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  410. if [ $PKG1_CHECK -eq 1 ] || [ $PKG2_CHECK -eq 1 ] || [ $PKG3_CHECK -eq 1 ] ; then
  411. 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 rpm package can be found in '$HOME'.\n"
  412. else
  413. if [[ $number -eq 1 ]]; then
  414. read -r -p "Install '$PACKAGE_NAME' now? [y/N] " response4
  415. if [[ $(echo $response4 | sed 's/ //g') =~ ^([yY][eE][sS]|[yY])$ ]]; then
  416. if [[ $DISTRO =~ $FEDORA ]]; then
  417. sudo dnf $METHOD --best --allowerasing install $HOME/$PACKAGE_NAME*.rpm
  418. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  419. sudo zypper $METHOD install $HOME/$PACKAGE_NAME*.rpm
  420. fi
  421. else
  422. echo -e "\nPlease install '$PACKAGE_NAME' manually. You find the compiled package in '$HOME'."
  423. sleep 2
  424. fi
  425. else
  426. if [[ $DISTRO =~ $FEDORA ]]; then
  427. sudo dnf $METHOD --best --allowerasing install $HOME/$PACKAGE_NAME*.rpm
  428. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  429. sudo zypper $METHOD install $HOME/$PACKAGE_NAME*.rpm
  430. fi
  431. fi
  432. fi
  433. fi
  434. #*********************************************************************************************************
  435. else
  436. echo -e "\nAborted.\n"
  437. fi