From d7163c75e5a73c610ef994b0a90c1be97f0e5e46 Mon Sep 17 00:00:00 2001 From: wfurt Date: Fri, 21 Aug 2020 11:07:20 -0700 Subject: [PATCH 1/2] map macOS compat 10.16 version to 11.0 --- .../corehost/cli/hostmisc/pal.unix.cpp | 32 ++++++++++++------- .../Common/src/Interop/OSX/Interop.libobjc.cs | 9 ++++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/installer/corehost/cli/hostmisc/pal.unix.cpp b/src/installer/corehost/cli/hostmisc/pal.unix.cpp index 4b2e996458b260..97823ba9cf4706 100644 --- a/src/installer/corehost/cli/hostmisc/pal.unix.cpp +++ b/src/installer/corehost/cli/hostmisc/pal.unix.cpp @@ -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) @@ -562,18 +561,29 @@ 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. + 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)); + } } } diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs index 9234767340f8ca..799bfd19e0d5e7 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs @@ -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); } From 45e1c74367f9f9e228c6ee3b16d244eb14818342 Mon Sep 17 00:00:00 2001 From: wfurt Date: Fri, 21 Aug 2020 11:59:23 -0700 Subject: [PATCH 2/2] feedback from review --- src/installer/corehost/cli/hostmisc/pal.unix.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/installer/corehost/cli/hostmisc/pal.unix.cpp b/src/installer/corehost/cli/hostmisc/pal.unix.cpp index 97823ba9cf4706..6996618239ebd7 100644 --- a/src/installer/corehost/cli/hostmisc/pal.unix.cpp +++ b/src/installer/corehost/cli/hostmisc/pal.unix.cpp @@ -563,11 +563,13 @@ pal::string_t pal::get_current_os_rid_platform() { int majorVersion = stoi(release.substr(0, pos)); // compat path with 10.x - if (majorVersion > 20) + if (majorVersion < 20) { // 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) {