2017-02-27 02:16:48 -05:00
|
|
|
:: Usage:
|
|
|
|
:: call prepare-msys2.bat [reinstall|clean]
|
|
|
|
|
|
|
|
setlocal enabledelayedexpansion
|
|
|
|
|
|
|
|
if "%EnvMSYS2Path%"=="" exit /B 1
|
|
|
|
if "%MSYS2Architecture%"=="" exit /B 1
|
|
|
|
if "%MSYS2Base%"=="" exit /B 1
|
|
|
|
if not exist "%EnvRootPath%"=="" exit /B 1
|
|
|
|
|
|
|
|
copy "%~dp0root\update-msys2.bat" "%EnvRootPath%" >nul
|
|
|
|
|
|
|
|
if "%~1"=="clean" (
|
|
|
|
%cecho% info "Clean MSYS2"
|
|
|
|
call "%ToolsPath%\remove-dir.bat" "%EnvMSYS2Path%"
|
|
|
|
goto exit
|
|
|
|
)
|
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
set MSYS2Version=20231026
|
2022-06-21 19:38:47 -04:00
|
|
|
|
|
|
|
set MSYS2Install=msys2-base-x86_64-%MSYS2Version%.sfx.exe
|
|
|
|
set MSYS2Url=https://github.com/msys2/msys2-installer/releases/download/%MSYS2Version:~0,4%-%MSYS2Version:~4,2%-%MSYS2Version:~6,2%/%MSYS2Install%
|
2023-11-10 14:44:48 -05:00
|
|
|
set MSYS2UnpackPath=%EnvMSYS2Path%\msys64
|
2022-06-21 19:38:47 -04:00
|
|
|
set CMakeInstall=cmake-3.19.0-win32-x86.zip
|
|
|
|
set CMakeUrl=https://github.com/Kitware/CMake/releases/download/v3.19.0/%CMakeInstall%
|
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
if exist "%MSYS2UnpackPath%\usr\bin\pacman.exe" (
|
2017-02-27 02:16:48 -05:00
|
|
|
if "%~1"=="reinstall" (
|
|
|
|
choice /M "Found existing MSYS2 version. Do you want to proceed?"
|
|
|
|
if !ERRORLEVEL!==2 goto exit
|
|
|
|
) else (
|
|
|
|
goto exit
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
if exist "%MSYS2UnpackPath%" (
|
2020-08-03 12:14:32 -04:00
|
|
|
%cecho% info "Remove previous MSYS2 version"
|
2023-11-10 14:44:48 -05:00
|
|
|
call "%ToolsPath%\remove-dir.bat" "%MSYS2UnpackPath%"
|
2020-08-03 12:14:32 -04:00
|
|
|
)
|
2017-02-27 02:16:48 -05:00
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
%cecho% info "Download MSYS2 installation files"
|
2017-02-27 02:16:48 -05:00
|
|
|
if not exist "%EnvDownloadPath%\%MSYS2Install%" call "%ToolsPath%\download-file.bat" "%MSYS2Url%" "%EnvDownloadPath%\%MSYS2Install%"
|
|
|
|
if not exist "%EnvDownloadPath%\%MSYS2Install%" %cecho% error "Cannot download MSYS" & goto error
|
|
|
|
|
|
|
|
if not exist "%EnvDownloadPath%\%CMakeInstall%" call "%ToolsPath%\download-file.bat" "%CMakeUrl%" "%EnvDownloadPath%\%CMakeInstall%"
|
|
|
|
if not exist "%EnvDownloadPath%\%CMakeInstall%" %cecho% error "Cannot download CMake" & goto error
|
|
|
|
|
|
|
|
%cecho% info "Unpack MSYS2"
|
2022-06-21 19:38:47 -04:00
|
|
|
"%EnvDownloadPath%\%MSYS2Install%" -y -o"%EnvMSYS2Path%"
|
2017-02-27 02:16:48 -05:00
|
|
|
|
|
|
|
%cecho% info "Unpack CMake"
|
2023-11-10 14:44:48 -05:00
|
|
|
"%EnvSevenZipExe%" x -o"%MSYS2UnpackPath%" "%EnvDownloadPath%\%CMakeInstall%" -y -bso0
|
2017-02-27 02:16:48 -05:00
|
|
|
|
|
|
|
%cecho% info "Install CMake"
|
|
|
|
set CMakeVersion=
|
2023-11-10 14:44:48 -05:00
|
|
|
for /D %%F in (%MSYS2UnpackPath%\cmake*) do set CMakeVersion=%%~nxF
|
2017-02-27 02:16:48 -05:00
|
|
|
if "%CMakeVersion%"=="" %cecho% error "CMake version not found." & goto :exit
|
|
|
|
%cecho% info "Found CMake version %CMakeVersion%"
|
|
|
|
|
|
|
|
set FoundProfile=
|
2023-11-10 14:44:48 -05:00
|
|
|
for /f "tokens=3" %%F in ('find /c /i "%CMakeVersion%" "%MSYS2UnpackPath%\etc\profile"') do set FoundProfile=%%F
|
2017-02-27 02:16:48 -05:00
|
|
|
|
|
|
|
if "%FoundProfile%"=="0" (
|
2023-11-10 14:44:48 -05:00
|
|
|
echo export PATH="${PATH}:/%CMakeVersion%/bin">>"%MSYS2UnpackPath%\etc\profile"
|
2017-02-27 02:16:48 -05:00
|
|
|
)
|
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
set MSYS2SH=%MSYS2UnpackPath%\usr\bin\sh
|
2017-02-27 02:16:48 -05:00
|
|
|
|
|
|
|
%cecho% info "Initialize MSYS2"
|
2021-11-03 11:23:35 -04:00
|
|
|
"%MSYS2SH%" -lc "yes | pacman --noconfirm -Syuu msys2-keyring"
|
2023-05-08 03:36:18 -04:00
|
|
|
"%MSYS2SH%" -lc "pacman --noconfirm -Sy"
|
2021-11-03 11:23:35 -04:00
|
|
|
"%MSYS2SH%" -lc "pacman --noconfirm -Su"
|
2017-02-27 02:16:48 -05:00
|
|
|
|
2023-11-10 14:44:48 -05:00
|
|
|
call "%MSYS2UnpackPath%\autorebase.bat"
|
2017-02-27 02:16:48 -05:00
|
|
|
|
|
|
|
:exit
|
|
|
|
endlocal
|
|
|
|
exit /B 0
|
|
|
|
|
|
|
|
:error
|
|
|
|
endlocal
|
|
|
|
exit /B 1
|