install.bat 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.Proxy = null;
  34. >> temp.cs ECHO client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
  35. >> temp.cs ECHO client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
  36. >> temp.cs ECHO Console.Write("Downloading " + url + ": 0%% ");
  37. >> temp.cs ECHO client.DownloadFileAsync(new Uri(url), file);
  38. >> temp.cs ECHO while (!done) System.Threading.Thread.Sleep(500);
  39. >> temp.cs ECHO }
  40. >> temp.cs ECHO catch (Exception x)
  41. >> temp.cs ECHO {
  42. >> temp.cs ECHO Console.WriteLine("Error: " + x.Message);
  43. >> temp.cs ECHO }
  44. >> temp.cs ECHO }
  45. >> temp.cs ECHO static void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  46. >> temp.cs ECHO {
  47. >> temp.cs ECHO Console.Write("\rDownloading " + url + ": " + e.ProgressPercentage + "%% ");
  48. >> temp.cs ECHO }
  49. >> temp.cs ECHO static void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
  50. >> temp.cs ECHO {
  51. >> temp.cs ECHO Console.WriteLine("\rDownloading " + url + ": Done. ");
  52. >> temp.cs ECHO done = true;
  53. >> temp.cs ECHO }
  54. >> temp.cs ECHO }
  55. > temp1.vbs ECHO WScript.Echo "Downloading using a fallback method. This might take a few minutes."
  56. >> temp1.vbs ECHO Dim strFileURL, strHDLocation
  57. >> temp1.vbs ECHO strFileURL = WScript.Arguments(0)
  58. >> temp1.vbs ECHO strHDLocation = WScript.Arguments(1)
  59. >> temp1.vbs ECHO Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  60. >> temp1.vbs ECHO objXMLHTTP.open "GET", strFileURL, false
  61. >> temp1.vbs ECHO WScript.Echo "Sending request..."
  62. >> temp1.vbs ECHO objXMLHTTP.send()
  63. >> temp1.vbs ECHO If objXMLHTTP.Status = 200 Then
  64. >> temp1.vbs ECHO WScript.Echo "Got response. Processing body..."
  65. >> temp1.vbs ECHO Set objADOStream = CreateObject("ADODB.Stream")
  66. >> temp1.vbs ECHO objADOStream.Open
  67. >> temp1.vbs ECHO objADOStream.Type = 1
  68. >> temp1.vbs ECHO objADOStream.Write objXMLHTTP.ResponseBody
  69. >> temp1.vbs ECHO objADOStream.Position = 0
  70. >> temp1.vbs ECHO Set objFSO = Createobject("Scripting.FileSystemObject")
  71. >> temp1.vbs ECHO If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  72. >> temp1.vbs ECHO Set objFSO = Nothing
  73. >> temp1.vbs ECHO WScript.Echo "Saving result to a file..."
  74. >> temp1.vbs ECHO objADOStream.SaveToFile strHDLocation
  75. >> temp1.vbs ECHO objADOStream.Close
  76. >> temp1.vbs ECHO Set objADOStream = Nothing
  77. >> temp1.vbs ECHO WScript.Echo "Success."
  78. >> temp1.vbs ECHO End if
  79. >> temp1.vbs ECHO Set objXMLHTTP = Nothing
  80. if exist %windir%\Microsoft.NET\Framework\v2.0.50727\NUL (
  81. %windir%\Microsoft.NET\Framework\v2.0.50727\csc temp.cs
  82. ) else (
  83. if exist %windir%\Microsoft.NET\Framework\v4.0.30319\NUL (
  84. %windir%\Microsoft.NET\Framework\v4.0.30319\csc temp.cs
  85. ) else (
  86. goto USE_VBS_AS_FALLBACK
  87. ))
  88. temp.exe
  89. del temp.exe
  90. goto :EXTRACT
  91. :USE_VBS_AS_FALLBACK
  92. cscript temp1.vbs %prefix%/%filename%.zip %filename%.zip
  93. :EXTRACT
  94. echo Extracting %filename%.zip... please standby...
  95. %~d0
  96. cd %~dp0
  97. > temp2.vbs ECHO Dim fileName, workingDir
  98. >> temp2.vbs ECHO fileName = WScript.Arguments(0)
  99. >> temp2.vbs ECHO workingDir = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
  100. >> temp2.vbs ECHO Set objShell = CreateObject("Shell.Application")
  101. >> temp2.vbs ECHO Set objSource = objShell.NameSpace(workingDir ^& "\" ^& fileName).Items()
  102. >> temp2.vbs ECHO Set objTarget = objShell.NameSpace(workingDir ^& "\")
  103. >> temp2.vbs ECHO intOptions = 256
  104. >> temp2.vbs ECHO objTarget.CopyHere objSource, intOptions
  105. cscript temp2.vbs %filename%.zip
  106. echo Cleaning up...
  107. del temp.cs
  108. del temp1.vbs
  109. del temp2.vbs
  110. del %filename%.zip
  111. echo Done.