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

azlinux3 dnf packages for compiler installation #423

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.14
1.16.15
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public async Task CompilerInstallationRunsTheExpectedWorkloadCommandInWindowsFor
}

[Test]
public async Task CompilerInstallationInLinuxDefaultsToGcc10()
public async Task CompilerInstallationInLinuxDefaultsToEmpty()
{
this.mockFixture.Parameters = new Dictionary<string, IConvertible>();

Expand All @@ -246,15 +246,7 @@ public async Task CompilerInstallationInLinuxDefaultsToGcc10()
"sudo update-alternatives --remove-all gfortran",
"sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y",
"sudo apt update",
"sudo apt install build-essential gcc-10 g++-10 gfortran-10 -y --quiet",
"sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 " +
$"--slave /usr/bin/g++ g++ /usr/bin/g++-10 " +
$"--slave /usr/bin/gcov gcov /usr/bin/gcov-10 " +
$"--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-10 " +
$"--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-10 " +
$"--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-10",
"sudo update-alternatives --remove-all cpp",
"sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-10 100",
"sudo apt install build-essential gcc g++ gfortran -y --quiet"
};

int commandExecuted = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace VirtualClient.Dependencies
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -209,26 +208,59 @@ private Task InstallCygwinAsync(DependencyPath cygwinInstallationPath, EventCont
private async Task InstallGccAsync(string gccVersion, EventContext telemetryContext, CancellationToken cancellationToken)
{
LinuxDistributionInfo distro = await this.systemManager.GetLinuxDistributionAsync(cancellationToken);
gccVersion = (string.IsNullOrEmpty(gccVersion)) ? string.Empty : gccVersion;

switch (distro.LinuxDistribution)
{
case LinuxDistribution.Ubuntu:
case LinuxDistribution.Debian:
// default to 10
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
gccVersion = (string.IsNullOrEmpty(gccVersion)) ? "10" : gccVersion;
await this.ExecuteCommandAsync("add-apt-repository", $"ppa:ubuntu-toolchain-r/test -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("apt", $"update", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("apt", @$"install build-essential gcc-{gccVersion} g++-{gccVersion} gfortran-{gccVersion} -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
if (string.IsNullOrEmpty(gccVersion))
{
await this.ExecuteCommandAsync("apt", @$"install build-essential gcc g++ gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
}
else
{
await this.ExecuteCommandAsync("apt", @$"install build-essential gcc-{gccVersion} g++-{gccVersion} gfortran-{gccVersion} -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
}

break;

case LinuxDistribution.CentOS8:
case LinuxDistribution.RHEL8:
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
if (string.IsNullOrEmpty(gccVersion))
saibulusu marked this conversation as resolved.
Show resolved Hide resolved
{
await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install kernel-headers kernel-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install binutils -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install glibc-headers glibc-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install git -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install make gcc -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
}
else
{
await this.ExecuteCommandAsync("dnf", @$"install make gcc-toolset-{gccVersion} gcc-toolset-{gccVersion}-gcc-gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
}

break;

case LinuxDistribution.AzLinux:
if (!string.IsNullOrEmpty(gccVersion))
{
throw new Exception($"gcc version must not be supplied for {distro.LinuxDistribution}");
}

await this.RemoveAlternativesAsync(telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", @$"install make gcc-toolset-{gccVersion} gcc-toolset-{gccVersion}-gcc-gfortran -y --quiet", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.SetGccPriorityAsync(gccVersion, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install kernel-headers kernel-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install binutils -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install glibc-headers glibc-devel -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install git -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);
await this.ExecuteCommandAsync("dnf", "install gcc gfortran -y", Environment.CurrentDirectory, telemetryContext, cancellationToken);

break;

Expand Down Expand Up @@ -263,7 +295,7 @@ private async Task RemoveAlternativesAsync(EventContext telemetryContext, Cancel
}
}
}

private async Task SetGccPriorityAsync(string gccVersion, EventContext telemetryContext, CancellationToken cancellationToken)
{
string updateAlternativeArgument = $"--install /usr/bin/gcc gcc /usr/bin/gcc-{gccVersion} {gccVersion}0 " +
Expand Down
Loading