Skip to content

Commit

Permalink
map macOS compat 10.16 version to 11.0 (dotnet#41176)
Browse files Browse the repository at this point in the history
* map macOS compat 10.16 version to 11.0

* feedback from review
  • Loading branch information
wfurt authored Aug 24, 2020
1 parent 94532e1 commit ea06e0c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/installer/corehost/cli/hostmisc/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ pal::string_t pal::get_current_os_rid_platform()
// We will, instead, use kern.osrelease and use its major version number
// as a means to formulate the OSX 10.X RID.
//
// Needless to say, this will need to be updated if OSX RID were to become 11.* ever.
size_t size = sizeof(str);
int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0);
if (ret == 0)
Expand All @@ -562,18 +561,31 @@ pal::string_t pal::get_current_os_rid_platform()
size_t pos = release.find('.');
if (pos != std::string::npos)
{
// Extract the major version and subtract 4 from it
// to get the Minor version used in OSX versioning scheme.
// That is, given a version 10.X.Y, we will get X below.
int minorVersion = stoi(release.substr(0, pos)) - 4;
if (minorVersion < 10)
int majorVersion = stoi(release.substr(0, pos));
// compat path with 10.x
if (majorVersion < 20)
{
// On OSX, our minimum supported RID is 10.12.
minorVersion = 12;
}
// Extract the major version and subtract 4 from it
// to get the Minor version used in OSX versioning scheme.
// That is, given a version 10.X.Y, we will get X below.
//
// macOS Cataline 10.15.5 has kernel 19.5.0
int minorVersion = majorVersion - 4;
if (minorVersion < 10)
{
// On OSX, our minimum supported RID is 10.12.
minorVersion = 12;
}

ridOS.append(_X("osx.10."));
ridOS.append(pal::to_string(minorVersion));
ridOS.append(_X("osx.10."));
ridOS.append(pal::to_string(minorVersion));
}
else
{
// 11.0 shipped with kernel 20.0
ridOS.append(_X("osx.11."));
ridOS.append(pal::to_string(majorVersion - 20));
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ internal static Version GetOperatingSystemVersion()
}
}

if (major == 10 && minor == 16)
{
// We get "compat" version for 11.0 unless we build with updated SDK.
// Hopefully that will be before 11.x comes out
// For now, this maps 10.16 to 11.0.
major = 11;
minor = 0;
}

return new Version(major, minor, patch);
}

Expand Down

0 comments on commit ea06e0c

Please sign in to comment.