aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/build/scriptlib
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/build/scriptlib
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/build/scriptlib')
-rw-r--r--Src/external_dependencies/openmpt-trunk/build/scriptlib/Verify-File.ps118
-rw-r--r--Src/external_dependencies/openmpt-trunk/build/scriptlib/download.cmd17
-rw-r--r--Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack-zip.vbs38
-rw-r--r--Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack.cmd16
4 files changed, 89 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/build/scriptlib/Verify-File.ps1 b/Src/external_dependencies/openmpt-trunk/build/scriptlib/Verify-File.ps1
new file mode 100644
index 00000000..607de43d
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/build/scriptlib/Verify-File.ps1
@@ -0,0 +1,18 @@
+param([String]$filename="", [Int32]$filesize=0, [String]$hashvalue="", [String]$hashname="SHA512")
+Function Get-FileHashWin7([String] $FileName, $HashName) {
+ $FileStream = New-Object System.IO.FileStream($FileName,[System.IO.FileMode]::Open)
+ $StringBuilder = New-Object System.Text.StringBuilder
+ [System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash($FileStream)|%{[Void]$StringBuilder.Append($_.ToString("x2"))}
+ $FileStream.Close()
+ $StringBuilder.ToString()
+}
+Write-Output "Verify " $filename
+if ((Get-Item $filename).length -ne $filesize) {
+ Write-Output "Failed " $filename
+ exit 1
+}
+if ((Get-FileHashWin7 $filename $hashname) -ne $hashvalue) {
+ Write-Output "Failed " $filename
+ exit 1
+}
+exit 0
diff --git a/Src/external_dependencies/openmpt-trunk/build/scriptlib/download.cmd b/Src/external_dependencies/openmpt-trunk/build/scriptlib/download.cmd
new file mode 100644
index 00000000..b9d9ee6e
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/build/scriptlib/download.cmd
@@ -0,0 +1,17 @@
+rem bDOWNLOAD bAUTO URL FILE HASH SIZE
+echo URL %3
+if "%1" == "yes" (
+ if "%2" == "xauto" (
+ echo Check %3 ...
+ if exist "%~4" (
+ powershell -ExecutionPolicy Unrestricted .\build\scriptlib\Verify-File.ps1 -hashvalue %5 -filesize %6 -filename %4 || del /Q "%4"
+ )
+ )
+ if not exist "%~4" (
+ echo Download %3 ...
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%~3', '%~4')" || exit /B 1
+ )
+)
+echo Verify %4 ...
+powershell -ExecutionPolicy Unrestricted .\build\scriptlib\Verify-File.ps1 -hashvalue %5 -filesize %6 -filename %4 || exit /B 1
+exit /B 0
diff --git a/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack-zip.vbs b/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack-zip.vbs
new file mode 100644
index 00000000..6f55d8bd
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack-zip.vbs
@@ -0,0 +1,38 @@
+
+On Error Resume Next
+
+Set fso = CreateObject("Scripting.FileSystemObject")
+Set shell = CreateObject("Wscript.Shell")
+
+Sub UnZIP(zipfilename, destinationfolder)
+ With CreateObject("Shell.Application")
+ .NameSpace(destinationfolder).Copyhere .NameSpace(zipfilename).Items
+ End With
+End Sub
+
+zipfile = WScript.Arguments(0)
+If Err.Number <> 0 Then
+ WSCript.Quit 1
+End If
+
+outdir = WScript.Arguments(1)
+If Err.Number <> 0 Then
+ WSCript.Quit 1
+End If
+
+WScript.Echo zipfile
+WScript.Echo outdir
+
+If fso.FolderExists(fso.GetAbsolutePathName(outdir)) Then
+ fso.DeleteFolder fso.GetAbsolutePathName(outdir)
+End If
+
+fso.CreateFolder fso.GetAbsolutePathName(outdir)
+If Err.Number <> 0 Then
+ WSCript.Quit 1
+End If
+
+UnZIP fso.GetAbsolutePathName(zipfile), fso.GetAbsolutePathName(outdir)
+If Err.Number <> 0 Then
+ WSCript.Quit 1
+End If
diff --git a/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack.cmd b/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack.cmd
new file mode 100644
index 00000000..f4ab109b
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/build/scriptlib/unpack.cmd
@@ -0,0 +1,16 @@
+set MPT_GET_DESTDIR="%~1"
+set MPT_GET_FILE="%~2"
+set MPT_GET_SUBDIR="%~3"
+echo %MPT_GET_DESTDIR%
+if exist %MPT_GET_DESTDIR% rmdir /S /Q %MPT_GET_DESTDIR%
+if "%~3" == "." (
+ build\tools\7zip\7z.exe x -y -o%MPT_GET_DESTDIR% "%~2" || exit /B 1
+)
+if not "%~3" == "." (
+ if exist "%~1.tmp" rmdir /S /Q "%~1.tmp"
+ build\tools\7zip\7z.exe x -y -o"%~1.tmp" -ir!"%~3" "%~2" || exit /B 1
+ choice /C y /N /T 1 /D y
+ move /Y "%~1.tmp\%~3" %MPT_GET_DESTDIR% || exit /B 1
+ rmdir /S /Q "%~1.tmp"
+)
+exit /B 0