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.

345 lines
16 KiB

  1. #------------------------------------------------------
  2. ## Prepare the script for possible Ctrl+C termination
  3. while ($true)
  4. {
  5. #------------------------------------------------------
  6. ## Test Internet connection
  7. If (-Not (Test-Connection -computer github.com -count 3 -quiet)) {
  8. "`nCan't connect to Github. Please check your internet connection and try again."
  9. exit
  10. }
  11. #------------------------------------------------------
  12. ## Initial script messages
  13. "`n***Welcome Comrade***"
  14. Start-Sleep -s 3
  15. "`nThis script will generate OpenRA with Tiberian Sun & Red Alert 2 for Windows."
  16. Start-Sleep -s 4
  17. "`n- Make sure you have Microsoft .NET Framework 4.5 installed on your computer."
  18. Start-Sleep -s 3
  19. "`n- This script is NOT made by the OpenRA developers and may have bugs."
  20. Start-Sleep -s 3
  21. "`n- If you worry about what the script is doing, you can always check its code (\data\windows\install.ps1)"
  22. Start-Sleep -s 4
  23. "`n- Press Ctrl+C if you want terminate script execution."
  24. Start-Sleep -s 4
  25. "`n***Starting execution sequence now***"
  26. Start-Sleep -s 3
  27. #------------------------------------------------------
  28. ## Hotfix question
  29. If (Test-Path ".\data\hotfixes\windows\*.patch"){
  30. "`n- Hotfixes -- Question`n"
  31. "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!"
  32. "`nAvailable hotfixes are:"
  33. ##List available hotfix files:
  34. get-childitem ".\data\hotfixes\windows\" -recurse | where {$_.extension -eq '.patch'} | format-table Name
  35. "More information about hotfixes: https://github.com/Fincer/openra-tibsunra2/#about-patches--hotfixes`n"
  36. $hotfixes = Read-Host "Use these hotfixes? (y/N)"
  37. if ($hotfixes -eq "y") {
  38. "`nHotfixes applied. Continuing."
  39. } else {
  40. "`nHotfixes ignored and skipped. Continuing."
  41. }
  42. }Else{
  43. "`nAvailable hotfixes: None"
  44. }
  45. Start-Sleep -s 2
  46. #------------------------------------------------------
  47. ## Remove all old source files if they exist
  48. "`nRemoving all old source files that may exist in the data directory."
  49. Remove-Item .\data\windows\OpenRA-bleed -Force -Recurse -ErrorAction SilentlyContinue
  50. Remove-Item .\data\windows\ra2-master -Force -Recurse -ErrorAction SilentlyContinue
  51. Remove-Item .\data\windows\OpenRA-bleed.zip -Force -ErrorAction SilentlyContinue
  52. Remove-Item .\data\windows\ra2-master.zip -Force -ErrorAction SilentlyContinue
  53. Remove-Item .\data\windows\*.html -Force -ErrorAction SilentlyContinue
  54. Remove-Item .\data\windows\*.txt -Force -ErrorAction SilentlyContinue
  55. Remove-Item .\data\windows\*.zip -Force -ErrorAction SilentlyContinue
  56. Remove-Item .\data\windows\*.patch -Force -ErrorAction SilentlyContinue
  57. #------------------------------------------------------
  58. ## Prepare Github environment for downloading the source
  59. [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
  60. $client = New-Object System.Net.WebClient
  61. $client.Headers.Add("Authorization","token 1234567890notarealtoken987654321")
  62. $client.Headers.Add("Accept","application/vnd.github.v3.raw")
  63. #------------------------------------------------------
  64. ## Download OpenRA-bleed source code
  65. "`nDownloading OpenRA source files from Github. Please Stand By."
  66. $client.DownloadFile("https://github.com/OpenRA/OpenRA/archive/bleed.zip?ref=bleed",".\data\windows\OpenRA-bleed.zip")
  67. #------------------------------------------------------
  68. ## Download Red Alert 2 mod files
  69. "`nDownloading Red Alert 2 mod files from Github. Please Stand By."
  70. $client.DownloadFile("https://github.com/OpenRA/ra2/archive/master.zip?ref=master",".\data\windows\ra2-master.zip")
  71. #------------------------------------------------------
  72. ## Unzip OpenRA-bleed source files
  73. "`nUnzipping OpenRA source files into \data\windows folder."
  74. $shell_app=new-object -com shell.application
  75. $filename = "OpenRA-bleed.zip"
  76. $zip_file = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename")
  77. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  78. $destination.Copyhere($zip_file.items())
  79. #------------------------------------------------------
  80. ## Unzip Red Alert 2 mod files
  81. "`nUnzipping Red Alert 2 mod files into \data\windows folder."
  82. $shell_app=new-object -com shell.application
  83. $filename2 = "ra2-master.zip"
  84. $zip_file2 = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename2")
  85. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  86. $destination.Copyhere($zip_file2.items())
  87. #------------------------------------------------------
  88. ## Merge OpenRA source files and Red Alert 2 mod files together
  89. "`nMerging OpenRA source & Red Alert 2 mod files."
  90. Copy-Item -Recurse ".\data\windows\ra2-master\OpenRA.Mods.RA2" ".\data\windows\OpenRA-bleed\OpenRA.Mods.RA2"
  91. Copy-Item -Recurse ".\data\windows\ra2-master" ".\data\windows\OpenRA-bleed\mods\ra2"
  92. Remove-Item -Recurse .\data\windows\ra2-master\*
  93. #------------------------------------------------------
  94. ## Get OpenRA Git version number
  95. "`nRetrieving OpenRA & Red Alert 2 Git version numbers."
  96. $web = New-Object System.Net.WebClient
  97. $web.DownloadFile("https://github.com/OpenRA/OpenRA",".\data\windows\openra-github.html")
  98. $flag=0
  99. Get-Content .\data\windows\openra-github.html |
  100. foreach {
  101. Switch -Wildcard ($_){
  102. "*Latest commit*" {$flag=1}
  103. "*time datetime*" {$flag=0}
  104. }
  105. if ($flag -eq 1){
  106. Out-File .\data\windows\openra-html-stripped.txt -InputObject $_ -Append
  107. }
  108. }
  109. (Get-Content .\data\windows\openra-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\openra-latestcommit.txt
  110. $openra_gitversion = [IO.File]::ReadAllText(".\data\windows\openra-latestcommit.txt").trim("`r`n")
  111. Write-Output "`nOpenRA version: $openra_gitversion"
  112. #This is used in folder name
  113. $openra_folderversion = [IO.File]::ReadAllText(".\data\windows\openra-latestcommit.txt").trim("`r`ngit")
  114. #------------------------------------------------------
  115. ## Get Red Alert 2 Git version number
  116. $web = New-Object System.Net.WebClient
  117. $web.DownloadFile("https://github.com/OpenRA/ra2",".\data\windows\ra2-github.html")
  118. $flag=0
  119. Get-Content .\data\windows\ra2-github.html |
  120. foreach {
  121. Switch -Wildcard ($_){
  122. "*Latest commit*" {$flag=1}
  123. "*time datetime*" {$flag=0}
  124. }
  125. if ($flag -eq 1){
  126. Out-File .\data\windows\ra2-html-stripped.txt -InputObject $_ -Append
  127. }
  128. }
  129. (Get-Content .\data\windows\ra2-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\ra2-latestcommit.txt
  130. $ra2_gitversion = [IO.File]::ReadAllText(".\data\windows\ra2-latestcommit.txt").trim("`r`n")
  131. Write-Output "RA2 version: $ra2_gitversion"
  132. #This is used in folder name
  133. $ra2_folderversion = [IO.File]::ReadAllText(".\data\windows\ra2-latestcommit.txt").trim("`r`ngit")
  134. #------------------------------------------------------
  135. ## Prepare OpenRA source code for Tiberian Sun & Red Alert 2
  136. Copy-Item ".\data\patches\windows\*.patch" ".\data\windows"
  137. if ($hotfixes -eq "y") {
  138. Copy-Item ".\data\hotfixes\windows\*.patch" ".\data\windows"
  139. }
  140. Start-Sleep -s 3
  141. "`nPatching OpenRA source code for Tiberian Sun & Red Alert 2."
  142. cd .\data\windows
  143. "`nFor each time a patch/hotfix is being applied, UAC may ask permission for patch.exe."
  144. $patchcount = (Get-Childitem .\ | where {$_.extension -eq ".patch"} | Measure-Object ).Count;
  145. Write-Output "`nExecuting patch.exe $patchcount times now."
  146. Start-Sleep -s 6
  147. Get-ChildItem .\ -include *.patch -recurse | Foreach ($_) {.\patch.exe -d OpenRA-bleed -Np1 -i $_.fullname }
  148. cd ..
  149. cd ..
  150. #------------------------------------------------------
  151. ## Push version numbers to mod files
  152. # Red Alert
  153. (Get-Content .\data\windows\Openra-bleed\mods\ra\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ra\mod.yaml
  154. # Tiberian Dawn
  155. (Get-Content .\data\windows\Openra-bleed\mods\cnc\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\cnc\mod.yaml
  156. # Dune 2K
  157. (Get-Content .\data\windows\Openra-bleed\mods\d2k\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\d2k\mod.yaml
  158. # Tiberian Sun
  159. (Get-Content .\data\windows\Openra-bleed\mods\ts\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ts\mod.yaml
  160. # Red Alert 2
  161. (Get-Content .\data\windows\Openra-bleed\mods\ra2\mod.yaml) -replace '{DEV_VERSION}',$ra2_gitversion | Set-Content .\data\windows\Openra-bleed\mods\ra2\mod.yaml
  162. # Mod Chooser
  163. (Get-Content .\data\windows\Openra-bleed\mods\modchooser\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\modchooser\mod.yaml
  164. # All
  165. (Get-Content .\data\windows\Openra-bleed\mods\all\mod.yaml) -replace '{DEV_VERSION}',$openra_gitversion | Set-Content .\data\windows\Openra-bleed\mods\all\mod.yaml
  166. #------------------------------------------------------
  167. ## Remove temporary files
  168. Remove-Item .\data\windows\*.html
  169. Remove-Item .\data\windows\*.txt
  170. Remove-Item .\data\windows\*.zip
  171. Remove-Item .\data\windows\*.patch
  172. #------------------------------------------------------
  173. ## Compile OpenRA with Tiberian Sun & Red Alert 2
  174. "`nCompiling OpenRA with Tiberian Sun & Red Alert 2.`n"
  175. cd .\data\windows\OpenRA-bleed\
  176. .\make.cmd dependencies
  177. .\make.cmd all
  178. cd ..
  179. cd ..
  180. cd ..
  181. "`nCopying OpenRA files to the final location. This takes a while. Please wait.`n"
  182. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Platforms.Default
  183. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.Common
  184. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.Cnc
  185. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.D2k
  186. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.RA
  187. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.TS
  188. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Mods.RA2
  189. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Server
  190. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Test
  191. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Utility
  192. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.GameMonitor
  193. Remove-Item -Recurse .\data\windows\OpenRA-bleed\OpenRA.Game
  194. Remove-Item -Recurse .\data\windows\OpenRA-bleed\packaging
  195. Remove-Item -Recurse .\data\windows\OpenRA-bleed\thirdparty
  196. Remove-Item .\data\windows\OpenRA-bleed\.editorconfig
  197. Remove-Item .\data\windows\OpenRA-bleed\.gitattributes
  198. Remove-Item .\data\windows\OpenRA-bleed\.gitignore
  199. Remove-Item .\data\windows\OpenRA-bleed\.kateproject
  200. Remove-Item .\data\windows\OpenRA-bleed\.travis.yml
  201. Remove-Item .\data\windows\OpenRA-bleed\CONTRIBUTING.md
  202. Remove-Item .\data\windows\OpenRA-bleed\COPYING
  203. Remove-Item .\data\windows\OpenRA-bleed\ConvertFrom-Markdown.ps1
  204. Remove-Item .\data\windows\OpenRA-bleed\INSTALL.md
  205. Remove-Item .\data\windows\OpenRA-bleed\Makefile
  206. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.sln
  207. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.sln.orig
  208. Remove-Item .\data\windows\OpenRA-bleed\README.md
  209. Remove-Item .\data\windows\OpenRA-bleed\Settings.StyleCop
  210. Remove-Item .\data\windows\OpenRA-bleed\make.ps1
  211. Remove-Item .\data\windows\OpenRA-bleed\make.ps1.orig
  212. Remove-Item .\data\windows\OpenRA-bleed\make.cmd
  213. Remove-Item .\data\windows\OpenRA-bleed\launch-game.sh
  214. Remove-Item .\data\windows\OpenRA-bleed\launch-dedicated.sh
  215. Remove-Item .\data\windows\OpenRA-bleed\appveyor.yml
  216. Remove-Item .\data\windows\OpenRA-bleed\dupFinder.xslt
  217. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Game.exe.config
  218. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Game.pdb
  219. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Server.pdb
  220. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Platforms.Default.pdb
  221. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Test.dll.config
  222. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Utility.exe.config
  223. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Test.nunit
  224. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Test.pdb
  225. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.pdb
  226. Remove-Item .\data\windows\OpenRA-bleed\OpenRA.Utility.pdb
  227. Remove-Item .\data\windows\OpenRA-bleed\AUTHORS
  228. Remove-Item .\data\windows\OpenRA-bleed\mods\cnc\OpenRA.Mods.Cnc.pdb
  229. Remove-Item .\data\windows\OpenRA-bleed\mods\common\OpenRA.Mods.Common.pdb
  230. Remove-Item .\data\windows\OpenRA-bleed\mods\d2k\OpenRA.Mods.D2k.pdb
  231. Remove-Item .\data\windows\OpenRA-bleed\mods\ra\OpenRA.Mods.RA.pdb
  232. Remove-Item .\data\windows\OpenRA-bleed\mods\ts\OpenRA.Mods.TS.pdb
  233. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\build.cake
  234. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\makefile
  235. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\make.ps1
  236. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\mod.yaml.orig
  237. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\.gitattributes
  238. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\.gitignore
  239. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\.travis.yml
  240. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\make.cmd
  241. Remove-Item .\data\windows\OpenRA-bleed\mods\ra2\fetch-content.sh
  242. Remove-Item -Recurse .\data\windows\OpenRA-bleed\mods\ra2\OpenRA.Mods.RA2
  243. Copy-Item -Recurse ".\data\windows\OpenRA-bleed\" ".\OpenRA-tibsunra2-Windows-openra$openra_folderversion-ra2$ra2_folderversion"
  244. Remove-Item .\data\windows\OpenRA-bleed\* -Recurse
  245. Remove-Item .\data\windows\OpenRA-bleed
  246. Remove-Item .\data\windows\ra2-master
  247. #------------------------------------------------------
  248. ## Post-installation messages
  249. "`nCompilation process completed. You find the game inside 'OpenRA-tibsunra2-Windows-openra$openra_folderversion-ra2$ra2_folderversion' folder"
  250. Start-Sleep -s 4
  251. "`nTO PLAY OPENRA: Click OpenRA.exe (maybe you should create a desktop shortcut for it?)"
  252. "`nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so."
  253. "`nTO PLAY RED ALERT 2: you must install language.mix, multi.mix, ra2.mix and theme.mix into \My Documents\OpenRA\Content\ra2\ folder.`nYou find these files from original RA2 installation media (CD's):`n`ntheme.mix, multi.mix = RA2 CD Root folder`nra2.mix, language.mix = RA2 CD Root\INSTALL\Game1.CAB (inside that archive file)"
  254. "`nMULTIPLAYER: It's recommended to build OpenRA using exactly same GIT source files for multiplayer usage to minimize possible version differences/conflicts between players. Please make sure all players have exactly same git versions of their in-game mods (RA, CNC, D2K, TS, RA2). Version numbers are formatted like 'git-e0d7445' etc. and can be found in each mod description in the mod selection menu."
  255. "`nFor this compilation, the version numbers are as follows:"
  256. Write-Output "OpenRA version: $openra_gitversion"
  257. Write-Output "RA2 version: $ra2_gitversion"
  258. "`nUNINSTALLATION: Since the game has been compiled from source and no additional setup programs are provided, all you need to do is to delete the contents of 'OpenRA-bleed-tibsunra2' folder and \My Documents\OpenRA\"
  259. "`nHave fun!"
  260. exit
  261. #------------------------------------------------------
  262. ## Termination code for the script (Ctrl + C)
  263. if ($Host.UI.RawUI.KeyAvailable -and (3 -eq [int]$Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character))
  264. {
  265. write-host "Installation script terminated by user."
  266. $key = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
  267. if ($key.Character -eq "N") { break; }
  268. }
  269. }