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

Fall back to /usr/lib/os-release if /etc/os-release doesn't exist #2380

Merged
merged 2 commits into from
Apr 19, 2022
Merged
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
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