gui_main.py: Add remaining patches

This commit is contained in:
Mykola Grymalyuk
2022-04-11 17:05:47 -06:00
parent 45a0824515
commit 27d2b7500a
3 changed files with 28 additions and 0 deletions
+2
View File
@@ -24,3 +24,5 @@ __pycache__/
/payloads/Installer.sh /payloads/Installer.sh
/payloads/Info.plist /payloads/Info.plist
/payloads/seed.plist /payloads/seed.plist
/payloads/InstallPackage/OCLP-Install.pkg
/payloads/InstallPackage/OCLP-Install.pkg.zip
+22
View File
@@ -11,6 +11,7 @@ import os
import wx.adv import wx.adv
from wx.lib.agw import hyperlink from wx.lib.agw import hyperlink
import threading import threading
from pathlib import Path
from resources import constants, defaults, build, install, installer, sys_patch_download, utilities, sys_patch_detect, sys_patch, run, generate_smbios, updates from resources import constants, defaults, build, install, installer, sys_patch_download, utilities, sys_patch_detect, sys_patch, run, generate_smbios, updates
from data import model_array, os_data, smbios_data, sip_data from data import model_array, os_data, smbios_data, sip_data
@@ -1420,6 +1421,8 @@ class wx_python_gui:
time.sleep(1) time.sleep(1)
thread = threading.Thread(target=self.start_script) thread = threading.Thread(target=self.start_script)
thread.start() thread.start()
download_thread = threading.Thread(target=self.download_and_unzip_pkg)
download_thread.start()
disk = disk[5:] disk = disk[5:]
default_output = float(utilities.monitor_disk_output(disk)) default_output = float(utilities.monitor_disk_output(disk))
while True: while True:
@@ -1432,6 +1435,11 @@ class wx_python_gui:
self.progress_label.Centre(wx.HORIZONTAL) self.progress_label.Centre(wx.HORIZONTAL)
wx.GetApp().Yield() wx.GetApp().Yield()
else: else:
while download_thread.is_alive():
# wait for download_thread to finish
# though highly unlikely this thread is still alive (flashing an Installer will take a while)
time.sleep(0.1)
self.install_installer_pkg(disk)
break break
self.progress_bar.SetValue(16000) self.progress_bar.SetValue(16000)
self.progress_label.SetLabel(f"Finished Running Installer Creation Script") self.progress_label.SetLabel(f"Finished Running Installer Creation Script")
@@ -1453,6 +1461,20 @@ class wx_python_gui:
popup = wx.MessageDialog(self.frame, f"Failed to create macOS installer\n\nOutput: {output}\n\nError: {error}", "Error", wx.OK | wx.ICON_ERROR) popup = wx.MessageDialog(self.frame, f"Failed to create macOS installer\n\nOutput: {output}\n\nError: {error}", "Error", wx.OK | wx.ICON_ERROR)
popup.ShowModal() popup.ShowModal()
def download_and_unzip_pkg(self):
# Remove this URL overwrite when released
self.constants.installer_pkg_url = "https://github.com/khronokernel/Storage/releases/download/1.0/OCLP-Install.pkg.zip"
if utilities.download_file(self.constants.installer_pkg_url, self.constants.installer_pkg_zip_path):
subprocess.run(["unzip", "-o", self.constants.installer_pkg_zip_path, "-d", self.constants.installer_pkg_path])
def install_installer_pkg(self, disk):
disk = disk + "s2" # ESP sits at 1, and we know macOS will have created the main partition at 2
if Path(self.constants.installer_pkg_zip_path).exists():
path = utilities.grab_mount_point_from_disk(disk)
subprocess.run(["mkdir", "-p", f"{path}/Library/Packages/"])
subprocess.run(["cp", f"{self.constants.installer_pkg_path}/OCLP-Install.pkg", f"{path}/Library/Packages/"])
def settings_menu(self, event=None): def settings_menu(self, event=None):
# Define Menu # Define Menu
# - Header: Settings # - Header: Settings
+4
View File
@@ -568,6 +568,10 @@ class Constants:
@property @property
def installer_pkg_path(self): def installer_pkg_path(self):
return self.payload_path / Path("InstallPackage/OCLP-Install.pkg") return self.payload_path / Path("InstallPackage/OCLP-Install.pkg")
@property
def installer_pkg_zip_path(self):
return self.payload_path / Path("InstallPackage/OCLP-Install.pkg.zip")
# Apple Payloads Paths # Apple Payloads Paths