1 | @echo off
|
---|
2 | set curlver=8.2.1_7
|
---|
3 | if not exist C:\Windows\System32\curl.exe if not exist %cd%\curl.exe (
|
---|
4 | bitsadmin /transfer curlDownload https://curl.se/windows/dl-%curlver%/curl-%curlver%-win32-mingw.zip %cd%\curl.zip
|
---|
5 | call :UnZipFile "%cd%" "%cd%\curl.zip"
|
---|
6 | move curl-%curlver%-win32-mingw\bin\curl.exe curl.exe
|
---|
7 | rmdir /s /q curl-%curlver%-win32-mingw
|
---|
8 | )
|
---|
9 |
|
---|
10 | REM BITS requires the HTTP server to return the Content-Length header
|
---|
11 | set URL=https://trac.wildfiregames.com/export/HEAD/ps/trunk/binaries/system
|
---|
12 | REM bitsadmin /transfer 0adDownload %URL%/SHA256SUMS %cd%\SHA256SUMS
|
---|
13 | REM curl.exe -k -L -s %URL%/SHA256SUMS
|
---|
14 |
|
---|
15 | SETLOCAL EnableDelayedExpansion
|
---|
16 | for /f "tokens=*" %%l in (SHA256SUMS) do (
|
---|
17 | for /f "tokens=1 delims= " %%i in ("%%l") DO (
|
---|
18 | set hash=%%i
|
---|
19 | )
|
---|
20 | for /f "tokens=2 delims= " %%i in ("%%l") DO (
|
---|
21 | set filename=%%i
|
---|
22 | if "*"=="!filename:~0,1!" set filename=!filename:~1!
|
---|
23 | )
|
---|
24 | if exist !filename! (
|
---|
25 | call :getfilehash
|
---|
26 | call :testfilehash
|
---|
27 | ) else (
|
---|
28 | call :testfilehash
|
---|
29 | call :getfilehash
|
---|
30 | echo !filename!: Hash !filehash!
|
---|
31 | )
|
---|
32 | )
|
---|
33 | ENDLOCAL
|
---|
34 |
|
---|
35 | :getfilehash
|
---|
36 | set line=0
|
---|
37 | for /F "delims=" %%i in ('certutil.exe -hashfile !filename! SHA256') do (
|
---|
38 | set /a line+=1
|
---|
39 | if !line!==2 set filehash=%%i
|
---|
40 | )
|
---|
41 | goto :eof
|
---|
42 |
|
---|
43 | :testfilehash
|
---|
44 | if !hash!==!filehash! (
|
---|
45 | echo !filename!: OK
|
---|
46 | ) else (
|
---|
47 | echo !filename!: FAILED
|
---|
48 | REM bitsadmin /transfer 0adDownload %URL%/!filename! %cd%\!filename!
|
---|
49 | curl.exe -k -L -s %URL%/!filename! -o !filename!
|
---|
50 | )
|
---|
51 | goto :eof
|
---|
52 |
|
---|
53 | :UnZipFile <ExtractTo> <zipfile>
|
---|
54 | set vbs="%temp%\_.vbs"
|
---|
55 | if exist %vbs% del /f /q %vbs%
|
---|
56 | >>%vbs% echo set objShell = CreateObject("Shell.Application")
|
---|
57 | >>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
|
---|
58 | >>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
|
---|
59 | >>%vbs% echo Set objShell = Nothing
|
---|
60 | cscript //nologo %vbs%
|
---|
61 | if exist %vbs% del /f /q %vbs%
|
---|