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.

229 lines
10 KiB

  1. #------------------------------------------------------
  2. ## Prepare the script for possible Ctrl+C termination
  3. while ($true)
  4. {
  5. #------------------------------------------------------
  6. ## Initial script messages
  7. "***Welcome Comrade***"
  8. Start-Sleep -s 3
  9. "`nThis script will generate OpenRA with Tiberian Sun & Red Alert 2 for Windows."
  10. Start-Sleep -s 4
  11. "`n- Make sure you have Microsoft .NET Framework 4.5 installed on your computer."
  12. Start-Sleep -s 3
  13. "`n- This script is NOT made by the OpenRA developers and may have bugs."
  14. Start-Sleep -s 3
  15. "`n- If you worry about what the script is doing, you can always check its code (\data\windows\install.ps1)"
  16. Start-Sleep -s 4
  17. "`n- Press Ctrl+C if you want terminate script execution."
  18. Start-Sleep -s 4
  19. "`n***Starting execution sequence now***"
  20. Start-Sleep -s 3
  21. #------------------------------------------------------
  22. ## Remove all old source files if they exist
  23. "`nRemoving all old source files that may exist in the data directory."
  24. Remove-Item .\data\windows\OpenRA-bleed -Force -Recurse -ErrorAction SilentlyContinue
  25. Remove-Item .\data\windows\ra2-master -Force -Recurse -ErrorAction SilentlyContinue
  26. Remove-Item .\data\windows\OpenRA-bleed.zip -Force -ErrorAction SilentlyContinue
  27. Remove-Item .\data\windows\ra2-master.zip -Force -ErrorAction SilentlyContinue
  28. Remove-Item .\data\windows\*.html -Force -ErrorAction SilentlyContinue
  29. Remove-Item .\data\windows\*.txt -Force -ErrorAction SilentlyContinue
  30. Remove-Item .\data\windows\*.zip -Force -ErrorAction SilentlyContinue
  31. Remove-Item .\data\windows\*.patch -Force -ErrorAction SilentlyContinue
  32. #------------------------------------------------------
  33. ## Prepare Github environment for downloading the source
  34. [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
  35. $client = New-Object System.Net.WebClient
  36. $client.Headers.Add("Authorization","token 1234567890notarealtoken987654321")
  37. $client.Headers.Add("Accept","application/vnd.github.v3.raw")
  38. #------------------------------------------------------
  39. ## Download OpenRA-bleed source code
  40. "`nDownloading OpenRA source files from Github. Please Stand By."
  41. $client.DownloadFile("https://github.com/OpenRA/OpenRA/archive/bleed.zip?ref=bleed",".\data\windows\OpenRA-bleed.zip")
  42. #------------------------------------------------------
  43. ## Download Red Alert 2 mod files
  44. "`nDownloading Red Alert 2 mod files from Github. Please Stand By."
  45. $client.DownloadFile("https://github.com/OpenRA/ra2/archive/master.zip?ref=master",".\data\windows\ra2-master.zip")
  46. #------------------------------------------------------
  47. ## Unzip OpenRA-bleed source files
  48. "`nUnzipping OpenRA source files into \data\windows folder."
  49. $shell_app=new-object -com shell.application
  50. $filename = "OpenRA-bleed.zip"
  51. $zip_file = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename")
  52. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  53. $destination.Copyhere($zip_file.items())
  54. #------------------------------------------------------
  55. ## Unzip Red Alert 2 mod files
  56. "`nUnzipping Red Alert 2 mod files into \data\windows folder."
  57. $shell_app=new-object -com shell.application
  58. $filename2 = "ra2-master.zip"
  59. $zip_file2 = $shell_app.namespace((Get-Location).Path + "\data\windows" + "\$filename2")
  60. $destination = $shell_app.namespace((Get-Location).Path + "\data\windows")
  61. $destination.Copyhere($zip_file2.items())
  62. #------------------------------------------------------
  63. ## Merge OpenRA source files and Red Alert 2 mod files together
  64. "`nMerging OpenRA source & Red Alert 2 mod files."
  65. Copy-Item -Recurse ".\data\windows\ra2-master\OpenRA.Mods.RA2" ".\data\windows\OpenRA-bleed\OpenRA.Mods.RA2"
  66. Copy-Item -Recurse ".\data\windows\ra2-master" ".\data\windows\OpenRA-bleed\mods\ra2"
  67. Remove-Item -Recurse .\data\windows\ra2-master\*
  68. #------------------------------------------------------
  69. ## Get OpenRA Git version number
  70. "`nRetrieving OpenRA & Red Alert 2 Git version numbers."
  71. $web = New-Object System.Net.WebClient
  72. $web.DownloadFile("https://github.com/OpenRA/OpenRA",".\data\windows\openra-github.html")
  73. $flag=0
  74. Get-Content .\data\windows\openra-github.html |
  75. foreach {
  76. Switch -Wildcard ($_){
  77. "*Latest commit*" {$flag=1}
  78. "*time datetime*" {$flag=0}
  79. }
  80. if ($flag -eq 1){
  81. Out-File .\data\windows\openra-html-stripped.txt -InputObject $_ -Append
  82. }
  83. }
  84. (Get-Content .\data\windows\openra-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\openra-latestcommit.txt
  85. $openra_gitversion = [IO.File]::ReadAllText(".\data\windows\openra-latestcommit.txt").trim("`r`n")
  86. Write-Output "`nOpenRA version: $openra_gitversion"
  87. #------------------------------------------------------
  88. ## Get Red Alert 2 Git version number
  89. $web = New-Object System.Net.WebClient
  90. $web.DownloadFile("https://github.com/OpenRA/ra2",".\data\windows\ra2-github.html")
  91. $flag=0
  92. Get-Content .\data\windows\ra2-github.html |
  93. foreach {
  94. Switch -Wildcard ($_){
  95. "*Latest commit*" {$flag=1}
  96. "*time datetime*" {$flag=0}
  97. }
  98. if ($flag -eq 1){
  99. Out-File .\data\windows\ra2-html-stripped.txt -InputObject $_ -Append
  100. }
  101. }
  102. (Get-Content .\data\windows\ra2-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\ra2-latestcommit.txt
  103. $ra2_gitversion = [IO.File]::ReadAllText(".\data\windows\ra2-latestcommit.txt").trim("`r`n")
  104. Write-Output "RA2 version: $ra2_gitversion"
  105. #------------------------------------------------------
  106. ## Prepare OpenRA source code for Tiberian Sun & Red Alert 2
  107. Copy-Item ".\data\patches\windows\*.patch" ".\data\windows"
  108. Start-Sleep -s 3
  109. "`nPatching OpenRA source code for Tiberian Sun & Red Alert 2."
  110. cd .\data\windows
  111. "`nFor each time a patch is being applied, UAC may ask permission for patch.exe."
  112. $patchcount = (Get-Childitem .\ | where {$_.extension -eq ".patch"} | Measure-Object ).Count;
  113. Write-Output "`nExecuting patch.exe $patchcount times now."
  114. Start-Sleep -s 6
  115. Get-ChildItem .\ -include *.patch -recurse | Foreach ($_) {.\patch.exe -d OpenRA-bleed -Np1 -i $_.fullname }
  116. cd ..
  117. cd ..
  118. #------------------------------------------------------
  119. ## Push version numbers to mod files
  120. # Red Alert
  121. (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
  122. # Tiberian Dawn
  123. (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
  124. # Dune 2K
  125. (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
  126. # Tiberian Sun
  127. (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
  128. # Red Alert 2
  129. (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
  130. # Mod Chooser
  131. (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
  132. # All
  133. (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
  134. #------------------------------------------------------
  135. ## Remove temporary files
  136. Remove-Item .\data\windows\*.html
  137. Remove-Item .\data\windows\*.txt
  138. Remove-Item .\data\windows\*.zip
  139. Remove-Item .\data\windows\*.patch
  140. #------------------------------------------------------
  141. ## Compile OpenRA with Tiberian Sun & Red Alert 2
  142. "`nCompiling OpenRA with Tiberian Sun & Red Alert 2.`n"
  143. cd .\data\windows\OpenRA-bleed\
  144. .\make.cmd dependencies
  145. .\make.cmd all
  146. cd ..
  147. cd ..
  148. cd ..
  149. "`nCopying OpenRA files to the final location.`n"
  150. Copy-Item -Recurse ".\data\windows\OpenRA-bleed\" ".\OpenRA-tibsunra2-Windows"
  151. Remove-Item .\data\windows\OpenRA-bleed\* -Recurse
  152. Remove-Item .\data\windows\OpenRA-bleed
  153. Remove-Item .\data\windows\ra2-master
  154. #------------------------------------------------------
  155. ## Post-installation messages
  156. "`nCompilation process completed. You find the game inside 'OpenRA-tibsunra2-Windows' folder"
  157. Start-Sleep -s 4
  158. "`nTO PLAY OPENRA: Click OpenRA.exe (maybe you should create a desktop shortcut for it?)"
  159. "`nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so."
  160. "`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)"
  161. "`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."
  162. "`nFor this compilation, the version numbers are as follows:"
  163. Write-Output "OpenRA version: $openra_gitversion"
  164. Write-Output "RA2 version: $ra2_gitversion"
  165. "`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\"
  166. "`nHave fun!"
  167. exit
  168. #------------------------------------------------------
  169. ## Termination code for the script (Ctrl + C)
  170. if ($Host.UI.RawUI.KeyAvailable -and (3 -eq [int]$Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character))
  171. {
  172. write-host "Installation script terminated by user."
  173. $key = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
  174. if ($key.Character -eq "N") { break; }
  175. }
  176. }