Skip to content
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

Windows - Install-Msys2.ps1 - minor reliability, taskkill, logging #928

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 26 additions & 29 deletions images/win/scripts/Installers/Install-Msys2.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
################################################################################
## File: Install-Msys2.ps1
## Desc: Install Msys2 and 64-bit gcc, cmake, & llvm (32-bit commented out)
## Desc: Install Msys2 and 64 & 32 bit gcc, cmake, & llvm
################################################################################

# References
# https://github.com/msys2/MINGW-packages/blob/master/azure-pipelines.yml
# https://packages.msys2.org/group/

$dash = "-" * 40

$origPath = $env:PATH
$gitPath = "$env:ProgramFiles\Git"

Expand All @@ -15,11 +17,9 @@ $msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/la
$msys2Uri = ((Invoke-RestMethod $msys2_release).assets | Where-Object {
$_.name -match "x86_64" -and $_.name.EndsWith("tar.xz") }).browser_download_url

$msys2File = "$env:TEMP\msys2.tar.xz"

# Download the latest msys2 x86_64
# Download the latest msys2 x86_64, filename includes release date
Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])"
(New-Object System.Net.WebClient).DownloadFile($msys2Uri, $msys2File)
$msys2File = Start-DownloadWithRetry -Url $msys2Uri
Write-Host "Finished download"

# nix style path for tar
Expand All @@ -31,63 +31,60 @@ $env:PATH = "$gitPath\usr\bin;$gitPath\mingw64\bin;$origPath"
$tar = "$gitPath\usr\bin\tar.exe"

# extract tar.xz to C:\
Write-Host "Starting msys2 extraction from $msys2FileU"
Write-Host "Starting msys2 extraction"
&$tar -xJf $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"
Write-Host "`n$dash 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 -Sy --noconfirm --needed pacman"
pacman -Sy --noconfirm --needed pacman
pacman -Su --noconfirm

# Force stop gpg-agent to continue installation
Get-Process gpg-agent -ErrorAction SilentlyContinue | Stop-Process -Force

Write-Host "pacman --noconfirm -Syyuu"
Write-Host "`n$dash pacman --noconfirm -Syyuu"
pacman.exe -Syyuu --noconfirm
pacman.exe -Syuu --noconfirm
taskkill /f /fi "MODULES eq msys-2.0.dll"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary since we're installing?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alepauly, see #906 (comment). The procedure in this PR is different from the recommended in those references (-Syyuu vs -Syuu, and -Syuu vs -Suu). However, I think that this first execution of taskkill /f /fi "MODULES eq msys-2.0.dll" is required. I'm not sure about others, tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I'd err on the cautious side, as the script should be bullet-proof. I intend to keep an eye on future CI logs to see if all the taskkill statements are needed. Some were included based on doing the install in Actions (mult vm's on one system), which may not be the case for the Pipeliines runs...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MSP-Greg, I think that the first y is irrelevant (i.e. Syyuu or Syuu). However, I believe that using y in following statements is what might make taskkill to be required again. Anyway, this should be fixed upstream, albeit "experimental" (https://github.com/msys2/msys2-installer/releases/tag/2020-05-22). We should not need it in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eine

Anyway, this should be fixed upstream

As mentioned above, 'the script should be bullet-proof'. If an extra few seconds are added to the install time to do that, so be it. As MSYS2 is tested better re scripted install, etc, the install script may be able to be simplified.

Both Ruby itself and several extension gems are running CI using the new MSYS2 install, and all are passing with no changes. All are using the gcc tools, the bash shell is used less frequently.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Ruby itself and several extension gems are running CI using the new MSYS2 install, and all are passing with no changes. All are using the gcc tools, the bash shell is used less frequently.

In fact, most users of eine/setup-msys2 are using update: true. Hence, apart from the Ruby extensions gems, there is intensive testing going on. See msys2/setup-msys2#20. For example in ghdl/ghdl:actions nightly packages for MSYS2 are being built with setup-msys2.

Write-Host "`n$dash pacman --noconfirm -Syuu (2nd pass)"
pacman.exe -Syuu --noconfirm
taskkill /f /fi "MODULES eq msys-2.0.dll"

Write-Host "Install msys2 packages"
Write-Host "`n$dash Install msys2 packages"
pacman.exe -S --noconfirm --needed --noprogressbar base-devel compression
taskkill /f /fi "MODULES eq msys-2.0.dll"

Write-Host "Remove p7zip/7z package due to conflicts"
Write-Host "`n$dash Remove p7zip/7z package due to conflicts"
pacman.exe -R --noconfirm --noprogressbar p7zip

# mingw package list
$tools = "___clang ___cmake ___llvm ___toolchain ___ragel"

# install mingw64 packages
Write-Host "Install mingw64 packages"
Write-Host "`n$dash 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"
Write-Host "`n$dash 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"
Write-Host "`n$dash Clean packages"
pacman.exe -Scc --noconfirm

Write-Host "Installed mingw64 packages"
pacman.exe -Qs --noconfirm mingw-w64-x86_64-
Write-Host "`n$dash Installed mingw64 packages"
pacman.exe -Q | grep ^mingw-w64-x86_64-

Write-Host "Installed mingw32 packages"
pacman.exe -Qs --noconfirm mingw-w64-i686-
Write-Host "`n$dash Installed mingw32 packages"
pacman.exe -Q | grep ^mingw-w64-i686-

Write-Host "Installed msys2 packages"
pacman.exe -Qs --noconfirm
Write-Host "`n$dash Installed msys2 packages"
pacman.exe -Q | grep -v ^mingw-w64-

Write-Host "MSYS2 installation completed"
Write-Host "`nMSYS2 installation completed"

exit 0
exit 0