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.

535 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 [[ $response =~ ^([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. sleep 1
  123. echo -e "\nDune 2 -- Question\n"
  124. read -r -p "Additionally, Dune 2 can be installed, too. Do you want to install it? [y/N] (Default: y) " dune2_install
  125. if [[ ! $(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | wc -l) -eq 0 ]]; then
  126. echo -e "\nHotfixes -- Question\n"
  127. 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!"
  128. echo -e "\nAvailable hotfixes are:\n"
  129. echo -e $green_in$(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | sed -e 's/.*\///' -e 's/\.[^\.]*$//')$out
  130. echo -e "\nMore information about hotfixes: https://github.com/Fincer/openra-tibsunra2/#about-patches--hotfixes\n"
  131. read -r -p "Use these hotfixes? [y/N] " hotfixes
  132. if [[ $hotfixes =~ ^([yY][eE][sS]|[yY])$ ]]; then
  133. echo -e "\nHotfixes applied. Continuing."
  134. sleep 2
  135. else
  136. echo -e "\nHotfixes ignored and skipped. Continuing."
  137. sleep 2
  138. fi
  139. fi
  140. if [[ $number -eq 1 ]]; then
  141. METHOD=''
  142. echo -e "\nSelected installation method:$bold_in Manual$out"
  143. else
  144. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]] || [[ $DISTRO =~ $FEDORA ]]; then
  145. METHOD=-y
  146. echo -e "\nSelected installation method:$bold_in Automatic$out"
  147. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  148. METHOD='--non-interactive --no-gpg-checks'
  149. echo -e "\nSelected installation method:$bold_in Automatic$out"
  150. fi
  151. fi
  152. if [[ $(find $WORKING_DIR/data/hotfixes/linux/ -type f -iname *.patch | wc -l) -eq 0 ]]; then
  153. echo -e "Available hotfixes:$bold_in None$out"
  154. else
  155. if [[ $hotfixes =~ ^([yY][eE][sS]|[yY])$ ]]; then
  156. echo -e "Use hotfixes:$bold_in Yes$out"
  157. else
  158. echo -e "Use hotfixes:$bold_in No$out"
  159. fi
  160. fi
  161. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  162. echo -e "Install Dune 2:$bold_in Yes$out"
  163. else
  164. echo -e "Install Dune 2:$bold_in No$out"
  165. fi
  166. sleep 3
  167. ################################################
  168. ##Sudo/Root check function for dependency packages installation process
  169. function sudocheck() {
  170. if [ $SUDO_CHECK -eq 0 ]; then
  171. if [[ -z $METHOD ]]; then
  172. 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"
  173. else
  174. 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"
  175. fi
  176. sudo echo -e "\nRoot password OK."
  177. sleep 1
  178. else
  179. true
  180. fi
  181. }
  182. ################################################
  183. ## PART 1/7
  184. #
  185. ## Install missing OpenRA dependencies for compilation process if needed.
  186. echo -e "$bold_in\n1/7 ***OpenRA build dependencies***\n$out"
  187. sleep 2
  188. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  189. 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
  190. echo -e "Some dependencies are missing.\n"
  191. sudocheck
  192. echo -e "Updating package lists with APT.\n"
  193. sleep 2
  194. sudo apt-get update || true
  195. echo -e "Installing required OpenRA build dependencies."
  196. sleep 4
  197. sudo apt-get $METHOD install ${DEBIAN_DEPS[@]}
  198. mozroots --import --sync && \
  199. sudo apt-key update || exit 1
  200. else
  201. echo -e "All dependencies are met. Continuing."
  202. fi
  203. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  204. if [[ ! $(zypper info "${OPENSUSE_DEPS[@]}" | grep -c "Installed: No") -eq 0 ]]; then #Find all dependency packages. If 'Installed: No' string has match(es), then
  205. echo -e "Some dependencies are missing.\n"
  206. sudocheck
  207. if [[ ! $RELEASE = "openSUSE Leap 42.1" ]] || [[ ! $RELEASE = "openSUSE Tumbleweed" ]]; then
  208. sudo zypper $METHOD install ${OPENSUSE_DEPS[@]}
  209. else
  210. sudo zypper $METHOD install ${OPENSUSE_DEPS[@]}
  211. fi
  212. mozroots --import --sync
  213. else
  214. echo -e "All dependencies are met. Continuing."
  215. fi
  216. elif [[ $DISTRO =~ $FEDORA ]]; then
  217. 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
  218. echo -e "Some dependencies are missing.\n"
  219. sudocheck
  220. sudo dnf $METHOD install ${FEDORA_DEPS[@]}
  221. cd /etc/yum.repos.d/
  222. if [[ $RELEASE = "Fedora 23" ]]; then
  223. sudo wget http://download.opensuse.org/repositories/games:openra/Fedora_23/games:openra.repo
  224. sudo dnf $METHOD --best --allowerasing install mono-core
  225. elif [[ $RELEASE = "Fedora 22" ]]; then
  226. sudo wget http://download.opensuse.org/repositories/games:openra/Fedora_22/games:openra.repo
  227. sudo dnf $METHOD --best --allowerasing install mono-core
  228. fi
  229. cd $WORKING_DIR
  230. mozroots --import --sync
  231. else
  232. echo -e "All dependencies are met. Continuing."
  233. fi
  234. fi
  235. sleep 2
  236. #*********************************************************************************************************
  237. ## PART 2/7 - 1
  238. #
  239. ## Download the latest OpenRA & Red Alert 2 source files from Github, create build directories to the user's home directory.
  240. ## Once Red Alert 2 source files have been downloaded, move them to the OpenRA parent source directory.
  241. ## Add several missing directories for Red Alert 2.
  242. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  243. echo -e "$bold_in\n2/7 ***Downloading OpenRA source code & Red Alert 2 + Dune 2 mod files from Github***\n$out"
  244. else
  245. echo -e "$bold_in\n2/7 ***Downloading OpenRA source code & Red Alert 2 mod files from Github***\n$out"
  246. fi
  247. sleep 2
  248. echo -e "Part 1 (OpenRA source code):\n"
  249. mkdir -p $HOME/openra-master/{$PACKAGE,ra2} && \
  250. git clone -b bleed https://github.com/OpenRA/OpenRA.git $HOME/openra-master/$PACKAGE
  251. echo -e "\nPart 2 (Red Alert 2 mod files):\n"
  252. git clone -b master https://github.com/OpenRA/ra2.git $HOME/openra-master/ra2 && \
  253. mv $HOME/openra-master/ra2/OpenRA.Mods.RA2 $HOME/openra-master/$PACKAGE && \
  254. mv $HOME/openra-master/ra2 $HOME/openra-master/$PACKAGE/mods/
  255. if [ ! -d "$RA2_MISSINGDIR1" ]; then
  256. mkdir "$RA2_MISSINGDIR1"
  257. fi
  258. if [ ! -d "$RA2_MISSINGDIR2" ]; then
  259. mkdir "$RA2_MISSINGDIR2"
  260. fi
  261. #*********************************************************************************************************
  262. ## OPTIONAL: PART 2/7 - 2
  263. #
  264. ## Download the latest Dune 2 mod files from Github
  265. ## Once Dune 2 source files have been downloaded, move them to the OpenRA parent source directory.
  266. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  267. echo -e "\nPart 3 (Dune 2 mod files):\n"
  268. git clone -b master https://github.com/OpenRA/d2.git $HOME/openra-master/d2 && \
  269. mv $HOME/openra-master/d2/OpenRA.Mods.D2 $HOME/openra-master/$PACKAGE && \
  270. mv $HOME/openra-master/d2 $HOME/openra-master/$PACKAGE/mods/
  271. fi
  272. #*********************************************************************************************************
  273. ## Apply patches & hotfixes
  274. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  275. #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)
  276. cp ./data/patches/linux/*.patch $HOME/openra-master/
  277. rm $HOME/openra-master/linux-ra2-make-modstrings.patch
  278. else
  279. #Copy all patch files excluding the ones for Dune 2.
  280. cp ./data/patches/linux/*.patch $HOME/openra-master/
  281. rm $HOME/openra-master/linux-d2*.patch
  282. fi
  283. if [[ $hotfixes =~ ^([yY][eE][sS]|[yY])$ ]]; then
  284. cp ./data/hotfixes/linux/*.patch $HOME/openra-master/
  285. fi
  286. #*********************************************************************************************************
  287. ## PART 3/7
  288. #
  289. ## Patch several OpenRA source files (Makefile and such) for Tiberian Sun & Red Alert 2
  290. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  291. echo -e "$bold_in\n3/7 ***Preparing OpenRA source files for Dune 2, Tiberian Sun & Red Alert 2***\n$out"
  292. else
  293. echo -e "$bold_in\n3/7 ***Preparing OpenRA source files for Tiberian Sun & Red Alert 2***\n$out"
  294. fi
  295. sleep 2
  296. for i in $HOME/openra-master/*.patch; do patch -d $HOME/openra-master/$PACKAGE -Np1 < $i; done
  297. # Get version number for Red Alert 2 mod files (Github)
  298. RA2_VERSION=git-$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  299. sed -i "s/Version: {DEV_VERSION}/Version: $RA2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/ra2/mod.yaml
  300. sed -i "s/maps\/ra2\/{DEV_VERSION}/maps\/ra2\/$RA2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/ra2/mod.yaml
  301. # Get OpenRA version number for package (Github)
  302. OPENRA_PKGVERSION=$(git ls-remote https://github.com/OpenRA/OpenRA.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  303. RA2_PKGVERSION=$(git ls-remote https://github.com/OpenRA/ra2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  304. # Get version number for Dune 2 mod files if the mod is about to be installed (Github)
  305. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  306. D2_VERSION=git-$(git ls-remote https://github.com/OpenRA/d2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  307. sed -i "s/Version: {DEV_VERSION}/Version: $D2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/d2/mod.yaml
  308. sed -i "s/maps\/ra2\/{DEV_VERSION}/maps\/ra2\/$D2_VERSION/g" $HOME/openra-master/$PACKAGE/mods/d2/mod.yaml
  309. D2_PKGVERSION=$(git ls-remote https://github.com/OpenRA/d2.git | head -1 | sed "s/HEAD//" | sed 's/^\(.\{7\}\).*/\1/')
  310. fi
  311. #*********************************************************************************************************
  312. ## PART 4/7
  313. #
  314. ## Compile the game
  315. ##Change OpenRA version as it is in Github & change PACKAGE variable after that
  316. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  317. mv $HOME/openra-master/$PACKAGE $HOME/openra-master/$PACKAGE-$OPENRA_PKGVERSION$RA2_PKGVERSION$D2_PKGVERSION
  318. PACKAGE=$PACKAGE-$OPENRA_PKGVERSION$RA2_PKGVERSION$D2_PKGVERSION
  319. else
  320. mv $HOME/openra-master/$PACKAGE $HOME/openra-master/$PACKAGE-$OPENRA_PKGVERSION$RA2_PKGVERSION
  321. PACKAGE=$PACKAGE_NAME-$OPENRA_PKGVERSION$RA2_PKGVERSION
  322. fi
  323. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  324. echo -e "$bold_in\n4/7 ***Starting OpenRA compilation with Dune 2, Tiberian Sun & Red Alert 2***
  325. $out"
  326. else
  327. echo -e "$bold_in\n4/7 ***Starting OpenRA compilation with Tiberian Sun & Red Alert 2***$out"
  328. fi
  329. sleep 2
  330. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  331. cd $HOME/openra-master/$PACKAGE && \
  332. make version && \
  333. make dependencies && \
  334. make all [DEBUG=false]
  335. ##Delete buildtime files:
  336. rm $HOME/openra-master/$PACKAGE/mods/cnc/OpenRA.Mods.Cnc.dll.mdb
  337. rm $HOME/openra-master/$PACKAGE/mods/common/OpenRA.Mods.Common.dll.mdb
  338. rm $HOME/openra-master/$PACKAGE/mods/d2k/OpenRA.Mods.D2k.dll.mdb
  339. rm $HOME/openra-master/$PACKAGE/mods/ra/OpenRA.Mods.RA.dll.mdb
  340. rm $HOME/openra-master/$PACKAGE/mods/ra2/{.gitattributes,.gitignore,.travis.yml,build.cake,OpenRA.Mods.RA2.dll.mdb,make.cmd,make.ps1,makefile}
  341. rm $HOME/openra-master/$PACKAGE/mods/ts/OpenRA.Mods.TS.dll.mdb
  342. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  343. rm $HOME/openra-master/$PACKAGE/mods/d2/OpenRA.Mods.D2.dll.mdb
  344. fi
  345. # rm $HOME/openra-master/$PACKAGE/{SharpFont.dll.config,SDL2-CS.dll.config,OpenAL-CS.dll.config,Eluant.dll.config}
  346. ##Can't remove .config files at this moment due to deb packaging mechanism!
  347. echo -e "$bold_in\n5/7 ***Preparing OpenRA deb package. This takes a while. Please wait.***\n$out"
  348. dh_make --createorig -s -y && \
  349. 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 && \
  350. 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 && \
  351. 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 && \
  352. sed -i 's/ <insert long description, indented with spaces>/ ./g' $HOME/openra-master/$PACKAGE/debian/control && \
  353. dpkg-buildpackage -rfakeroot -b -nc -uc -us
  354. #*********************************************************************************************************
  355. ## PART 6/7
  356. #
  357. ## Remove temporary OpenRA build files & directories
  358. echo -e "$bold_in\n6/7 ***Compilation process completed. Moving compiled deb package into '$HOME'***\n$out"
  359. sleep 2
  360. mv $HOME/openra-master/$PACKAGE_NAME*.deb $HOME
  361. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  362. echo -e "$bold_in\n5/7 ***Compiling OpenRA rpm package.***\n$out"
  363. mkdir -p $HOME/openra-master/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
  364. cp ./data/linux/opensuse/openra.spec $HOME/openra-master/rpmbuild/SPECS/
  365. cp ./data/linux/opensuse/{GeoLite2-Country.mmdb.gz,thirdparty.tar.gz} $HOME/openra-master/rpmbuild/SOURCES/
  366. ##Change OpenRA + RA2 (& Dune 2) version as it is in Github
  367. if [[ ! $dune2_install =~ ^([nN][oO]|[nN])$ ]]; then
  368. sed -i "s/Version: 1/Version: $OPENRA_PKGVERSION$RA2_PKGVERSION$D2_PKGVERSION/g" $HOME/openra-master/rpmbuild/SPECS/openra.spec
  369. else
  370. sed -i "s/Version: 1/Version: $OPENRA_PKGVERSION$RA2_PKGVERSION/g" $HOME/openra-master/rpmbuild/SPECS/openra.spec
  371. fi
  372. cd $HOME/openra-master
  373. tar -czf $HOME/openra-master/rpmbuild/SOURCES/$PACKAGE.tar.gz ./$PACKAGE
  374. cd $WORKING_DIR
  375. rpmbuild --define "_topdir $HOME/openra-master/rpmbuild" -bb --clean $HOME/openra-master/rpmbuild/SPECS/openra.spec
  376. echo -e "$bold_in\n6/7 ***Compilation process completed. Moving compiled rpm package into '$HOME'***\n$out"
  377. sleep 2
  378. mv $HOME/openra-master/rpmbuild/RPMS/noarch/$PACKAGE_NAME*.rpm $HOME
  379. fi
  380. echo -e "Removing temporary files."
  381. rm -rf $HOME/openra-master
  382. #*********************************************************************************************************
  383. ## PART 7/7
  384. #
  385. ## Install OpenRA
  386. echo -e "$bold_in\n7/7 ***Starting OpenRA installation process***\n$out"
  387. sleep 2
  388. if [[ $DISTRO =~ $UBUNTU ]] || [[ $DISTRO =~ $DEBIAN ]]; then
  389. if [ $PKG4_CHECK -eq 1 ] || [ $PKG5_CHECK -eq 1 ] || [ $PKG6_CHECK -eq 1 ] ; then
  390. 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"
  391. else
  392. if [[ $number -eq 1 ]]; then
  393. read -r -p "Install '$PACKAGE_NAME' now? [y/N] " response4
  394. if [[ $response4 =~ ^([yY][eE][sS]|[yY])$ ]]; then
  395. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  396. else
  397. echo -e "\nPlease install '$PACKAGE_NAME' manually. You find the compiled package in '$HOME'."
  398. sleep 2
  399. fi
  400. else
  401. sudo dpkg -i $HOME/$PACKAGE_NAME*.deb
  402. fi
  403. fi
  404. elif [[ $DISTRO =~ $OPENSUSE ]] || [[ $DISTRO =~ $FEDORA ]]; then
  405. if [ $PKG1_CHECK -eq 1 ] || [ $PKG2_CHECK -eq 1 ] || [ $PKG3_CHECK -eq 1 ] ; then
  406. 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"
  407. else
  408. if [[ $number -eq 1 ]]; then
  409. read -r -p "Install '$PACKAGE_NAME' now? [y/N] " response4
  410. if [[ $response4 =~ ^([yY][eE][sS]|[yY])$ ]]; then
  411. if [[ $DISTRO =~ $FEDORA ]]; then
  412. sudo dnf $METHOD --best --allowerasing install $HOME/$PACKAGE_NAME*.rpm
  413. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  414. sudo zypper $METHOD install $HOME/$PACKAGE_NAME*.rpm
  415. fi
  416. else
  417. echo -e "\nPlease install '$PACKAGE_NAME' manually. You find the compiled package in '$HOME'."
  418. sleep 2
  419. fi
  420. else
  421. if [[ $DISTRO =~ $FEDORA ]]; then
  422. sudo dnf $METHOD --best --allowerasing install $HOME/$PACKAGE_NAME*.rpm
  423. elif [[ $DISTRO =~ $OPENSUSE ]]; then
  424. sudo zypper $METHOD install $HOME/$PACKAGE_NAME*.rpm
  425. fi
  426. fi
  427. fi
  428. fi
  429. #*********************************************************************************************************
  430. else
  431. echo -e "\nAborted.\n"
  432. fi