Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/stage1/stage1.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
)
if not exist "%GG_CACHE_DIR%" mkdir "%GG_CACHE_DIR%"
powershell -c "sc m2 ([byte[]](gc '%0' -Encoding Byte | select -Skip AAAA)) -Encoding Byte"
tar -zxf m2 -C "%GG_CACHE_DIR%"
: Git's GNU tar shadows tar on PATH and cannot take "C:" paths (#291)
set "GG_TAR=%SystemRoot%\System32\tar.exe"
if not exist "%GG_TAR%" set "GG_TAR=tar"
"%GG_TAR%" -zxf m2 -C "%GG_CACHE_DIR%"
del m2
if not exist "%GG_CACHE_DIR%\gg-VERVER\stage2.ps1" (
echo gg: could not unpack into "%GG_CACHE_DIR%"
exit /b 1
)
powershell -executionpolicy bypass -file "%GG_CACHE_DIR%\gg-VERVER\stage2.ps1" %*
exit /b %errorlevel%
BATCH
15 changes: 14 additions & 1 deletion src/stage2/stage2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,20 @@ if ($hash)
# stage3, so verify ourselves. Catches a tampered blob as well as
# the boring case: a truncated-but-non-empty download. -ne is
# case-insensitive, so uppercase vs lowercase hex is fine.
$actualHash = (Get-FileHash $tempFile -Algorithm SHA512).Hash
# Hash via .NET, not Get-FileHash: that one lives in a script module
# which PowerShell 7 shadows with its Core-only copy, so a child
# Windows PowerShell can't load it and the cmdlet vanishes (#292).
$sha512 = [System.Security.Cryptography.SHA512]::Create()
$stream = [System.IO.File]::OpenRead($tempFile)
try
{
$actualHash = [BitConverter]::ToString($sha512.ComputeHash($stream)).Replace('-', '')
}
finally
{
$stream.Dispose()
$sha512.Dispose()
}
if ($actualHash -ne $hash)
{
Write-Host "Hash mismatch: expected $hash, got $actualHash"
Expand Down
Loading