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.

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