FS-4768 4768-again applied

This commit is contained in:
Jeff Lenk 2013-01-09 09:20:28 -06:00
parent 8e892abdef
commit 1a3323a9d1

View File

@ -4,7 +4,6 @@
' David A. Horner http://dave.thehorners.com ' David A. Horner http://dave.thehorners.com
'---------------------------------------------- '----------------------------------------------
'On Error Resume Next
' ************** ' **************
' Initialization ' Initialization
' ************** ' **************
@ -36,14 +35,11 @@ If UseWgetEXE Then
GetWgetEXE UtilsDir GetWgetEXE UtilsDir
End If End If
GetCompressionTools UtilsDir
If objArgs.Count >=3 Then If objArgs.Count >=3 Then
Select Case objArgs(0) Select Case objArgs(0)
Case "Get" Case "Get"
Wget objArgs(1), Showpath(objArgs(2)) Wget objArgs(1), Showpath(objArgs(2))
Case "GetUnzip" Case "GetUnzip"
WgetUnCompress objArgs(1), Showpath(objArgs(2)) WgetUnCompress objArgs(1), Showpath(objArgs(2))
Case "GetUnzipSounds" Case "GetUnzipSounds"
WgetSounds objArgs(1), objArgs(2), Showpath(objArgs(3)), objArgs(4) WgetSounds objArgs(1), objArgs(2), Showpath(objArgs(3)), objArgs(4)
@ -96,26 +92,34 @@ Sub WgetUnCompress(URL, DestFolder)
End Sub End Sub
Sub GetCompressionTools(DestFolder) Sub GetCompressionTools(DestFolder)
Dim oExec
Dim tries Dim tries
Dim max_tries
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
tries = 0 tries = 0
While Not FSO.FileExists(DestFolder & "7za.exe") And tries < 2 max_tries = 10
WScript.Sleep(Int(10000*Rnd)) If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
If Not FSO.FileExists(DestFolder & "7za.tag") And Not FSO.FileExists(DestFolder & "7za.exe") Then If Not FSO.FileExists(DestFolder & "7za.exe") Then
Set MyFile = fso.CreateTextFile(DestFolder & "7za.tag", True) On Error Resume Next
Set MyFile = FSO.CreateTextFile(DestFolder & "7za.tag", False)
If Err <> 0 Then Wscript.echo("Downloading 7za: " & DestFolder & "7za.tag - " & Err.Description) End If
On Error Goto 0
If Not IsEmpty(MyFile) Then
MyFile.WriteLine("This file marks a pending download for 7za.exe so we don't download it twice at the same time") MyFile.WriteLine("This file marks a pending download for 7za.exe so we don't download it twice at the same time")
MyFile.Close MyFile.Close
Wget ToolsBase & "7za.exe", DestFolder
Wget ToolsBase & "7za.exe", DestFolder FSO.DeleteFile DestFolder & "7za.tag", true
Wscript.echo("Downloaded 7za.exe")
FSO.DeleteFile DestFolder & "7za.tag" ,true End If
Else WScript.Sleep(500)
WScript.Sleep(5000) End If
tries = tries + 1 Do While FSO.FileExists(DestFolder & "7za.tag") And tries < max_tries
End If Wscript.echo("Waiting for 7za.exe to be downloaded")
WEnd WScript.Sleep(1000)
tries = tries + 1
Loop
If tries = max_tries Then
Wscript.echo("ERROR: Download of 7za.exe takes too much time")
Wscript.quit 99
End If
End Sub End Sub
Sub GetWgetEXE(DestFolder) Sub GetWgetEXE(DestFolder)
@ -127,13 +131,18 @@ Sub GetWgetEXE(DestFolder)
End Sub End Sub
Function Strip(Str) Function Strip(Str)
Set oRE = New Regexp Set oRE = New Regexp
oRE.Pattern = "[\W_]" oRE.Pattern = "[\W_]"
oRE.Global = True oRE.Global = True
Strip=oRE.Replace(Str, "") Strip = Right(oRE.Replace(Str, ""), 20)
End Function End Function
Sub UnCompress(Archive, DestFolder) Sub UnCompress(Archive, DestFolder)
Dim Fn
Dim batname
GetCompressionTools UtilsDir
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat" batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"
wscript.echo("Extracting: " & Archive & " - using: " & batname) wscript.echo("Extracting: " & Archive & " - using: " & batname)
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True) Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
@ -143,44 +152,38 @@ Sub UnCompress(Archive, DestFolder)
Do Do
WScript.Echo OExec.StdOut.ReadLine() WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
wscript.echo("Ready extracting: " & Archive) wscript.echo("Ready extracting: " & Archive)
Fn = Left(Archive, Len(Archive)-3) Fn = Left(Archive, Len(Archive)-3)
If FSO.FileExists(Fn) Then If FSO.FileExists(Fn) Then
WScript.Sleep(100) Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)
wscript.echo("Processing: " & Fn & " - deleting " & batname)
FSO.DeleteFile UtilsDir & batname, True
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote ) MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
MyFile.Close MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname) Set oExec = WshShell.Exec(UtilsDir & batname)
Do Do
WScript.Echo OExec.StdOut.ReadLine() WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
wscript.echo("Ready extracting: " & Fn) wscript.echo("Ready extracting: " & Fn)
WScript.Sleep(500) WScript.Sleep(500)
wscript.echo("Deleting: " & Fn) wscript.echo("Deleting: " & Fn)
FSO.DeleteFile Fn,true FSO.DeleteFile Fn,true
End If End If
Fn= Fn & tar Fn = Fn & tar
If FSO.FileExists(Fn) Then If FSO.FileExists(Fn) Then
WScript.Sleep(100) Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)
wscript.echo("Processing: " & Fn & " - deleting " & batname)
FSO.DeleteFile UtilsDir & batname, True
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote ) MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )
MyFile.Close MyFile.Close
Set oExec = WshShell.Exec(UtilsDir & batname) Set oExec = WshShell.Exec(UtilsDir & batname)
Do Do
WScript.Echo OExec.StdOut.ReadLine() WScript.Echo OExec.StdOut.ReadLine()
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
wscript.echo("Ready extracting: " & Fn ) wscript.echo("Ready extracting: " & Fn )
WScript.Sleep(500) WScript.Sleep(500)
wscript.echo("Deleting: " & Fn) wscript.echo("Deleting: " & Fn)
FSO.DeleteFile Fn,true FSO.DeleteFile Fn,true
End If End If
WScript.Sleep(500) WScript.Sleep(500)
If FSO.FileExists(UtilsDir & batname)Then If FSO.FileExists(UtilsDir & batname) Then
FSO.DeleteFile UtilsDir & batname, True FSO.DeleteFile UtilsDir & batname, True
End If End If
End Sub End Sub
@ -192,8 +195,8 @@ Sub Wget(URL, DestFolder)
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
If UseWgetEXE Then If UseWgetEXE Then
Wscript.echo("Downloading (wget): " & URL) Wscript.echo("wget: " & URL)
batname = "tmp" & CStr(Int(100000*Rnd)) & ".bat" batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
Set MyFile = fso.CreateTextFile(UtilsDir & batname, True) Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
MyFile.WriteLine("@cd " & quote & DestFolder & quote) MyFile.WriteLine("@cd " & quote & DestFolder & quote)
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL) MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
@ -204,11 +207,11 @@ Sub Wget(URL, DestFolder)
Loop While Not OExec.StdOut.atEndOfStream Loop While Not OExec.StdOut.atEndOfStream
Else Else
Wscript.echo("Downloading (HTTP GET): " & URL) Wscript.echo("XMLHTTP GET: " & URL)
xml.Open "GET", URL, False xml.Open "GET", URL, False
xml.Send xml.Send
Const adTypeBinary = 1 Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2 Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1 Const adSaveCreateNotExist = 1
@ -373,7 +376,7 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
'Get revision hash 'Get revision hash
strRevision = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=10 --abbrev-commit HEAD") strRevision = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=10 --abbrev-commit HEAD")
strRevisionHuman = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=7 --abbrev-commit HEAD") strRevisionHuman = ExecAndGetResult(tmpFolder, VersionDir, "git rev-list -n1 --abbrev=7 --abbrev-commit HEAD")
If strLastCommit <> "" And strLastCommitHuman <> "" And strRevision <> "" And strRevisionHuman <> "" Then If strLastCommit <> "" And strLastCommitHuman <> "" And strRevision <> "" And strRevisionHuman <> "" Then
'Bild version string 'Bild version string
strGitVer = "+git~" & strLastCommit & "~" & strRevision strGitVer = "+git~" & strLastCommit & "~" & strRevision
@ -416,3 +419,4 @@ Sub CreateVersion(tmpFolder, VersionDir, includebase, includedest)
End If End If
End Sub End Sub