mirror of
https://github.com/slorelee/wimbuilder2.git
synced 2025-05-06 18:25:51 +08:00
add Updater
This commit is contained in:
parent
bb0d6347c5
commit
031f0bdfa0
53
bin/_Updater.cmd
Normal file
53
bin/_Updater.cmd
Normal file
@ -0,0 +1,53 @@
|
||||
@echo off
|
||||
if "x%TMP_UPDATER%"=="x1" goto :UPDATE_MAIN
|
||||
cd /d "%~dp0..\"
|
||||
set "APP_ROOT=%cd%"
|
||||
set TMP_UPT=_Factory_\tmp
|
||||
if not exist "%TMP_UPT%\" md "%TMP_UPT%"
|
||||
if "x%TMP_UPDATER%"=="x1" goto :UPDATE_MAIN
|
||||
|
||||
copy /y "%~0" "%TMP_UPT%\" 1>nul
|
||||
copy /y "%~dpn0.vbs" "%TMP_UPT%\" 1>nul
|
||||
|
||||
del /f /a /q "%TMP_UPT%\local.md5"
|
||||
del /f /a /q "%TMP_UPT%\fciv.err"
|
||||
del /f /a /q "%TMP_UPT%\updatefile.list"
|
||||
|
||||
set TMP_UPDATER=1
|
||||
"%TMP_UPT%\%~nx0" %*
|
||||
|
||||
:UPDATE_MAIN
|
||||
|
||||
set APP_ARCH=x64
|
||||
if /i %PROCESSOR_IDENTIFIER:~0,3%==x86 set APP_ARCH=x86
|
||||
set "PATH=%APP_ROOT%\bin\%APP_ARCH%;%APP_ROOT%\bin;%PATH%"
|
||||
|
||||
set "TMP_UPT=%APP_ROOT%\%TMP_UPT%"
|
||||
cd /d "%TMP_UPT%"
|
||||
title Updater
|
||||
echo Updating ...
|
||||
echo.
|
||||
echo PHASE 1:Create local.MD5 mainifest ...
|
||||
echo %TMP_UPT%
|
||||
if exist "%TMP_UPT%\local.md5" goto :END_LOCAL_MD5
|
||||
echo Detect Projects ...
|
||||
fciv.exe -add "%APP_ROOT%\Projects" -r -bp "%APP_ROOT%" > "%TMP_UPT%\local.md5"
|
||||
echo Detect assets ...
|
||||
fciv.exe -add "%APP_ROOT%\assets" -r -bp "%APP_ROOT%" >> "%TMP_UPT%\local.md5"
|
||||
echo Detect bin ...
|
||||
fciv.exe -add "%APP_ROOT%\bin" -r -bp "%APP_ROOT%" >> "%TMP_UPT%\local.md5"
|
||||
echo Detect macros ...
|
||||
fciv.exe -add "%APP_ROOT%\lib\macros" -bp "%APP_ROOT%" >> "%TMP_UPT%\local.md5"
|
||||
fciv.exe -add "%APP_ROOT%\config.js" -wp >> "%TMP_UPT%\local.md5"
|
||||
fciv.exe -add "%APP_ROOT%\WimBuilder.cmd" -wp >> "%TMP_UPT%\local.md5"
|
||||
|
||||
:END_LOCAL_MD5
|
||||
echo PHASE 2:Download remote.MD5 mainifest ...
|
||||
|
||||
if exist "%TMP_UPT%\remote.md5" goto :END_REMOTE_MD5
|
||||
set remote_md5=https://github.com/slorelee/wimbuilder2/releases/download/update/remote.md5
|
||||
|
||||
aria2c.exe -c "%remote_md5%" -d "%TMP_UPT%" -o remote.md5
|
||||
:END_REMOTE_MD5
|
||||
|
||||
pause
|
78
bin/_Updater.vbs
Normal file
78
bin/_Updater.vbs
Normal file
@ -0,0 +1,78 @@
|
||||
Const OpenAsASCII = 0
|
||||
Const OpenAsUnicode = -1
|
||||
|
||||
Const FailIfExist = 0
|
||||
Const OverwriteIfExist = -1
|
||||
|
||||
Const ForReading = 1
|
||||
Const ForWriting = 2
|
||||
Const ForAppending = 8
|
||||
|
||||
Dim argCount:argCount = Wscript.Arguments.Count
|
||||
|
||||
If argCount = 0 Then
|
||||
'Wscript.Quit(1)
|
||||
End If
|
||||
|
||||
Dim inFile, outFile, inStream, outStream, inLine, FileSys, WshShell
|
||||
'inFile = Wscript.Arguments(0)
|
||||
'outFile = Wscript.Arguments(0) & "_"
|
||||
|
||||
Set WshShell = Wscript.CreateObject("Wscript.Shell")
|
||||
Set FileSys = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Set objLocalMD5 = CreateObject("Scripting.Dictionary")
|
||||
Set objRemoteMD5 = CreateObject("Scripting.Dictionary")
|
||||
|
||||
Dim res
|
||||
res = LoadHashToDict("local.md5", objLocalMD5)
|
||||
res = LoadHashToDict("remote.md5", objRemoteMD5)
|
||||
|
||||
For Each file In objLocalMD5
|
||||
'remove same files from objRemoteMD5
|
||||
If objLocalMD5.Item(file) = objRemoteMD5.Item(file) Then
|
||||
objRemoteMD5.Remove(file)
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim outstr
|
||||
outstr = vbCrLf
|
||||
For Each file In objRemoteMD5
|
||||
outstr = outstr & file & vbCrLf
|
||||
Next
|
||||
|
||||
outstr = Replace(outstr, "\", "/")
|
||||
outstr = Replace(outstr, vbCrLf & "projects/", vbCrLf & "Projects/")
|
||||
outstr = Replace(outstr, vbCrLf & "wimbuilder.cmd" & vbCrLf, vbCrLf & "WimBuilder.cmd" & vbCrLf)
|
||||
|
||||
Set outStream = FileSys.CreateTextFile("updatefile.list", OverwriteIfExist)
|
||||
outStream.Write outstr
|
||||
outStream.Close
|
||||
|
||||
Function LoadHashToDict(filename, dict)
|
||||
Set inStream = FileSys.OpenTextFile(filename, ForReading, FailIfNotExist)
|
||||
Do
|
||||
inLine = inStream.ReadLine
|
||||
If Left(inLine, 1) <> "" And Left(inLine, 1) <> "/" And _
|
||||
Left(inLine, 1) <> "S" And Left(inLine, 1) <> " " And _
|
||||
Left(inLine, 3) <> "End" And Left(inLine, 3) <> "Err" Then
|
||||
arr = Split(inLine, " ", 2)
|
||||
'If dict.Exists(arr(1)) Then
|
||||
' MsgBox( arr(1))
|
||||
'Else
|
||||
dict.Add arr(1), arr(0)
|
||||
'End If
|
||||
End If
|
||||
Loop Until inStream.AtEndOfStream
|
||||
inStream.Close
|
||||
LoadHashToDict = True
|
||||
End Function
|
||||
|
||||
Function RegKeyRePlacer(transFlag, str, okey, nkey)
|
||||
RegKeyRePlacer = str
|
||||
transFlag = 0
|
||||
If InStr(1, str, okey) = 1 Then
|
||||
RegKeyRePlacer = Replace(str, okey, nkey, 1, 1)
|
||||
transFlag = 1
|
||||
End If
|
||||
End Function
|
BIN
bin/fciv.exe
Normal file
BIN
bin/fciv.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user