From 02151f4b57b19880cb0322abc814181543cf1f1e Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Fri, 15 Oct 2021 13:55:44 -0700 Subject: [PATCH 1/4] fix rid processing on macOS --- src/native/corehost/hostmisc/pal.unix.cpp | 32 ++++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 45821cfae6897..49ca6743a81c6 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -570,26 +570,44 @@ pal::string_t pal::get_current_os_rid_platform() char str[256]; size_t size = sizeof(str); - // returns something like 10.5.2 + // returns something like 10.5.2 or 11.6 int ret = sysctlbyname("kern.osproductversion", str, &size, nullptr, 0); if (ret == 0) { // the value _should_ be null terminated but let's make sure str[size - 1] = 0; + char* pos = strchr(str, '.'); if (pos != NULL) { - pos = strchr(pos + 1, '.'); - - if (pos != NULL) + int major = atoi(str); + if (major > 11) { - // strip anything after second dot and return something like 10.5 + // starting with 12.0 we track only major release *pos = 0; - size = pos - str; + + } + else if (major == 11) + { + // for 11.x we publish RID as 11.0 + // if wwe return anytrhing else, it would brek the graph porocessing + strcpy(str, "11.0"); + } + else + { + // for 10.x the significant relases are actully the second digit + pos = strchr(pos + 1, '.'); + + if (pos != NULL) + { + // strip anything after second dot and return something like 10.5 + *pos = 0; + size = pos - str - 1; + } } } - std::string release(str, size); + std::string release(str, strlen(str)); ridOS.append(_X("osx.")); ridOS.append(release); } From 75cf218788b56fdd95036eea89755377cad311fe Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Fri, 15 Oct 2021 15:03:32 -0700 Subject: [PATCH 2/4] Update src/native/corehost/hostmisc/pal.unix.cpp Co-authored-by: Vitek Karas --- src/native/corehost/hostmisc/pal.unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 49ca6743a81c6..5796698a7d052 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -590,7 +590,7 @@ pal::string_t pal::get_current_os_rid_platform() else if (major == 11) { // for 11.x we publish RID as 11.0 - // if wwe return anytrhing else, it would brek the graph porocessing + // if we return anything else, it would break the RID graph processing strcpy(str, "11.0"); } else From 53e7d811e6599b76c310a4915b0709b155b9ee36 Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Fri, 15 Oct 2021 17:56:13 -0700 Subject: [PATCH 3/4] Update src/native/corehost/hostmisc/pal.unix.cpp Co-authored-by: Jan Kotas --- src/native/corehost/hostmisc/pal.unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 5796698a7d052..c4e6126a20184 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -595,7 +595,7 @@ pal::string_t pal::get_current_os_rid_platform() } else { - // for 10.x the significant relases are actully the second digit + // for 10.x the significant releases are actually the second digit pos = strchr(pos + 1, '.'); if (pos != NULL) From 7c25dffe81a53f2ad5d8421c5817a1eb4d9e31e7 Mon Sep 17 00:00:00 2001 From: Tomas Weinfurt Date: Mon, 18 Oct 2021 14:16:19 -0700 Subject: [PATCH 4/4] remove extra size calculation --- src/native/corehost/hostmisc/pal.unix.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 49ca6743a81c6..f665b7eaf316b 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -587,7 +587,7 @@ pal::string_t pal::get_current_os_rid_platform() *pos = 0; } - else if (major == 11) + else if (major == 12) { // for 11.x we publish RID as 11.0 // if wwe return anytrhing else, it would brek the graph porocessing @@ -602,7 +602,6 @@ pal::string_t pal::get_current_os_rid_platform() { // strip anything after second dot and return something like 10.5 *pos = 0; - size = pos - str - 1; } } }