From 17aa97248fa3aa60d46a1a355ec8d2f5705bad38 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 10 Jan 2025 07:22:25 -0800 Subject: [PATCH] Installer: make the hashsum verification more robust on Windows --- start_windows.bat | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/start_windows.bat b/start_windows.bat index c167cdc5..960cfdb7 100755 --- a/start_windows.bat +++ b/start_windows.bat @@ -41,10 +41,18 @@ if "%conda_exists%" == "F" ( mkdir "%INSTALL_DIR%" call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe" || ( echo. && echo Miniconda failed to download. && goto end ) + :: Try CertUtil first for /f %%a in ('CertUtil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" SHA256 ^| find /i /v " " ^| find /i "%MINICONDA_CHECKSUM%"') do ( set "output=%%a" ) + :: If CertUtil fails, try PowerShell + if not defined output ( + for /f %%a in ('powershell -Command "if((Get-FileHash \"%INSTALL_DIR%\miniconda_installer.exe\" -Algorithm SHA256).Hash -eq ''%MINICONDA_CHECKSUM%''){echo true}"') do ( + set "output=%%a" + ) + ) + if not defined output ( echo The checksum verification for miniconda_installer.exe has failed. del "%INSTALL_DIR%\miniconda_installer.exe"