From 3340f10fbd30545a31c6bd6a537ed8b92e4fdcd3 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 26 Apr 2022 21:24:45 -0600 Subject: [PATCH] gui_main.py: Add disk highlighting during install --- CHANGELOG.md | 1 + docs/TROUBLESHOOTING.md | 7 +++++++ gui/gui_main.py | 32 ++++++++++++++++++++++++++++---- resources/constants.py | 1 + resources/device_probe.py | 2 ++ resources/main.py | 1 + resources/utilities.py | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 78 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07cbd2df1..ecd0bab71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Streamline GUI relaunch for Root Patch/Unpatch (remembering previous state during patching) - Grey out return buttons while performing sensitive tasks - Add `Currently Booted SIP` info to SIP Settings + - Add Disk Highlighting during Build/Install for previously installed disks - Remove manual root unpatching - Removed due to reliablity issues - `bless` based reversion still supported in Big Sur+ diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 0806ebd55..39e952c11 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -16,6 +16,7 @@ Here are some common errors users may experience while using this patcher: * [No DisplayPort Output on Mac Pros with Nvidia Kepler](#no-displayport-output-on-mac-pros-with-nvidia-kepler) * [Volume Hash Mismatch Error in macOS Monterey](#volume-hash-mismatch-error-in-macos-monterey) * [Cannot Disable SIP in recoveryOS](#cannot-disable-sip-in-recoveryos) +* [Stuck on "Less than a minute remaining..."](#stuck-on-less-than-a-minute-remaining) ## Stuck on `This version of Mac OS X is not supported on this platform` @@ -135,3 +136,9 @@ For those experiencing issues with USB 1.1 devices (such as mice, keyboards and Because of this, we recommend placing a USB 2.0/3.0 hub between your devices and the port on the Mac Pro. UHCI and EHCI cannot both be used at once, so using a USB hub will always force the EHCI controller on. * Alternatively, you can try cold starting the hardware and see if macOS recognizes the UHCI controller properly + +## Stuck on "Less than a minute remaining..." + +A common area for systems to get "stuck", namely for units that are missing the `AES` CPU instruction/older mobile hardware. During this stange a lot of heavy cryptography is performed, which can make systems appear to be stuck when in reality they are working quite hard to finish up the installation. + +Be patient at this stage, do not manually reboot your machine. This will break the installation and require you to reinstall. diff --git a/gui/gui_main.py b/gui/gui_main.py index c32105dcc..649be90e4 100644 --- a/gui/gui_main.py +++ b/gui/gui_main.py @@ -567,9 +567,26 @@ class wx_python_gui: ) self.missing_disks.Centre(wx.HORIZONTAL) + self.color_note = wx.StaticText(self.frame, label="Note: Blue represent the disk OpenCore is currently booted from") + self.color_note.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) + self.color_note.SetPosition( + wx.Point( + self.missing_disks.GetPosition().x, + self.missing_disks.GetPosition().y + self.missing_disks.GetSize().height + 5 + ) + ) + self.color_note.Centre(wx.HORIZONTAL) + # Request Disks Present list_disks = install.tui_disk_installation(self.constants).list_disks() if list_disks: + if self.constants.booted_oc_disk is not None: + # disk6s1 -> disk6 + disk_root = self.constants.booted_oc_disk.strip("disk") + disk_root = "disk" + disk_root.split("s")[0] + else: + disk_root = None + for disk in list_disks: # Create a button for each disk print(f"{list_disks[disk]['disk']} - {list_disks[disk]['name']} - {list_disks[disk]['size']}") @@ -577,21 +594,25 @@ class wx_python_gui: self.install_button.SetLabel(f"{list_disks[disk]['disk']} - {list_disks[disk]['name']} - {list_disks[disk]['size']}") self.install_button.SetPosition( wx.Point( - self.missing_disks.GetPosition().x, - self.missing_disks.GetPosition().y + self.missing_disks.GetSize().height + 3 + i + self.color_note.GetPosition().x, + self.color_note.GetPosition().y + self.color_note.GetSize().height + 3 + i ) ) self.install_button.Bind(wx.EVT_BUTTON, lambda event, temp=disk: self.install_oc_disk_select(temp, list_disks)) self.install_button.Centre(wx.HORIZONTAL) i += self.install_button.GetSize().height + 3 + if disk_root == list_disks[disk]['disk']: + # Set label colour to red + self.install_button.SetForegroundColour((25, 179, 231)) + else: # Label: No disks found self.install_button = wx.StaticText(self.frame, label="Failed to find any applicable disks") self.install_button.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) self.install_button.SetPosition( wx.Point( - self.missing_disks.GetPosition().x, - self.missing_disks.GetPosition().y + self.missing_disks.GetSize().height + 3 + self.color_note.GetPosition().x, + self.color_note.GetPosition().y + self.color_note.GetSize().height + 3 ) ) self.install_button.Centre(wx.HORIZONTAL) @@ -644,6 +665,9 @@ class wx_python_gui: self.install_button.Bind(wx.EVT_BUTTON, lambda event, temp=partition: self.install_oc_process(temp)) self.install_button.Centre(wx.HORIZONTAL) i += self.install_button.GetSize().height + 3 + if self.constants.booted_oc_disk == list_partitions[partition]['partition']: + # Set label colour to red + self.install_button.SetForegroundColour((25, 179, 231)) self.return_to_main_menu = wx.Button(self.frame, label="Return to Main Menu") self.return_to_main_menu.SetPosition( diff --git a/resources/constants.py b/resources/constants.py index 34be30c87..c0dec2cdb 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -192,6 +192,7 @@ class Constants: self.allow_nvme_fixing = True # Allow NVMe Kernel Space Patches self.disable_xcpm = False # Disable XCPM (X86PlatformPlugin.kext) self.root_patcher_succeded = False # Determine if root patcher succeeded + self.booted_oc_disk = None # Determine current disk OCLP booted from self.legacy_accel_support = [ os_data.os_data.mojave, diff --git a/resources/device_probe.py b/resources/device_probe.py index 0b1ddd904..cd487a810 100644 --- a/resources/device_probe.py +++ b/resources/device_probe.py @@ -475,6 +475,7 @@ class Computer: cpu: Optional[CPU] = None oclp_version: Optional[str] = None opencore_version: Optional[str] = None + opencore_path: Optional[str] = None bluetooth_chipset: Optional[str] = None ambient_light_sensor: Optional[bool] = False third_party_sata_ssd: Optional[bool] = False @@ -696,6 +697,7 @@ class Computer: # OCLP version self.oclp_version = utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) self.opencore_version = utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) + self.opencore_path = utilities.get_nvram("boot-path", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True) def cpu_probe(self): self.cpu = CPU( diff --git a/resources/main.py b/resources/main.py index b887fa55b..79c7599af 100644 --- a/resources/main.py +++ b/resources/main.py @@ -30,6 +30,7 @@ class OpenCoreLegacyPatcher: self.constants.computer = device_probe.Computer.probe() self.constants.recovery_status = utilities.check_recovery() self.computer = self.constants.computer + self.constants.booted_oc_disk = utilities.find_disk_off_uuid(utilities.clean_device_path(self.computer.opencore_path)) launcher_script = None launcher_binary = sys.executable if "python" in launcher_binary: diff --git a/resources/utilities.py b/resources/utilities.py index 8842ed447..01508a3d6 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -403,6 +403,44 @@ def download_file(link, location, is_gui=None, verify_checksum=False): print(link) return None +def dump_constants(constants): + with open(os.path.join(os.path.expanduser('~'), 'Desktop', 'internal_data.txt'), 'w') as f: + f.write(str(vars(constants))) + + +def clean_device_path(device_path: str): + # ex: + # 'PciRoot(0x0)/Pci(0xA,0x0)/Sata(0x0,0x0,0x0)/HD(1,GPT,C0778F23-3765-4C8E-9BFA-D60C839E7D2D,0x28,0x64000)/EFI\OC\OpenCore.efi' + # 'PciRoot(0x0)/Pci(0x1A,0x7)/USB(0x0,0x0)/USB(0x2,0x0)/HD(2,GPT,4E929909-2074-43BA-9773-61EBC110A670,0x64800,0x38E3000)/EFI\OC\OpenCore.efi' + # return: + # 'C0778F23-3765-4C8E-9BFA-D60C839E7D2D' + # '4E929909-2074-43BA-9773-61EBC110A670' + + if device_path: + device_path_array = device_path.split("/") + # we can always assume [-1] is 'EFI\OC\OpenCore.efi' + if len(device_path_array) >= 2: + device_path_stripped = device_path_array[-2] + device_path_root_array = device_path_stripped.split(",") + return device_path_root_array[2] + return None + + +def find_disk_off_uuid(uuid): + # Find disk by UUID + disk_list = None + try: + disk_list = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", uuid], stdout=subprocess.PIPE).stdout) + except TypeError: + pass + if disk_list: + try: + return disk_list["DeviceIdentifier"] + except KeyError: + pass + return None + + def grab_mount_point_from_disk(disk): data = plistlib.loads(subprocess.run(f"diskutil info -plist {disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) return data["MountPoint"]