install.bat 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 Dim strFileURL, strHDLocation
  55. >> temp1.vbs ECHO strFileURL = WScript.Arguments(0)
  56. >> temp1.vbs ECHO strHDLocation = WScript.Arguments(1)
  57. >> temp1.vbs ECHO Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  58. >> temp1.vbs ECHO objXMLHTTP.open "GET", strFileURL, false
  59. >> temp1.vbs ECHO objXMLHTTP.send()
  60. >> temp1.vbs ECHO If objXMLHTTP.Status = 200 Then
  61. >> temp1.vbs ECHO Set objADOStream = CreateObject("ADODB.Stream")
  62. >> temp1.vbs ECHO objADOStream.Open
  63. >> temp1.vbs ECHO objADOStream.Type = 1
  64. >> temp1.vbs ECHO objADOStream.Write objXMLHTTP.ResponseBody
  65. >> temp1.vbs ECHO objADOStream.Position = 0
  66. >> temp1.vbs ECHO Set objFSO = Createobject("Scripting.FileSystemObject")
  67. >> temp1.vbs ECHO If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  68. >> temp1.vbs ECHO Set objFSO = Nothing
  69. >> temp1.vbs ECHO objADOStream.SaveToFile strHDLocation
  70. >> temp1.vbs ECHO objADOStream.Close
  71. >> temp1.vbs ECHO Set objADOStream = Nothing
  72. >> temp1.vbs ECHO End if
  73. >> temp1.vbs ECHO Set objXMLHTTP = Nothing
  74. if exist %windir%\Microsoft.NET\Framework\v2.0.50727\NUL (
  75. %windir%\Microsoft.NET\Framework\v2.0.50727\csc temp.cs
  76. ) else (
  77. if exist %windir%\Microsoft.NET\Framework\v4.0.30319\NUL (
  78. %windir%\Microsoft.NET\Framework\v4.0.30319\csc temp.cs
  79. ) else (
  80. goto USE_VBS_AS_FALLBACK
  81. ))
  82. temp.exe
  83. del temp.exe
  84. goto :EXTRACT
  85. :USE_VBS_AS_FALLBACK
  86. cscript temp1.vbs %prefix%/%filename%.zip %filename%.zip
  87. :EXTRACT
  88. echo Extracting %filename%.zip... please standby...
  89. %~d0
  90. cd %~dp0
  91. > temp2.vbs ECHO Dim fileName, workingDir
  92. >> temp2.vbs ECHO fileName = WScript.Arguments(0)
  93. >> temp2.vbs ECHO workingDir = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
  94. >> temp2.vbs ECHO Set objShell = CreateObject("Shell.Application")
  95. >> temp2.vbs ECHO Set objSource = objShell.NameSpace(workingDir ^& "\" ^& fileName).Items()
  96. >> temp2.vbs ECHO Set objTarget = objShell.NameSpace(workingDir ^& "\")
  97. >> temp2.vbs ECHO intOptions = 256
  98. >> temp2.vbs ECHO objTarget.CopyHere objSource, intOptions
  99. cscript temp2.vbs %filename%.zip
  100. echo Cleaning up...
  101. del temp.cs
  102. del temp1.vbs
  103. del temp2.vbs
  104. del %filename%.zip
  105. echo Done.