Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3188 from janvorli/port-add-rhel6-detection
Browse files Browse the repository at this point in the history
Port to 2.0.0: Add RHEL 6 and CentOS 6 distro detection
  • Loading branch information
weshaggard committed Sep 14, 2017
2 parents e10d9cf + 69f6efc commit bb6dac8
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
30 changes: 30 additions & 0 deletions src/corehost/common/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pal::string_t pal::get_current_os_rid_platform()
{
pal::string_t ridOS;
pal::string_t versionFile(_X("/etc/os-release"));
pal::string_t rhelVersionFile(_X("/etc/redhat-release"));

if (pal::file_exists(versionFile))
{
Expand Down Expand Up @@ -353,6 +354,35 @@ pal::string_t pal::get_current_os_rid_platform()
}
}
}
else if (pal::file_exists(rhelVersionFile))
{
// Read the file to check if the current OS is RHEL or CentOS 6.x
std::fstream fsVersionFile;

fsVersionFile.open(rhelVersionFile, std::fstream::in);

// Proceed only if we were able to open the file
if (fsVersionFile.good())
{
pal::string_t line;
// Read the first line
std::getline(fsVersionFile, line);

if (!fsVersionFile.eof())
{
pal::string_t rhel6Prefix(_X("Red Hat Enterprise Linux Server release 6."));
pal::string_t centos6Prefix(_X("CentOS release 6."));

if ((line.find(rhel6Prefix) == 0) || (line.find(centos6Prefix) == 0))
{
ridOS = _X("rhel.6");
}
}

// Close the file now that we are done with it.
fsVersionFile.close();
}
}

return normalize_linux_rid(ridOS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/managed/CommonManaged.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)../..'))/</RepoRoot>
<VersionPrefix>2.0.1</VersionPrefix>
<VersionPrefix>2.0.2</VersionPrefix>
<AssemblyFileVersion>$(VersionPrefix)</AssemblyFileVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private static string GetDistroVersionId()

private static DistroInfo LoadDistroInfo()
{
DistroInfo result = null;

// Sample os-release file:
// NAME="Ubuntu"
// VERSION = "14.04.3 LTS, Trusty Tahr"
Expand All @@ -100,7 +102,7 @@ private static DistroInfo LoadDistroInfo()
if (File.Exists("/etc/os-release"))
{
var lines = File.ReadAllLines("/etc/os-release");
var result = new DistroInfo();
result = new DistroInfo();
foreach (var line in lines)
{
if (line.StartsWith("ID=", StringComparison.Ordinal))
Expand All @@ -112,10 +114,30 @@ private static DistroInfo LoadDistroInfo()
result.VersionId = line.Substring(11).Trim('"', '\'');
}
}
}
else if (File.Exists("/etc/redhat-release"))
{
var lines = File.ReadAllLines("/etc/redhat-release");

if (lines.Length >= 1)
{
string line = lines[0];
if (line.StartsWith("Red Hat Enterprise Linux Server release 6.") ||
line.StartsWith("CentOS release 6."))
{
result = new DistroInfo();
result.Id = "rhel";
result.VersionId = "6";
}
}
}

return NormalizeDistroInfo(result);
if (result != null)
{
result = NormalizeDistroInfo(result);
}
return null;

return result;
}

// For some distros, we don't want to use the full version from VERSION_ID. One example is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
</PropertyGroup>

<ItemGroup>
<!-- Since Microsoft.DotNet.PlatformAbstractions isn't being serviced, take a dependency on the shipped package. -->
<!--<ProjectReference Include="..\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />-->
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.0.0" />
<ProjectReference Include="..\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion src/pkg/packaging/dir.proj
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@

<Target Name="GenerateNugetPackages" DependsOnTargets="InitPackage" Condition="'$(UsePrebuiltPortableBinariesForInstallers)' == 'false'">

<ItemGroup Condition="'$(BuildAllPackages)' == 'true'">
<ItemGroup>
<!-- The list of packages we are servicing -->
<PackageProjects Include="$(ProjectDir)src\managed\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />
<PackageProjects Include="$(ProjectDir)src\managed\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(BuildAllPackages)' == 'true'">
<!-- The list of packages we are not servicing -->
</ItemGroup>

<PropertyGroup>
<OutputArg>--output $(PackagesOutDir)</OutputArg>
Expand Down

0 comments on commit bb6dac8

Please sign in to comment.