mirror of
git://code.qt.io/qt/qt5.git
synced 2026-03-26 08:22:25 +08:00
windows provisioning: automatically choose the right hash algorithm
...based on the length of the given hash.
Additionally use -ine for string comparison, which explicitly does
case-insensitive comparison. That is what the function needs, previously
it was done implicitly by -ne.
And remove MD5, it's not used anywhere.
Pick-to: 6.10 6.8 6.5
Change-Id: Ib4303737e5e1d743dd0be1a8f829be9a0db2bc04
Reviewed-by: Tero Heikkinen <tero.heikkinen@qt.io>
(cherry picked from commit e5e813ef90)
This commit is contained in:
@@ -10,7 +10,7 @@ $sdkChecksumSha1 = "8fe98c00fde0f524760bb9021f438bd7d9304a69"
|
|||||||
$package_path = "C:\Windows\Temp\$package"
|
$package_path = "C:\Windows\Temp\$package"
|
||||||
|
|
||||||
Download $officialUrl $cachedUrl $package_path
|
Download $officialUrl $cachedUrl $package_path
|
||||||
Verify-Checksum $package_path $sdkChecksumSha1 sha1
|
Verify-Checksum $package_path $sdkChecksumSha1
|
||||||
Write-Host "Installing DirectX SDK"
|
Write-Host "Installing DirectX SDK"
|
||||||
Run-Executable $package_path "/u"
|
Run-Executable $package_path "/u"
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,20 @@ function Verify-Checksum
|
|||||||
{
|
{
|
||||||
Param (
|
Param (
|
||||||
[string]$File=$(throw("You must specify a filename to get the checksum of.")),
|
[string]$File=$(throw("You must specify a filename to get the checksum of.")),
|
||||||
[string]$Expected=$(throw("Checksum required")),
|
[string]$Expected=$(throw("Checksum required"))
|
||||||
[ValidateSet("sha256","sha1","md5")][string]$Algorithm="sha1"
|
|
||||||
)
|
)
|
||||||
|
switch ($Expected.Length) {
|
||||||
|
40 { $Algorithm = "SHA1" }
|
||||||
|
64 { $Algorithm = "SHA256" }
|
||||||
|
default { throw "Unknown hash length for: $Expected" }
|
||||||
|
}
|
||||||
Write-Host "Verifying checksum of $File"
|
Write-Host "Verifying checksum of $File"
|
||||||
$fs = new-object System.IO.FileStream $File, "Open"
|
$fs = new-object System.IO.FileStream $File, "Open"
|
||||||
$algo = [type]"System.Security.Cryptography.$Algorithm"
|
$algo = [type]"System.Security.Cryptography.$Algorithm"
|
||||||
$crypto = $algo::Create()
|
$crypto = $algo::Create()
|
||||||
$hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace("-", "")
|
$hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace("-", "")
|
||||||
$fs.Close()
|
$fs.Close()
|
||||||
if ($hash -ne $Expected) {
|
if ($hash -ine $Expected) {
|
||||||
throw "Checksum verification failed, got: '$hash' expected: '$Expected'"
|
throw "Checksum verification failed, got: '$hash' expected: '$Expected'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ $url_official = "https://go.dev/dl/go" + $version + ".windows-" + $arch + ".msi"
|
|||||||
|
|
||||||
Write-Host "Fetching Go $version..."
|
Write-Host "Fetching Go $version..."
|
||||||
Download $url_official $url_cache $goPackage
|
Download $url_official $url_cache $goPackage
|
||||||
Verify-Checksum $goPackage $sha256 sha256
|
Verify-Checksum $goPackage $sha256
|
||||||
Write-Host "Installing Go $version..."
|
Write-Host "Installing Go $version..."
|
||||||
Run-Executable "msiexec" "/quiet /i $goPackage"
|
Run-Executable "msiexec" "/quiet /i $goPackage"
|
||||||
Write-Output "Go = $version" >> ~\versions.txt
|
Write-Output "Go = $version" >> ~\versions.txt
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ $install_location = "c:\Utils\$prog"
|
|||||||
|
|
||||||
$tmp_location = "c:\users\qt\downloads"
|
$tmp_location = "c:\users\qt\downloads"
|
||||||
Download $cached_url $cached_url "$tmp_location\$pkg"
|
Download $cached_url $cached_url "$tmp_location\$pkg"
|
||||||
Verify-Checksum "$tmp_location\$pkg" $sha1 sha1
|
Verify-Checksum "$tmp_location\$pkg" $sha1
|
||||||
Download $dep_cached_url $dep_cached_url "$tmp_location\$dep_pkg"
|
Download $dep_cached_url $dep_cached_url "$tmp_location\$dep_pkg"
|
||||||
Verify-Checksum "$tmp_location\$dep_pkg" $dep_sha1 sha1
|
Verify-Checksum "$tmp_location\$dep_pkg" $dep_sha1
|
||||||
|
|
||||||
Extract-7Zip "$tmp_location\$pkg" $install_location
|
Extract-7Zip "$tmp_location\$pkg" $install_location
|
||||||
Extract-7Zip "$tmp_location\$dep_pkg" $install_location
|
Extract-7Zip "$tmp_location\$dep_pkg" $install_location
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ $vcpkgExeCacheUrl = "\\ci-files01-hki.ci.qt.io\provisioning\vcpkg\vcpkg-$nonDott
|
|||||||
$vcpkgExe = "C:\Windows\Temp\vcpkg.exe"
|
$vcpkgExe = "C:\Windows\Temp\vcpkg.exe"
|
||||||
|
|
||||||
Download "$vcpkgExeOfficialUrl" "$vcpkgExeCacheUrl" "$vcpkgExe"
|
Download "$vcpkgExeOfficialUrl" "$vcpkgExeCacheUrl" "$vcpkgExe"
|
||||||
Verify-Checksum $vcpkgExe $vcpkgExechecksum "sha256"
|
Verify-Checksum $vcpkgExe $vcpkgExechecksum
|
||||||
Move-Item "$vcpkgExe" -Destination "$vcpkgRoot" -Force
|
Move-Item "$vcpkgExe" -Destination "$vcpkgRoot" -Force
|
||||||
|
|
||||||
if(![System.IO.File]::Exists("$vcpkgRoot\vcpkg.exe")){
|
if(![System.IO.File]::Exists("$vcpkgRoot\vcpkg.exe")){
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ $tempfile = "C:\Windows\Temp\" + $filename_zip
|
|||||||
|
|
||||||
Write-Host "Fetching Telegraf $version..."
|
Write-Host "Fetching Telegraf $version..."
|
||||||
Download $url_official $url_cache $tempfile
|
Download $url_official $url_cache $tempfile
|
||||||
Verify-Checksum $tempfile $sha256 sha256
|
Verify-Checksum $tempfile $sha256
|
||||||
|
|
||||||
Write-Host "Installing telegraf.exe under C:\Utils\telegraf"
|
Write-Host "Installing telegraf.exe under C:\Utils\telegraf"
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ $internalUrl = "http://ci-files01-hki.ci.qt.io/input/windows/node-v$version-win-
|
|||||||
|
|
||||||
Write-Host "Installing Node.js"
|
Write-Host "Installing Node.js"
|
||||||
Download $externalUrl $internalUrl $package
|
Download $externalUrl $internalUrl $package
|
||||||
Verify-Checksum $package $sha256 "sha256"
|
Verify-Checksum $package $sha256
|
||||||
Extract-7Zip $package $targetFolder
|
Extract-7Zip $package $targetFolder
|
||||||
Add-Path $installFolder
|
Add-Path $installFolder
|
||||||
Remove $package
|
Remove $package
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ $script:package_path = "$packageRoot\\$nugetPackage"
|
|||||||
|
|
||||||
New-Item -ItemType Directory -Path "$packageRoot"
|
New-Item -ItemType Directory -Path "$packageRoot"
|
||||||
Download $officialUrl $cachedUrl $package_path
|
Download $officialUrl $cachedUrl $package_path
|
||||||
Verify-Checksum $package_path $sdkChecksumSha1 sha1
|
Verify-Checksum $package_path $sdkChecksumSha1
|
||||||
Write-Host "Installing Nuget"
|
Write-Host "Installing Nuget"
|
||||||
Run-Executable "$package_path" "install Microsoft.WindowsAppSDK -OutputDirectory $packageRoot"
|
Run-Executable "$package_path" "install Microsoft.WindowsAppSDK -OutputDirectory $packageRoot"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user