install.bat 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. @echo off
  2. REM
  3. REM install.bat [master | next]
  4. REM
  5. REM Download GamePlay resources from HTTP server and extract from ZIP
  6. REM
  7. REM Helps prevent repo bloat due to large binary files since they can
  8. REM be hosted separately.
  9. REM
  10. REM Production URL
  11. set prefix=http://www.gameplay3d.org
  12. set branchname=%1
  13. if "%branchname%" == "" (
  14. set branchname=next
  15. )
  16. set filename=gameplay-deps-%branchname%
  17. echo Downloading %filename%.zip from %prefix%
  18. %~d0
  19. cd %~dp0
  20. > temp.cs ECHO using System;
  21. >> temp.cs ECHO using System.Net;
  22. >> temp.cs ECHO using System.ComponentModel;
  23. >> temp.cs ECHO class Program
  24. >> temp.cs ECHO {
  25. >> temp.cs ECHO static string file = "%filename%.zip";
  26. >> temp.cs ECHO static string url = "%prefix%/" + file;
  27. >> temp.cs ECHO static bool done = false;
  28. >> temp.cs ECHO static void Main(string[] args)
  29. >> temp.cs ECHO {
  30. >> temp.cs ECHO try
  31. >> temp.cs ECHO {
  32. >> temp.cs ECHO WebClient client = new WebClient();
  33. >> temp.cs ECHO client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
  34. >> temp.cs ECHO client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
  35. >> temp.cs ECHO Console.Write("Downloading " + url + ": 0%% ");
  36. >> temp.cs ECHO client.DownloadFileAsync(new Uri(url), file);
  37. >> temp.cs ECHO while (!done) System.Threading.Thread.Sleep(1000);
  38. >> temp.cs ECHO }
  39. >> temp.cs ECHO catch (Exception x)
  40. >> temp.cs ECHO {
  41. >> temp.cs ECHO Console.WriteLine("Error: " + x.Message);
  42. >> temp.cs ECHO }
  43. >> temp.cs ECHO }
  44. >> temp.cs ECHO static void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  45. >> temp.cs ECHO {
  46. >> temp.cs ECHO Console.Write("\rDownloading " + url + ": " + e.ProgressPercentage + "%% ");
  47. >> temp.cs ECHO }
  48. >> temp.cs ECHO static void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
  49. >> temp.cs ECHO {
  50. >> temp.cs ECHO Console.WriteLine("\rDownloading " + url + ": Done. ");
  51. >> temp.cs ECHO done = true;
  52. >> temp.cs ECHO }
  53. >> temp.cs ECHO }
  54. > temp1.vbs ECHO WScript.Echo "Downloading using a fallback method. This might take a few minutes."
  55. >> temp1.vbs ECHO Dim strFileURL, strHDLocation
  56. >> temp1.vbs ECHO strFileURL = WScript.Arguments(0)
  57. >> temp1.vbs ECHO strHDLocation = WScript.Arguments(1)
  58. >> temp1.vbs ECHO Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  59. >> temp1.vbs ECHO objXMLHTTP.open "GET", strFileURL, false
  60. >> temp1.vbs ECHO WScript.Echo "Sending request..."
  61. >> temp1.vbs ECHO objXMLHTTP.send()
  62. >> temp1.vbs ECHO If objXMLHTTP.Status = 200 Then
  63. >> temp1.vbs ECHO WScript.Echo "Got response. Processing body..."
  64. >> temp1.vbs ECHO Set objADOStream = CreateObject("ADODB.Stream")
  65. >> temp1.vbs ECHO objADOStream.Open
  66. >> temp1.vbs ECHO objADOStream.Type = 1
  67. >> temp1.vbs ECHO objADOStream.Write objXMLHTTP.ResponseBody
  68. >> temp1.vbs ECHO objADOStream.Position = 0
  69. >> temp1.vbs ECHO Set objFSO = Createobject("Scripting.FileSystemObject")
  70. >> temp1.vbs ECHO If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  71. >> temp1.vbs ECHO Set objFSO = Nothing
  72. >> temp1.vbs ECHO WScript.Echo "Saving result to a file..."
  73. >> temp1.vbs ECHO objADOStream.SaveToFile strHDLocation
  74. >> temp1.vbs ECHO objADOStream.Close
  75. >> temp1.vbs ECHO Set objADOStream = Nothing
  76. >> temp1.vbs ECHO WScript.Echo "Success."
  77. >> temp1.vbs ECHO End if
  78. >> temp1.vbs ECHO Set objXMLHTTP = Nothing
  79. if exist %windir%\Microsoft.NET\Framework\v2.0.50727\NUL (
  80. %windir%\Microsoft.NET\Framework\v2.0.50727\csc temp.cs
  81. ) else (
  82. if exist %windir%\Microsoft.NET\Framework\v4.0.30319\NUL (
  83. %windir%\Microsoft.NET\Framework\v4.0.30319\csc temp.cs
  84. ) else (
  85. goto USE_VBS_AS_FALLBACK
  86. ))
  87. temp.exe
  88. del temp.exe
  89. goto :EXTRACT
  90. :USE_VBS_AS_FALLBACK
  91. cscript temp1.vbs %prefix%/%filename%.zip %filename%.zip
  92. :EXTRACT
  93. echo Extracting %filename%.zip... please standby...
  94. %~d0
  95. cd %~dp0
  96. > temp2.vbs ECHO Dim fileName, workingDir
  97. >> temp2.vbs ECHO fileName = WScript.Arguments(0)
  98. >> temp2.vbs ECHO workingDir = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
  99. >> temp2.vbs ECHO Set objShell = CreateObject("Shell.Application")
  100. >> temp2.vbs ECHO Set objSource = objShell.NameSpace(workingDir ^& "\" ^& fileName).Items()
  101. >> temp2.vbs ECHO Set objTarget = objShell.NameSpace(workingDir ^& "\")
  102. >> temp2.vbs ECHO intOptions = 256
  103. >> temp2.vbs ECHO objTarget.CopyHere objSource, intOptions
  104. cscript temp2.vbs %filename%.zip
  105. echo Cleaning up...
  106. del temp.cs
  107. del temp1.vbs
  108. del temp2.vbs
  109. del %filename%.zip
  110. echo Done.