diff --git a/src/stage1/stage1.bat b/src/stage1/stage1.bat index ec9e210..55dfd10 100644 --- a/src/stage1/stage1.bat +++ b/src/stage1/stage1.bat @@ -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 diff --git a/src/stage2/stage2.ps1 b/src/stage2/stage2.ps1 index 89d3e2c..b688c48 100644 --- a/src/stage2/stage2.ps1 +++ b/src/stage2/stage2.ps1 @@ -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"