Skip to content

Commit

Permalink
Installer: validate the checksum for the miniconda installer on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Mar 10, 2024
1 parent cf06979 commit 52a3492
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions start_windows.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
setlocal enabledelayedexpansion

cd /D "%~dp0"

Expand All @@ -25,6 +26,7 @@ set INSTALL_DIR=%cd%\installer_files
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
set INSTALL_ENV_DIR=%cd%\installer_files\env
set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
set MINICONDA_CHECKSUM=307194e1f12bbeb52b083634e89cc67db4f7980bd542254b43d3309eaf7cb358
set conda_exists=F

@rem figure out whether git and conda needs to be installed
Expand All @@ -39,15 +41,27 @@ 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 )

for /f %%a in ('CertUtil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" SHA256 ^| find /i /v " " ^| find /i "%MINICONDA_CHECKSUM%"') do (
set "output=%%a"
)

if not defined output (
echo The checksum verification for miniconda_installer.exe has failed.
del "%INSTALL_DIR%\miniconda_installer.exe"
goto end
) else (
echo The checksum verification for miniconda_installer.exe has passed successfully.
)

echo Installing Miniconda to %CONDA_ROOT_PREFIX%
start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%

@rem test the conda binary
echo Miniconda version:
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version || ( echo. && echo Miniconda not found. && goto end )

@rem delete the Miniconda installer
del "%INSTALL_DIR%\miniconda_installer.exe"
@rem delete the Miniconda installer
del "%INSTALL_DIR%\miniconda_installer.exe"
)

@rem create the installer env
Expand Down

0 comments on commit 52a3492

Please sign in to comment.