-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install MSYS2 to Windows. #632
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
################################################################################ | ||
## File: Install-Msys2.ps1 | ||
## Desc: Install Msys2 and 64-bit gcc, cmake, & llvm (32-bit commented out) | ||
################################################################################ | ||
|
||
# References | ||
# https://github.com/msys2/MINGW-packages/blob/master/azure-pipelines.yml | ||
# https://packages.msys2.org/group/ | ||
|
||
$origPath = $env:PATH | ||
$gitPath = "$env:ProgramFiles\Git" | ||
|
||
# get info from https://sourceforge.net/projects/msys2/files/Base/x86_64/ | ||
$msys2Uri = "http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.tar.xz" | ||
$msys2File = "$env:TEMP\msys2.tar.xz" | ||
|
||
# Download the latest msys2 x86_64 | ||
Write-Host "Starting msys2 download" | ||
(New-Object System.Net.WebClient).DownloadFile($msys2Uri, $msys2File) | ||
Write-Host "Finished download" | ||
|
||
$msys2FileU = "/$msys2File".replace(':', '') | ||
|
||
$tar = "$gitPath\usr\bin\tar.exe" | ||
|
||
# extract tar.xz to C:\ | ||
Write-Host "Starting msys2 extraction" | ||
&$tar -Jxf $msys2FileU -C /c/ | ||
Remove-Item $msys2File | ||
Write-Host "Finished extraction" | ||
|
||
# Add msys2 bin tools folders to PATH temporary | ||
$env:PATH = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;$origPath" | ||
|
||
Write-Host "bash pacman-key --init" | ||
bash.exe -c "pacman-key --init 2>&1" | ||
|
||
Write-Host "bash pacman-key --populate msys2" | ||
bash.exe -c "pacman-key --populate msys2 2>&1" | ||
|
||
Write-Host "pacman --noconfirm -Syyuu" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref #342 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is based on @MSP-Greg suggested one that's why it's here. I'd prefer to wait for image deployment and then we can collect some feedback about working scenarios and decide if this approach suits or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #342 was previous, and it was ignored. I don't think that being based on some other PR is meaningful in this case. Actually, I'm good with the merged solution, even though it constraints the possible use cases. As commented in previous discussions, users can keep using other custom MSYS2 installations through action setup-msys2. I'd just like it to be explicitly documented, so that users of GitHub Actions are aware that this is not a default MSYS2 install. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you provide your vision on documentation, please? What points should be mentioned? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. For example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @eine, we will add information about non-default MSYS2 installation to docs, thank you for your participate! |
||
pacman.exe -Syyuu --noconfirm | ||
pacman.exe -Syuu --noconfirm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, see #342 (comment) |
||
|
||
Write-Host "Install msys2 packages" | ||
pacman.exe -S --noconfirm --needed --noprogressbar base-devel compression | ||
|
||
# mingw package list | ||
$tools = "___clang ___cmake ___llvm ___toolchain ___ragel" | ||
|
||
# install mingw64 packages | ||
Write-Host "Install mingw64 packages" | ||
$pre = "mingw-w64-x86_64-" | ||
pacman.exe -S --noconfirm --needed --noprogressbar $tools.replace('___', $pre).split(' ') | ||
|
||
# install mingw32 packages | ||
Write-Host "Install mingw32 packages" | ||
$pre = "mingw-w64-i686-" | ||
pacman.exe -S --noconfirm --needed --noprogressbar $tools.replace('___', $pre).split(' ') | ||
|
||
# clean all packages to decrease image size | ||
Write-Host "Clean packages" | ||
pacman.exe -Scc --noconfirm | ||
|
||
Write-Host "Installed mingw64 packages" | ||
pacman.exe -Qs --noconfirm mingw-w64-x86_64- | ||
|
||
Write-Host "Installed mingw32 packages" | ||
pacman.exe -Qs --noconfirm mingw-w64-i686- | ||
|
||
Write-Host "Installed msys2 packages" | ||
pacman.exe -Qs --noconfirm | ||
|
||
Write-Host "MSYS2 installation completed" | ||
|
||
exit 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
################################################################################ | ||
## File: Validate-Msys2.ps1 | ||
## Desc: Validate Msys2 | ||
################################################################################ | ||
|
||
$msys2BinDir = "C:\msys64\usr\bin" | ||
$msys2mingwDir = "C:\msys64\mingw64\bin" | ||
|
||
$installedTools = @( | ||
"bash", | ||
"tar", | ||
"make" | ||
) | ||
|
||
$installedMinGWTools = @( | ||
"gcc", | ||
"cmake" | ||
) | ||
|
||
Write-Host "Check installed tools in msys2/usr/bin directory" | ||
$installedTools | ForEach-Object { | ||
$toolName = $_ | ||
try { | ||
Invoke-Expression "$msys2BinDir\$_ --version" | ||
} catch { | ||
Write-Host "$toolName was not installed in MSYS2 bin directory" | ||
Write-Error $_ | ||
exit 1 | ||
} | ||
} | ||
|
||
Write-Host "Check installed tools in msys2/mingw/bin directory" | ||
$installedMinGWTools | ForEach-Object { | ||
$toolName = $_ | ||
try { | ||
Invoke-Expression "$msys2mingwDir\$_ --version" | ||
} catch { | ||
Write-Error "$toolName was not installed in MSYS2 mingw bin directory" | ||
Write-Error $_ | ||
exit 1 | ||
} | ||
} | ||
|
||
# Adding description of the software to Markdown | ||
|
||
function Get-ToolVersion { | ||
param( | ||
[string] $ToolPath, | ||
[int] $VersionLineNumber | ||
) | ||
|
||
$toolRawVersion = Invoke-Expression "$ToolPath --version" | ||
$toolRawVersion.Split([System.Environment]::NewLine)[$VersionLineNumber] -match "\d+\.\d+(\.\d+)?" | Out-Null | ||
$toolVersion = $matches[0] | ||
return $toolVersion | ||
} | ||
|
||
$SoftwareName = "MSYS2" | ||
$pacmanVersion = Get-ToolVersion -ToolPath "$msys2BinDir/pacman" -VersionLineNumber 1 | ||
$bashVersion = Get-ToolVersion -ToolPath "$msys2BinDir/bash" -VersionLineNumber 0 | ||
$gccVersion = Get-ToolVersion -ToolPath "$msys2mingwDir/gcc" -VersionLineNumber 0 | ||
$tarVersion = Get-ToolVersion -ToolPath "$msys2BinDir/tar" -VersionLineNumber 0 | ||
|
||
$Description = @" | ||
_Tool versions_ | ||
_pacman:_ $pacmanVersion<br/> | ||
_bash:_ $bashVersion<br/> | ||
_gcc:_ $gccVersion<br/> | ||
_tar:_ $tarVersion<br/> | ||
MSYS2 location: C:\msys64 | ||
"@ | ||
|
||
Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more recent release is available at https://github.com/msys2/msys2-installer/releases. Nightly releases are available too. It might be worth updating. Moreover, releases are hosted on GitHub.
At the same time, since everything is updated anyway, it would be desirable to retrieve the non-base package.