Add error handling for bless failure

This commit is contained in:
Mykola Grymalyuk
2021-10-08 12:53:06 -06:00
parent 96fd706ead
commit 86694de7df
3 changed files with 27 additions and 7 deletions

View File

@@ -1585,4 +1585,15 @@ smbios_dictionary = {
"Ethernet Chipset": "Broadcom",
},
"AAPLJ53,1": {
# AppleInternal MacBookPro11,4
"Board ID": "Mac-C08A65A66A9A3BA2",
"FirmwareFeatures": None,
"SecureBootModel": None,
"CPU Generation": cpu_data.cpu_data.haswell.value,
"Max OS Supported": os_data.os_data.mavericks,
"Wireless Model": device_probe.Broadcom.Chipsets.AirportBrcmNIC,
"Bluetooth Model": bluetooth_data.bluetooth_data.BRCM20702_v2,
},
}

View File

@@ -12,7 +12,7 @@ def set_smbios_model_spoof(model):
return "MacBookAir7,1"
else:
# Unknown Model
raise Exception
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
elif model.startswith("MacBookPro"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookPro12,1"
@@ -25,7 +25,7 @@ def set_smbios_model_spoof(model):
return "MacBookPro11,4"
else:
# Unknown Model
raise Exception
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
elif model.startswith("MacBook"):
if smbios_data.smbios_dictionary[model]["Screen Size"] == 13:
return "MacBookAir7,2"
@@ -33,10 +33,10 @@ def set_smbios_model_spoof(model):
return "MacBook9,1"
else:
# Unknown Model
raise Exception
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
else:
# Unknown Model
raise Exception
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
except KeyError:
# Found desktop model
if model.startswith("MacPro") or model.startswith("Xserve"):
@@ -51,7 +51,7 @@ def set_smbios_model_spoof(model):
return "iMac17,1"
else:
# Unknown Model
raise Exception
raise Exception(f"Unknown SMBIOS for spoofing: {model}")
def update_firmware_features(firmwarefeature):
# Adjust FirmwareFeature to support everything macOS requires

View File

@@ -10,6 +10,7 @@ import shutil
import subprocess
import zipfile
from pathlib import Path
import sys
from resources import constants, device_probe, utilities
from data import sip_data, sys_patch_data, model_array
@@ -236,8 +237,16 @@ class PatchSysVolume:
input("Press [ENTER] to continue with kernel and dyld cache merging")
if self.constants.detected_os > self.constants.catalina:
print("- Creating new APFS snapshot")
utilities.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
self.unmount_drive()
bless = utilities.elevated(["bless", "--folder", f"{self.mount_location}/System/Library/CoreServices", "--bootefi", "--create-snapshot"], stdout=subprocess.PIPE).stdout.decode().strip().encode()
if bless.returncode != 0:
print("- Unable to create new snapshot")
print("Reason for snapshot failure:")
print(bless.stdout.decode())
if "Can't use last-sealed-snapshot or create-snapshot on non system volume" in bless.stdout.decode():
print("- This is an APFS bug with Monterey! Perform a clean installation to ensure your APFS volume is built correctly")
sys.exit(1)
else:
self.unmount_drive()
else:
if self.constants.detected_os == self.constants.catalina:
print("- Merging kernel cache")