Ticket #1814: update.bat

File update.bat, 1.8 KB (added by hamletmun, 8 months ago)
Line 
1@echo off
2set curlver=8.2.1_7
3if 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
10REM BITS requires the HTTP server to return the Content-Length header
11set URL=https://trac.wildfiregames.com/export/HEAD/ps/trunk/binaries/system
12REM bitsadmin /transfer 0adDownload %URL%/SHA256SUMS %cd%\SHA256SUMS
13REM curl.exe -k -L -s %URL%/SHA256SUMS
14
15SETLOCAL EnableDelayedExpansion
16for /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)
33ENDLOCAL
34
35:getfilehash
36set line=0
37for /F "delims=" %%i in ('certutil.exe -hashfile !filename! SHA256') do (
38 set /a line+=1
39 if !line!==2 set filehash=%%i
40)
41goto :eof
42
43:testfilehash
44if !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)
51goto :eof
52
53:UnZipFile <ExtractTo> <zipfile>
54set vbs="%temp%\_.vbs"
55if 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
60cscript //nologo %vbs%
61if exist %vbs% del /f /q %vbs%