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.

224 lines
9.9 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 contain 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. move-item ".\data\windows\ra2-master\OpenRA.Mods.RA2" ".\data\windows\OpenRA-bleed\OpenRA.Mods.RA2"
  66. move-item ".\data\windows\ra2-master" ".\data\windows\OpenRA-bleed\mods\ra2"
  67. #------------------------------------------------------
  68. ## Get OpenRA Git version number
  69. "`nRetrieving OpenRA & Red Alert 2 Git version numbers."
  70. $web = New-Object System.Net.WebClient
  71. $web.DownloadFile("https://github.com/OpenRA/OpenRA",".\data\windows\openra-github.html")
  72. $flag=0
  73. Get-Content .\data\windows\openra-github.html |
  74. foreach {
  75. Switch -Wildcard ($_){
  76. "*Latest commit*" {$flag=1}
  77. "*time datetime*" {$flag=0}
  78. }
  79. if ($flag -eq 1){
  80. Out-File .\data\windows\openra-html-stripped.txt -InputObject $_ -Append
  81. }
  82. }
  83. (Get-Content .\data\windows\openra-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\openra-latestcommit.txt
  84. $openra_gitversion = [IO.File]::ReadAllText(".\data\windows\openra-latestcommit.txt").trim("`r`n")
  85. Write-Output "`nOpenRA version: $openra_gitversion"
  86. #------------------------------------------------------
  87. ## Get Red Alert 2 Git version number
  88. $web = New-Object System.Net.WebClient
  89. $web.DownloadFile("https://github.com/OpenRA/ra2",".\data\windows\ra2-github.html")
  90. $flag=0
  91. Get-Content .\data\windows\ra2-github.html |
  92. foreach {
  93. Switch -Wildcard ($_){
  94. "*Latest commit*" {$flag=1}
  95. "*time datetime*" {$flag=0}
  96. }
  97. if ($flag -eq 1){
  98. Out-File .\data\windows\ra2-html-stripped.txt -InputObject $_ -Append
  99. }
  100. }
  101. (Get-Content .\data\windows\ra2-html-stripped.txt)[2] -replace '\s','' | Foreach-Object{ 'git-' + $_ } > .\data\windows\ra2-latestcommit.txt
  102. $ra2_gitversion = [IO.File]::ReadAllText(".\data\windows\ra2-latestcommit.txt").trim("`r`n")
  103. Write-Output "RA2 version: $ra2_gitversion"
  104. #------------------------------------------------------
  105. ## Prepare OpenRA source code for Tiberian Sun & Red Alert 2
  106. Copy-Item ".\data\patches\*.patch" ".\data\windows"
  107. Start-Sleep -s 3
  108. "`nPatching OpenRA source code for Tiberian Sun & Red Alert 2."
  109. cd .\data\windows
  110. "`nFor each time a patch is being applied, UAC may ask permission for patch.exe."
  111. $patchcount = (Get-Childitem .\ | where {$_.extension -eq ".patch"} | Measure-Object ).Count;
  112. Write-Output "`nExecuting patch.exe $patchcount times now."
  113. Get-ChildItem .\ -include *.patch -recurse | Foreach ($_) {.\patch.exe -d OpenRA-bleed -Np1 -i $_.fullname }
  114. cd ..
  115. cd ..
  116. #------------------------------------------------------
  117. ## Push version numbers to mod files
  118. # Red Alert
  119. (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
  120. # Tiberian Dawn
  121. (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
  122. # Dune 2K
  123. (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
  124. # Tiberian Sun
  125. (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
  126. # Red Alert 2
  127. (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
  128. # Mod Chooser
  129. (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
  130. # All
  131. (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
  132. #------------------------------------------------------
  133. ## Remove temporary files
  134. Remove-Item .\data\windows\*.html
  135. Remove-Item .\data\windows\*.txt
  136. Remove-Item .\data\windows\*.zip
  137. Remove-Item .\data\windows\*.patch
  138. #------------------------------------------------------
  139. ## Compile OpenRA with Tiberian Sun & Red Alert 2
  140. "`nCompiling OpenRA with Tiberian Sun & Red Alert 2.`n"
  141. cd .\data\windows\OpenRA-bleed\
  142. .\make.cmd dependencies
  143. .\make.cmd all
  144. cd ..
  145. cd ..
  146. cd ..
  147. move-item ".\data\windows\OpenRA-bleed\" ".\OpenRA-tibsunra2-Windows"
  148. #------------------------------------------------------
  149. ## Post-installation messages
  150. "`nCompilation process completed. You find the game inside 'OpenRA-tibsunra2-Windows' folder"
  151. Start-Sleep -s 4
  152. "`nTO PLAY OPENRA: Click OpenRA.exe (maybe you should create a desktop shortcut for it?)"
  153. "`nTO PLAY TIBERIAN SUN: Launch the game and download the required asset files from the web when the game asks you to do so."
  154. "`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)"
  155. "`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."
  156. "`nFor this compilation, the version numbers are as follows:"
  157. Write-Output "OpenRA version: $openra_gitversion"
  158. Write-Output "RA2 version: $ra2_gitversion"
  159. "`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\"
  160. "`nHave fun!"
  161. exit
  162. #------------------------------------------------------
  163. ## Termination code for the script (Ctrl + C)
  164. if ($Host.UI.RawUI.KeyAvailable -and (3 -eq [int]$Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character))
  165. {
  166. write-host "Installation script terminated by user."
  167. $key = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
  168. if ($key.Character -eq "N") { break; }
  169. }
  170. }