Skip to content

Commit 55ab8ce

Browse files
[release/5.0] map macOS compat 10.16 version to 11.0 (#41294)
* map macOS compat 10.16 version to 11.0 * feedback from review Co-authored-by: wfurt <[email protected]>
1 parent 4001666 commit 55ab8ce

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

src/installer/corehost/cli/hostmisc/pal.unix.cpp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ pal::string_t pal::get_current_os_rid_platform()
553553
// We will, instead, use kern.osrelease and use its major version number
554554
// as a means to formulate the OSX 10.X RID.
555555
//
556-
// Needless to say, this will need to be updated if OSX RID were to become 11.* ever.
557556
size_t size = sizeof(str);
558557
int ret = sysctlbyname("kern.osrelease", str, &size, nullptr, 0);
559558
if (ret == 0)
@@ -562,18 +561,31 @@ pal::string_t pal::get_current_os_rid_platform()
562561
size_t pos = release.find('.');
563562
if (pos != std::string::npos)
564563
{
565-
// Extract the major version and subtract 4 from it
566-
// to get the Minor version used in OSX versioning scheme.
567-
// That is, given a version 10.X.Y, we will get X below.
568-
int minorVersion = stoi(release.substr(0, pos)) - 4;
569-
if (minorVersion < 10)
564+
int majorVersion = stoi(release.substr(0, pos));
565+
// compat path with 10.x
566+
if (majorVersion < 20)
570567
{
571-
// On OSX, our minimum supported RID is 10.12.
572-
minorVersion = 12;
573-
}
568+
// Extract the major version and subtract 4 from it
569+
// to get the Minor version used in OSX versioning scheme.
570+
// That is, given a version 10.X.Y, we will get X below.
571+
//
572+
// macOS Cataline 10.15.5 has kernel 19.5.0
573+
int minorVersion = majorVersion - 4;
574+
if (minorVersion < 10)
575+
{
576+
// On OSX, our minimum supported RID is 10.12.
577+
minorVersion = 12;
578+
}
574579

575-
ridOS.append(_X("osx.10."));
576-
ridOS.append(pal::to_string(minorVersion));
580+
ridOS.append(_X("osx.10."));
581+
ridOS.append(pal::to_string(minorVersion));
582+
}
583+
else
584+
{
585+
// 11.0 shipped with kernel 20.0
586+
ridOS.append(_X("osx.11."));
587+
ridOS.append(pal::to_string(majorVersion - 20));
588+
}
577589
}
578590
}
579591

src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ internal static Version GetOperatingSystemVersion()
5151
}
5252
}
5353

54+
if (major == 10 && minor == 16)
55+
{
56+
// We get "compat" version for 11.0 unless we build with updated SDK.
57+
// Hopefully that will be before 11.x comes out
58+
// For now, this maps 10.16 to 11.0.
59+
major = 11;
60+
minor = 0;
61+
}
62+
5463
return new Version(major, minor, patch);
5564
}
5665

0 commit comments

Comments
 (0)