Add developer patcher

This commit is contained in:
Jazzzny
2023-07-28 20:52:18 -04:00
parent 9631cc48bd
commit 97a86fcd92

View File

@@ -4,6 +4,7 @@ import pprint
import logging
import py_sip_xnu
import subprocess
import os
from pathlib import Path
@@ -814,6 +815,9 @@ class SettingsFrame(wx.Frame):
},
},
"Developer": {
"Validation": {
"type": "title",
},
"Install latest nightly build 🧪": {
"type": "button",
"function": self.on_nightly,
@@ -839,6 +843,28 @@ class SettingsFrame(wx.Frame):
"Export constants.py values to a txt file.",
],
},
"Developer Root Volume Patching": {
"type": "title",
},
"Mount Root Volume": {
"type": "button",
"function": self.on_mount_root_vol,
"description": [
"Life's too short to type 'sudo mount -o",
"nobrowse -t apfs /dev/diskXsY",
"/System/Volumes/Update/mnt1' every time.",
],
},
"wrap_around 2": {
"type": "wrap_around",
},
"Update Root Volume": {
"type": "button",
"function": self.on_bless_root_vol,
"description": [
"Rebuild kernel cache and bless snapshot 🙏",
],
},
},
}
@@ -1274,4 +1300,29 @@ Hardware Information:
def on_test_exception(self, event: wx.Event) -> None:
raise Exception("Test Exception")
raise Exception("Test Exception")
def on_mount_root_vol(self, event: wx.Event) -> None:
if os.geteuid() != 0:
wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
else:
from resources.sys_patch.sys_patch import PatchSysVolume
#Don't need to pass model as we're bypassing all logic
if PatchSysVolume("",self.constants)._mount_root_vol() == True:
wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before blessing 🙏", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal()
else:
wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
def on_bless_root_vol(self, event: wx.Event) -> None:
if os.geteuid() != 0:
wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
else:
from resources.sys_patch.sys_patch import PatchSysVolume
#Don't need to pass model as we're bypassing all logic
if PatchSysVolume("",self.constants)._rebuild_kernel_collection() == True:
if PatchSysVolume("",self.constants)._create_new_apfs_snapshot() == True:
wx.MessageDialog(self.parent, "Root Volume Updated, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal()
else:
wx.MessageDialog(self.parent, "Root Volume Bless Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
else:
wx.MessageDialog(self.parent, "KC Update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal()