Skip to content

Commit

Permalink
Merge pull request #2380 from oscarwcl/os-release
Browse files Browse the repository at this point in the history
Fall back to /usr/lib/os-release if /etc/os-release doesn't exist
  • Loading branch information
filipw authored Apr 19, 2022
2 parents 4356617 + 1cc2f41 commit 0208ea2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 14 additions & 2 deletions scripts/platform.cake
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,23 @@ public sealed class Platform

private static void ReadDistroNameAndVersion(out string distroName, out Version version)
{
var lines = System.IO.File.ReadAllLines("/etc/os-release");

distroName = null;
version = null;

string OS_Release_Path = "/etc/os-release";

if (!System.IO.File.Exists(OS_Release_Path))
{
OS_Release_Path = "/usr/lib/os-release";
}

if (!System.IO.File.Exists(OS_Release_Path))
{
return;
}

var lines = System.IO.File.ReadAllLines(OS_Release_Path);

foreach (var line in lines)
{
var equalsIndex = line.IndexOf('=');
Expand Down
7 changes: 6 additions & 1 deletion src/OmniSharp.Shared/Utilities/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ private static void ReadDistroNameAndVersion(out string distroName, out Version
version = null;

// Details: https://www.freedesktop.org/software/systemd/man/os-release.html
const string OS_Release_Path = "/etc/os-release";
string OS_Release_Path = "/etc/os-release";

if (!File.Exists(OS_Release_Path))
{
OS_Release_Path = "/usr/lib/os-release";
}

if (!File.Exists(OS_Release_Path))
{
Expand Down

0 comments on commit 0208ea2

Please sign in to comment.