From 854fc16889744d6a8b2b0e280e2ca50701232449 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Wed, 13 Nov 2024 22:48:45 +0800 Subject: [PATCH 1/4] os/mac/diagnostic: fix OpenCore check Fixes #18763. --- Library/Homebrew/extend/os/mac/diagnostic.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index c13c5b5956eb3..01d894e2de740 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -129,11 +129,16 @@ def check_for_unsupported_macos end def check_for_opencore - has_opencore = - File.exist?("/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper") - has_opencore ||= File.exist?("/Library/Application Support/Dortania/OpenCore-Patcher.app") - has_opencore ||= MacOS.pkgutil_info("com.dortania.opencore-legacy-patcher").present? - return unless has_opencore + return if ::Hardware::CPU.physical_cpu_arm64? + + # https://dortania.github.io/OpenCore-Legacy-Patcher/UPDATE.html#checking-oclp-and-opencore-versions + begin + opencore_version = Utils.safe_popen_read("/usr/sbin/nvram", + "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:opencore-version") + return if opencore_version.blank? + rescue ErrorDuringExecution + return + end <<~EOS You have installed macOS using OpenCore Legacy Patcher. From dee399c27df17ff808dda46a3a5aaec6d53bc970 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Wed, 13 Nov 2024 23:01:29 +0800 Subject: [PATCH 2/4] os/mac/diagnostic: display OpenCore version --- Library/Homebrew/extend/os/mac/diagnostic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 01d894e2de740..24a2920856104 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -141,7 +141,7 @@ def check_for_opencore end <<~EOS - You have installed macOS using OpenCore Legacy Patcher. + You have installed macOS using OpenCore Legacy Patcher, version #{opencore_version}. We do not provide support for this configuration. #{please_create_pull_requests} EOS From 13265ca170a2e28572ab4cb3730aa2bc42d395b3 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Wed, 13 Nov 2024 23:10:38 +0800 Subject: [PATCH 3/4] os/mac/diagnostic: skip OpenCore check in CI --- Library/Homebrew/extend/os/mac/diagnostic.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 24a2920856104..9fc366a8bfd1b 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -130,6 +130,7 @@ def check_for_unsupported_macos def check_for_opencore return if ::Hardware::CPU.physical_cpu_arm64? + return if ENV["CI"] # https://dortania.github.io/OpenCore-Legacy-Patcher/UPDATE.html#checking-oclp-and-opencore-versions begin @@ -141,7 +142,7 @@ def check_for_opencore end <<~EOS - You have installed macOS using OpenCore Legacy Patcher, version #{opencore_version}. + You have installed macOS using OpenCore Legacy Patcher. We do not provide support for this configuration. #{please_create_pull_requests} EOS From a525ce0ad88f350184331e4bae8995b01d96d900 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Wed, 13 Nov 2024 23:43:24 +0800 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Eric Knibbe --- Library/Homebrew/extend/os/mac/diagnostic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 9fc366a8bfd1b..6cc02f7c0de8e 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -135,14 +135,14 @@ def check_for_opencore # https://dortania.github.io/OpenCore-Legacy-Patcher/UPDATE.html#checking-oclp-and-opencore-versions begin opencore_version = Utils.safe_popen_read("/usr/sbin/nvram", - "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:opencore-version") + "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:opencore-version").split[1] return if opencore_version.blank? rescue ErrorDuringExecution return end <<~EOS - You have installed macOS using OpenCore Legacy Patcher. + You have booted macOS using OpenCore Legacy Patcher. We do not provide support for this configuration. #{please_create_pull_requests} EOS