install.bat 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. @echo off
  2. REM
  3. REM install.bat
  4. REM
  5. REM Download GamePlay dependencies and binaries from github releases and extracts from ZIP
  6. REM
  7. REM Helps prevent repo bloat due to large binary files
  8. REM
  9. set prefix=https://github.com/blackberry/GamePlay/releases/download/v3.0.0
  10. set filename=gameplay-deps
  11. echo Downloading %filename%.zip from %prefix%
  12. %~d0
  13. cd %~dp0
  14. > temp.cs ECHO using System;
  15. >> temp.cs ECHO using System.Net;
  16. >> temp.cs ECHO using System.ComponentModel;
  17. >> temp.cs ECHO class Program
  18. >> temp.cs ECHO {
  19. >> temp.cs ECHO static string file = "%filename%.zip";
  20. >> temp.cs ECHO static string url = "%prefix%/" + file;
  21. >> temp.cs ECHO static bool done = false;
  22. >> temp.cs ECHO static void Main(string[] args)
  23. >> temp.cs ECHO {
  24. >> temp.cs ECHO try
  25. >> temp.cs ECHO {
  26. >> temp.cs ECHO WebClient client = new WebClient();
  27. >> temp.cs ECHO client.Proxy = null;
  28. >> temp.cs ECHO client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
  29. >> temp.cs ECHO client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
  30. >> temp.cs ECHO Console.Write("Downloading " + file + ": 0%% ");
  31. >> temp.cs ECHO client.DownloadFileAsync(new Uri(url), file);
  32. >> temp.cs ECHO while (!done) System.Threading.Thread.Sleep(500);
  33. >> temp.cs ECHO }
  34. >> temp.cs ECHO catch (Exception x)
  35. >> temp.cs ECHO {
  36. >> temp.cs ECHO Console.WriteLine("Error: " + x.Message);
  37. >> temp.cs ECHO }
  38. >> temp.cs ECHO }
  39. >> temp.cs ECHO static void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
  40. >> temp.cs ECHO {
  41. >> temp.cs ECHO Console.Write("\rDownloading " + file + ": " + e.ProgressPercentage + "%% ");
  42. >> temp.cs ECHO }
  43. >> temp.cs ECHO static void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
  44. >> temp.cs ECHO {
  45. >> temp.cs ECHO Console.WriteLine("\rDownloading " + file + ": Done. ");
  46. >> temp.cs ECHO done = true;
  47. >> temp.cs ECHO }
  48. >> temp.cs ECHO }
  49. > temp1.vbs ECHO WScript.Echo "Downloading using a fallback method. This might take a few minutes."
  50. >> temp1.vbs ECHO Dim strFileURL, strHDLocation
  51. >> temp1.vbs ECHO strFileURL = WScript.Arguments(0)
  52. >> temp1.vbs ECHO strHDLocation = WScript.Arguments(1)
  53. >> temp1.vbs ECHO Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  54. >> temp1.vbs ECHO objXMLHTTP.open "GET", strFileURL, false
  55. >> temp1.vbs ECHO WScript.Echo "Sending request..."
  56. >> temp1.vbs ECHO objXMLHTTP.send()
  57. >> temp1.vbs ECHO If objXMLHTTP.Status = 200 Then
  58. >> temp1.vbs ECHO WScript.Echo "Got response. Processing body..."
  59. >> temp1.vbs ECHO Set objADOStream = CreateObject("ADODB.Stream")
  60. >> temp1.vbs ECHO objADOStream.Open
  61. >> temp1.vbs ECHO objADOStream.Type = 1
  62. >> temp1.vbs ECHO objADOStream.Write objXMLHTTP.ResponseBody
  63. >> temp1.vbs ECHO objADOStream.Position = 0
  64. >> temp1.vbs ECHO Set objFSO = Createobject("Scripting.FileSystemObject")
  65. >> temp1.vbs ECHO If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  66. >> temp1.vbs ECHO Set objFSO = Nothing
  67. >> temp1.vbs ECHO WScript.Echo "Saving result to a file..."
  68. >> temp1.vbs ECHO objADOStream.SaveToFile strHDLocation
  69. >> temp1.vbs ECHO objADOStream.Close
  70. >> temp1.vbs ECHO Set objADOStream = Nothing
  71. >> temp1.vbs ECHO WScript.Echo "Success."
  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.