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.

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