From 98bbddc03db69a4c0fa699f2f28633c64d45c0c8 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Thu, 18 May 2023 10:28:18 -0600 Subject: [PATCH] Settings: Add additional safe guards --- resources/wx_gui/gui_settings.py | 9 ++++++--- resources/wx_gui/gui_support.py | 12 +++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index d558f74fc..b6113454e 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -22,7 +22,8 @@ from data import ( model_array, sip_data, smbios_data, - os_data + os_data, + cpu_data ) @@ -238,7 +239,7 @@ class SettingsFrame(wx.Frame): "Enable booting macOS from", "FireWire drives.", ], - "condition": not bool(generate_smbios.check_firewire(self.constants.computer.real_model) is False and not self.constants.custom_model) + "condition": not (generate_smbios.check_firewire(self.constants.custom_model or self.constants.computer.real_model) is False) }, "XHCI Booting": { "type": "checkbox", @@ -249,6 +250,7 @@ class SettingsFrame(wx.Frame): "USB 3.0 expansion cards on systems", "without native support.", ], + "condition": not gui_support.CheckProperties(self.constants).host_has_cpu_gen(cpu_data.cpu_data.ivy_bridge) # Sandy Bridge and older do not natively support XHCI booting }, "NVMe Booting": { "type": "checkbox", @@ -261,6 +263,7 @@ class SettingsFrame(wx.Frame): "Note: Requires Firmware support", "for OpenCore to load from NVMe.", ], + "condition": not gui_support.CheckProperties(self.constants).host_has_cpu_gen(cpu_data.cpu_data.ivy_bridge) # Sandy Bridge and older do not natively support NVMe booting }, "wrap_around 2": { "type": "wrap_around", @@ -453,7 +456,7 @@ class SettingsFrame(wx.Frame): "'gpu-power-prefs'.", ], "warning": "This settings requires 'gpu-power-prefs' NVRAM argument to be set to '1'.\n\nIf missing and this option is toggled, the system will not boot\n\nFull command:\nnvram FA4CE28D-B62F-4C99-9CC3-6815686E30F9:gpu-power-prefs=%01%00%00%00", - "condition": not bool(not self.constants.custom_model and self.constants.computer.real_model not in ["MacBookPro8,2", "MacBookPro8,3"]) + "condition": not bool((not self.constants.custom_model and self.constants.computer.real_model not in ["MacBookPro8,2", "MacBookPro8,3"]) or (self.constants.custom_model and self.constants.custom_model not in ["MacBookPro8,2", "MacBookPro8,3"])) }, "wrap_around 1": { "type": "wrap_around", diff --git a/resources/wx_gui/gui_support.py b/resources/wx_gui/gui_support.py index 863ad52a3..acf363035 100644 --- a/resources/wx_gui/gui_support.py +++ b/resources/wx_gui/gui_support.py @@ -9,7 +9,7 @@ import applescript from pathlib import Path from resources import constants -from data import model_array, os_data +from data import model_array, os_data, cpu_data, smbios_data class AutoUpdateStages: @@ -122,6 +122,16 @@ class CheckProperties: return True + def host_has_cpu_gen(self, gen: int) -> bool: + """ + Check if host has a CPU generation equal to or greater than the specified generation + """ + model = self.constants.custom_model if self.constants.custom_model else self.constants.computer.real_model + if model in smbios_data.smbios_dictionary: + if smbios_data.smbios_dictionary[model]["CPU Generation"] >= gen: + return True + return False + class PayloadMount: