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

Install WSL and MSYS2 on Windows Images #342

Closed
Show file tree
Hide file tree
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
30 changes: 30 additions & 0 deletions images/win/Windows2016-Azure.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,28 @@
"{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-WSL.ps1"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should make these changes to the Windows2016 - I don't see any requests asking for them and it just adds one more element to destabilize an older setup. @thejoebourneidentity thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I can see there is a request for the both Windows2016 and 2019 images in the issue #50.
We also planned to use bash from the WSL as default . Wouldn't it be confused if we'll use different bash.exe for these images?

]
},
{
"type": "windows-restart",
"restart_timeout": "30m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-UbuntuImage.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-MSYS2.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down Expand Up @@ -251,6 +269,18 @@
"{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WSL.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-MSYS2.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down
30 changes: 30 additions & 0 deletions images/win/Windows2019-Azure.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,28 @@
"{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-WSL.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout": "10m"
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-UbuntuImage.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-MSYS2.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand All @@ -220,6 +238,18 @@
"{{ template_dir }}/scripts/Installers/Validate-ServiceFabricSDK.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-WSL.ps1"
]
},
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Validate-MSYS2.ps1"
]
},
{
"type": "powershell",
"scripts":[
Expand Down
11 changes: 11 additions & 0 deletions images/win/scripts/Installers/Install-MSYS2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
################################################################################
## File: Install-MSYS2.ps1
## Desc: Install MSYS2 via chocolaty
################################################################################

Import-Module -Name ImageHelpers

$msys2Path = "C:\tools\msys64"
choco install msys2 -y --params "/InstallDir:$msys2Path"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm rather sure that the mingw toolchains can be installed through msys2 so ideally we do that here and remove the separate installation of mingw. Also, I wonder if it's possible to tell GitForWindows to just use the installed msys2/mingw rather than bring in it's own. Any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, how does this affect existing builds that depend on the currently installed mingw?

Copy link
Contributor

@alepauly alepauly Jan 31, 2020

Choose a reason for hiding this comment

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

another comment. if avoiding chocolatey is not substantially difficult, I think we should avoid it since waiting for choco packages adds another layer of delay and potential problems that we can't control. This comment by @eine suggests it should be easy enough to just untar and execute setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Re using the tar, I created an Install-MSYS2.ps1 script mentioned in Issue #30 comment. Also installs typical MSYS2 shell tools and basic 32 & 64 bit compilers.

Having used MSYS2 for a while, the main tar is not revised often, as the current release is dated 2019-May-24. Hence, the more important code is the update code, which hopefully can be run any time images are updated...

Copy link

Choose a reason for hiding this comment

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

Hence, the more important code is the update code, which hopefully can be run any time images are updated...

I beg to differ. Updating by default prevents users from testing their tools on a stable environment.

Copy link
Contributor Author

@AndreyMaslennikov AndreyMaslennikov Feb 6, 2020

Choose a reason for hiding this comment

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

@alepauly, MSYS2 installation is already implemented in the #355 PR. Could you please take a look at this PR? If it looks good for you, we probably should merge #355 (after adding some tests), and remove MSYS2 installation from this PR. What do you think about it?


Add-MachinePathItem $msys2Path
33 changes: 33 additions & 0 deletions images/win/scripts/Installers/Install-UbuntuImage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
################################################################################
## File: Install-UbuntuImage.ps1
## Desc: Install Ubuntu 18.04 Image for WSL
################################################################################

Import-Module -Name ImageHelpers

$ubuntuTempDir = "$env:AGENT_TEMPDIRECTORY\ubuntu"

if (-not (Test-Path $ubuntuTempDir)) {
New-Item -Path $ubuntuTempDir -ItemType Directory
}

Push-Location $ubuntuTempDir

$ubuntuZipName = "ubuntu.zip"
Invoke-WebRequest -Uri "https://aka.ms/wsl-ubuntu-1804" -OutFile $ubuntuZipName

$ubuntuPath = "C:\tools\ubuntu"
if (-not (Test-Path $ubuntuPath)) {
New-Item -Path $ubuntuPath -ItemType Directory
}

Expand-Archive -Path $ubuntuZipName -DestinationPath $ubuntuPath

Add-MachinePathItem $ubuntuPath

ubuntu1804 install --root
ubuntu1804 run apt update
ubuntu1804 run DEBIAN_FRONTEND=noninteractive apt upgrade -y

Pop-Location
Remove-Item $ubuntuTempDir -Recurse -Force
6 changes: 6 additions & 0 deletions images/win/scripts/Installers/Install-WSL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
################################################################################
## File: Install-WSL.ps1
## Desc: Install Windows subsystem for Linux
################################################################################

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
14 changes: 14 additions & 0 deletions images/win/scripts/Installers/Validate-MSYS2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
################################################################################
## File: Validate-MSYS2.ps1
## Desc: Validate MSYS2 installation
################################################################################

$msysCommand = "msys2"

Get-Command $msysCommand -ErrorAction SilentlyContinue -OutVariable commandInfo
if ($commandInfo) {
Write-Host "$msysCommand is successfully installed"
} else {
Write-Host "$msysCommand command unavailable"
exit 1
}
11 changes: 11 additions & 0 deletions images/win/scripts/Installers/Validate-WSL.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
################################################################################
## File: Validate-WSL.ps1
## Desc: Validate Windows Subsystem for Linux installation
################################################################################

$FeatureInfo = (Get-WindowsOptionalFeature -Online | Where FeatureName -eq Microsoft-Windows-Subsystem-Linux)

if ($FeatureInfo.State -eq "Disabled") {
Write-Host "Microsoft-Windows-Subsystem-Linux is Disabled"
exit 1
}