mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-20 14:10:51 +10:00
Work-around Root Volume unmounting
This commit is contained in:
+12
-1
@@ -1,6 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
from resources import defaults, build, utilities, validation, sys_patch, sys_patch_auto
|
from resources import defaults, build, utilities, validation, sys_patch, sys_patch_auto
|
||||||
from data import model_array
|
from data import model_array
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
# Generic building args
|
# Generic building args
|
||||||
class arguments:
|
class arguments:
|
||||||
@@ -101,7 +103,16 @@ If you plan to create the USB for another machine, please select the "Change Mod
|
|||||||
print("- Set Mojave/Catalina root patch configuration")
|
print("- Set Mojave/Catalina root patch configuration")
|
||||||
settings.moj_cat_accel = True
|
settings.moj_cat_accel = True
|
||||||
print("- Set System Volume patching")
|
print("- Set System Volume patching")
|
||||||
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings, None).start_patch()
|
|
||||||
|
if "Library/InstallerSandboxes/" in str(self.constants.payload_path):
|
||||||
|
print("- Running from Installer Sandbox")
|
||||||
|
thread = threading.Thread(target=sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings, None).start_patch)
|
||||||
|
thread.start()
|
||||||
|
while thread.is_alive():
|
||||||
|
utilities.block_os_updaters()
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings, None).start_patch()
|
||||||
elif self.args.unpatch_sys_vol:
|
elif self.args.unpatch_sys_vol:
|
||||||
print("- Set System Volume unpatching")
|
print("- Set System Volume unpatching")
|
||||||
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings, None).start_unpatch()
|
sys_patch.PatchSysVolume(settings.custom_model or settings.computer.real_model, settings, None).start_unpatch()
|
||||||
|
|||||||
@@ -241,9 +241,13 @@ class PatchSysVolume:
|
|||||||
else:
|
else:
|
||||||
result = utilities.elevated(["kextcache", "-i", f"{self.mount_location}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = utilities.elevated(["kextcache", "-i", f"{self.mount_location}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
# kextcache always returns 0, even if it fails
|
# kextcache notes:
|
||||||
# Check the output for 'KernelCache ID' to see if the cache was successfully rebuilt
|
# - kextcache always returns 0, even if it fails
|
||||||
if result.returncode != 0 or (self.constants.detected_os < os_data.os_data.catalina and "KernelCache ID" not in result.stdout.decode()):
|
# - Check the output for 'KernelCache ID' to see if the cache was successfully rebuilt
|
||||||
|
# kmutil notes:
|
||||||
|
# - kmutil will return 71 on failure to build KCs
|
||||||
|
# - kmutil will sometimes have a stroke and return a negative value even if it succeeds
|
||||||
|
if result.returncode > 0 or (self.constants.detected_os < os_data.os_data.catalina and "KernelCache ID" not in result.stdout.decode()):
|
||||||
self.success_status = False
|
self.success_status = False
|
||||||
print("- Unable to build new kernel cache")
|
print("- Unable to build new kernel cache")
|
||||||
print(f"\nReason for Patch Failure({result.returncode}):")
|
print(f"\nReason for Patch Failure({result.returncode}):")
|
||||||
@@ -254,7 +258,7 @@ class PatchSysVolume:
|
|||||||
input("Press [ENTER] to continue")
|
input("Press [ENTER] to continue")
|
||||||
else:
|
else:
|
||||||
self.success_status = True
|
self.success_status = True
|
||||||
print("- Successfully built new kernel cache")
|
print(f"- Successfully built new kernel cache({result.returncode})")
|
||||||
if self.root_supports_snapshot is True:
|
if self.root_supports_snapshot is True:
|
||||||
print("- Creating new APFS snapshot")
|
print("- Creating new APFS snapshot")
|
||||||
bless = utilities.elevated(
|
bless = utilities.elevated(
|
||||||
|
|||||||
@@ -410,6 +410,29 @@ def monitor_disk_output(disk):
|
|||||||
output = output[-2]
|
output = output[-2]
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def block_os_updaters():
|
||||||
|
# Disables any processes that would be likely to mess with
|
||||||
|
# the root volume while we're working with it.
|
||||||
|
bad_processes = [
|
||||||
|
"softwareupdate",
|
||||||
|
"SoftwareUpdate",
|
||||||
|
"Software Update",
|
||||||
|
"MobileSoftwareUpdate",
|
||||||
|
]
|
||||||
|
output = subprocess.check_output(["ps", "-ax"])
|
||||||
|
lines = output.splitlines()
|
||||||
|
for line in lines:
|
||||||
|
entry = line.split()
|
||||||
|
pid = entry[0]
|
||||||
|
process_name = entry[3].decode()
|
||||||
|
for process in bad_processes:
|
||||||
|
if process in process_name:
|
||||||
|
if pid != "":
|
||||||
|
print(f"Killing PID: {pid}")
|
||||||
|
print(f"Process: {process_name}")
|
||||||
|
subprocess.run(["kill", "-9", pid])
|
||||||
|
|
||||||
def check_boot_mode():
|
def check_boot_mode():
|
||||||
# Check whether we're in Safe Mode or not
|
# Check whether we're in Safe Mode or not
|
||||||
sys_plist = plistlib.loads(subprocess.run(["system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout)
|
sys_plist = plistlib.loads(subprocess.run(["system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user