mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-20 10:44:32 +10:00
Move build stages to seperate file
This commit is contained in:
@@ -14,61 +14,10 @@ from Resources import *
|
||||
|
||||
# List build versions
|
||||
patcher_version = "0.0.1"
|
||||
opencore_version = "0.6.3"
|
||||
lilu_version = "1.4.9"
|
||||
whatevergreen_version = "1.4.4"
|
||||
airportbcrmfixup_version = "2.1.1"
|
||||
bcm570_version = "1.0.0"
|
||||
marvel_version = "1.0.0"
|
||||
nforce_version = "1.0.0"
|
||||
mce_version = "1.0.0"
|
||||
mousse_version = "0.93"
|
||||
telemetrap_version = "1.0.0"
|
||||
io80211high_sierra_version = "1.0.0"
|
||||
io80211mojave_version = "1.0.0"
|
||||
|
||||
# Setup file locations
|
||||
current_path = os.getcwd()
|
||||
|
||||
# Payload Location
|
||||
# OpenCore
|
||||
opencore_path = os.path.join(current_path, "payloads/OpenCore/" "OpenCore-v%s.zip" % opencore_version)
|
||||
plist_path = os.path.join(current_path, "payloads/Config/v%s/" "config.plist" % opencore_version)
|
||||
|
||||
# ACPI
|
||||
pci_ssdt_path = os.path.join(current_path, "payloads/ACPI/" "SSDT-CPBG.aml")
|
||||
|
||||
# Drivers
|
||||
nvme_driver_path = os.path.join(current_path, "payloads/Drivers/" "NvmExpressDxe.efi")
|
||||
|
||||
# Kexts
|
||||
lilu_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "Lilu-v%s.zip" % lilu_version)
|
||||
whatevergreen_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "WhateverGreen-v%s.zip" % whatevergreen_version)
|
||||
airportbcrmfixup_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "AirportBrcmFixup-v%s.zip" % airportbcrmfixup_version)
|
||||
bcm570_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "CatalinaBCM5701Ethernet-v%s.zip" % bcm570_version)
|
||||
marvel_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "MarvelYukonEthernet-v%s.zip" % marvel_version)
|
||||
nforce_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "nForceEthernet-v%s.zip" % nforce_version)
|
||||
mce_path = os.path.join(current_path, "payloads/Kexts/Misc/" "AppleMCEReporterDisabler-v%s.zip" % mce_version)
|
||||
mousse_path = os.path.join(current_path, "payloads/Kexts/SSE/" "AAAMouSSE-v%s.zip" % mousse_version)
|
||||
telemetrap_path = os.path.join(current_path, "payloads/Kexts/SSE/" "telemetrap-v%s.zip" % telemetrap_version)
|
||||
io80211high_sierra_path = os.path.join(current_path, "payloads/Kexts/Wifi/" "IO80211HighSierra-v%s.zip" % io80211high_sierra_version)
|
||||
io80211mojave_path = os.path.join(current_path, "payloads/Kexts/Wifi/" "IO80211Mojave-v%s.zip" % io80211mojave_version)
|
||||
|
||||
# Build Location
|
||||
opencore_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s.zip" % opencore_version)
|
||||
plist_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/" % opencore_version)
|
||||
plist_path_build_full = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/config.plist" % opencore_version)
|
||||
acpi_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/ACPI" % opencore_version)
|
||||
drivers_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/Drivers" % opencore_version)
|
||||
kext_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/Kexts" % opencore_version)
|
||||
opencore_path_done = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s" % opencore_version)
|
||||
|
||||
# Tools
|
||||
macserial_path = os.path.join(current_path, "payloads/" "Tools")
|
||||
|
||||
# Find SMBIOS of machine
|
||||
current_model = subprocess.Popen("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE)
|
||||
current_model = [line.strip().split(": ", 1)[1] for line in current_model.stdout.read().split("\n") if line.strip().startswith("Model Identifier")][0]
|
||||
#current_model = subprocess.Popen("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE)
|
||||
#current_model = [line.strip().split(": ", 1)[1] for line in current_model.stdout.read().split("\n") if line.strip().startswith("Model Identifier")][0]
|
||||
|
||||
CustomSMBIOS=False
|
||||
MainMenu=True
|
||||
@@ -78,17 +27,17 @@ while MainMenu:
|
||||
|
||||
print("###################################################")
|
||||
print(" OpenCore Legacy patcher v%s" % patcher_version)
|
||||
print(" Current Model: %s" % current_model)
|
||||
print(" Current Model: %s" % BuildOpenCore.current_model)
|
||||
print("###################################################")
|
||||
print("")
|
||||
if current_model not in ModelArray.SupportedSMBIOS:
|
||||
if BuildOpenCore.current_model not in ModelArray.SupportedSMBIOS:
|
||||
print(" Your model is not supported by this patcher!")
|
||||
print("")
|
||||
print(" If you plan to create the USB for another machine,")
|
||||
print(" please select option 5")
|
||||
print("---------------------------------------------------")
|
||||
print("")
|
||||
elif current_model in ("MacPro3,1", "iMac7,1"):
|
||||
elif BuildOpenCore.current_model in ("MacPro3,1", "iMac7,1"):
|
||||
print(" This model is supported")
|
||||
print(" However please ensure the CPU have been upgraded")
|
||||
print(" to support SSE4.1+")
|
||||
@@ -114,7 +63,7 @@ while MainMenu:
|
||||
os.system('clear')
|
||||
|
||||
print("#######################################################")
|
||||
print(" Build OpenCore for model: %s" % current_model)
|
||||
print(" Build OpenCore for model: %s" % BuildOpenCore.current_model)
|
||||
print("#######################################################")
|
||||
print("")
|
||||
print(" 1. Auto build OpenCore")
|
||||
@@ -130,368 +79,23 @@ while MainMenu:
|
||||
while AutoBuilderMenu:
|
||||
os.system('clear')
|
||||
print("#######################################################")
|
||||
print(" Building OpenCore for model: %s" % current_model)
|
||||
print(" Building OpenCore for model: %s" % BuildOpenCore.current_model)
|
||||
print("#######################################################")
|
||||
print("")
|
||||
print("The current working directory:")
|
||||
print (" %s" % current_path)
|
||||
print (" %s" % Versions.current_path)
|
||||
print("")
|
||||
build_path = os.path.join(current_path, r'Build-Folder/')
|
||||
if not os.path.exists(build_path):
|
||||
os.makedirs(build_path)
|
||||
print("Created Build Folder")
|
||||
else:
|
||||
print("Build Folder already present, skipping")
|
||||
# Copy OpenCore into Build Folder
|
||||
|
||||
if os.path.exists(opencore_path_build):
|
||||
print("Deleting old copy of OpenCore zip")
|
||||
os.remove(opencore_path_build)
|
||||
if os.path.exists(opencore_path_done):
|
||||
print("Deleting old copy of OpenCore folder")
|
||||
rmtree(opencore_path_done)
|
||||
print("")
|
||||
print("- Adding OpenCore v%s" % opencore_version)
|
||||
copy(opencore_path, build_path)
|
||||
zipfile.ZipFile(opencore_path_build).extractall(build_path)
|
||||
|
||||
print("- Adding config.plist v%s" % opencore_version)
|
||||
# Setup config.plist for editing
|
||||
copy(plist_path, plist_path_build)
|
||||
with open(plist_path_build_full, 'r') as file :
|
||||
plist_data = file.read()
|
||||
|
||||
print("- Adding Lilu %s" % lilu_version)
|
||||
copy(lilu_path, kext_path_build)
|
||||
print("- Adding WhateverGreen %s" % whatevergreen_version)
|
||||
copy(whatevergreen_path, kext_path_build)
|
||||
|
||||
# Checks for kexts
|
||||
# CPU Kext Patches
|
||||
if current_model in ModelArray.DualSocket:
|
||||
print("- Adding AppleMCEReporterDisabler v%s" % mce_version)
|
||||
copy(mce_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AppleMCEReporterDisabler-->",
|
||||
"<true/><!--AppleMCEReporterDisabler-->"
|
||||
)
|
||||
|
||||
if current_model in ModelArray.SSEEmulator:
|
||||
print("- Adding AAAMouSSE v%s" % mousse_version)
|
||||
copy(mousse_version, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AAAMouSSE-->",
|
||||
"<true/><!--AAAMouSSE-->"
|
||||
)
|
||||
if current_model in ModelArray.MissingSSE42:
|
||||
print("- Adding telemetrap %s" % telemetrap_version)
|
||||
copy(telemetrap_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--telemetrap-->",
|
||||
"<true/><!--telemetrap-->"
|
||||
)
|
||||
|
||||
# Ethernet Patches
|
||||
|
||||
if current_model in ModelArray.EthernetNvidia:
|
||||
print("- Adding nForceEthernet v%s" % nforce_version)
|
||||
copy(nforce_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--nForceEthernet-->",
|
||||
"<true/><!--nForceEthernet-->"
|
||||
)
|
||||
if current_model in ModelArray.EthernetMarvell:
|
||||
print("- Adding MarvelYukonEthernet v%s" % marvel_version)
|
||||
copy(marvel_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--MarvelYukonEthernet-->",
|
||||
"<true/><!--MarvelYukonEthernet-->"
|
||||
)
|
||||
if current_model in ModelArray.EthernetBroadcom:
|
||||
print("- Adding CatalinaBCM5701Ethernet %s" % bcm570_version)
|
||||
copy(bcm570_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--CatalinaBCM5701Ethernet-->",
|
||||
"<true/><!--CatalinaBCM5701Ethernet-->"
|
||||
)
|
||||
|
||||
# Wifi Patches
|
||||
|
||||
if current_model in ModelArray.WifiAtheros:
|
||||
print("- Adding IO80211HighSierra v%s" % io80211high_sierra_version)
|
||||
copy(io80211high_sierra_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--IO80211HighSierra-->",
|
||||
"<true/><!--IO80211HighSierra-->"
|
||||
)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AirPortAtheros40-->",
|
||||
"<true/><!--AirPortAtheros40-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM94328:
|
||||
print("- Wifi patches currently unsupported")
|
||||
# TO-DO: Add El Capitan's IO80211
|
||||
if current_model in ModelArray.WifiBCM94322:
|
||||
print("- Adding IO80211Mojave %s" % io80211mojave_version)
|
||||
copy(io80211mojave_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--IO80211Mojave-->",
|
||||
"<true/><!--IO80211Mojave-->"
|
||||
)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AirPortBrcm4331-->",
|
||||
"<true/><!--AirPortBrcm4331-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM943224:
|
||||
print("- Adding IO80211Mojave %s" % io80211mojave_version)
|
||||
copy(io80211mojave_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--IO80211Mojave-->",
|
||||
"<true/><!--IO80211Mojave-->"
|
||||
)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AirPortBrcm4331-->",
|
||||
"<true/><!--AirPortBrcm4331-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM94331:
|
||||
print("- Adding AirportBrcmFixup and appling fake ID")
|
||||
copy(airportbcrmfixup_path, kext_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AirportBrcmFixup-->",
|
||||
"<true/><!--AirportBrcmFixup-->"
|
||||
)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--AirPortBrcmNIC_Injector-->",
|
||||
"<true/><!--AirPortBrcmNIC_Injector-->"
|
||||
)
|
||||
if current_model in ("iMac13,1", "iMac13,2"):
|
||||
plist_data = plist_data.replace(
|
||||
"#PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)",
|
||||
"PciRoot(0x0)/Pci(0x1C,0x3)Pci(0x0,0x0)"
|
||||
)
|
||||
else:
|
||||
plist_data = plist_data.replace(
|
||||
"#PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)",
|
||||
"PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)"
|
||||
)
|
||||
|
||||
|
||||
usb_map_path = os.path.join(current_path, "payloads/Kexts/Maps/Zip/" "USB-Map-%s.zip" % current_model)
|
||||
if os.path.exists(usb_map_path):
|
||||
print("- Adding USB Map for %s" % current_model)
|
||||
copy(usb_map_path, kext_path_build)
|
||||
map_name = ("USB-Map-%s.kext" % current_model)
|
||||
plist_data = plist_data.replace(
|
||||
"USB-Map-SMBIOS.kext",
|
||||
map_name
|
||||
)
|
||||
|
||||
|
||||
# Checks for ACPI
|
||||
# Add SSDTs
|
||||
if current_model in ModelArray.pciSSDT:
|
||||
print("- Adding SSDT-CPBG.aml")
|
||||
copy(pci_ssdt_path, acpi_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--SSDT-CPBG-->",
|
||||
"<true/><!--SSDT-CPBG-->"
|
||||
)
|
||||
|
||||
# Check for Kernel Patches
|
||||
if current_model in ModelArray.LegacyHID:
|
||||
print("- Adding IOHIDFamily Patch")
|
||||
copy(pci_ssdt_path, acpi_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<false/><!--IOHIDFamily-->",
|
||||
"<true/><!--IOHIDFamily-->"
|
||||
)
|
||||
|
||||
# Check for EFI Drivers
|
||||
if current_model in ModelArray.NVMePatch:
|
||||
print("- Adding NVMe support")
|
||||
copy(nvme_driver_path, drivers_path_build)
|
||||
plist_data = plist_data.replace(
|
||||
"<string>#NvmExpressDxe.efi</string>",
|
||||
"<string>NvmExpressDxe.efi</string>"
|
||||
)
|
||||
|
||||
# Add new SMBIOS data
|
||||
if current_model in ModelArray.MacBookAir61:
|
||||
print("- Spoofing to MacBookAir6,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookAir6,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookAir62:
|
||||
print("- Spoofing to MacBookAir6,2")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookAir6,2"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookPro111:
|
||||
print("- Spoofing to MacBookPro11,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookPro11,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookPro112:
|
||||
print("- Spoofing to MacBookPro11,2")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookPro11,2"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.Macmini71:
|
||||
print("- Spoofing to Macmini7,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
" Macmini7,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.iMac151:
|
||||
print("- Spoofing to iMac15,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"iMac15,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.iMac144:
|
||||
print("- Spoofing to iMac14,4")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"iMac14,4"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacPro71:
|
||||
print("- Spoofing to MacPro7,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
plist_data = plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacPro7,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
plist_data = plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
plist_data = plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
|
||||
# Patch UUID
|
||||
uuidGen = subprocess.Popen(["uuidgen"], stdout=subprocess.PIPE).communicate()[0]
|
||||
plist_data = plist_data.replace(
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
uuidGen
|
||||
)
|
||||
|
||||
BuildOpenCore.BuildEFI()
|
||||
BuildOpenCore.BuildSMBIOS()
|
||||
# Save config.plist changes in memory
|
||||
with open(plist_path_build_full, 'w') as file:
|
||||
file.write(plist_data)
|
||||
with open(Versions.plist_path_build_full, 'w') as file:
|
||||
file.write(Versions.plist_data)
|
||||
|
||||
# Clean up Build Folder
|
||||
print("")
|
||||
print("Cleaning build folder")
|
||||
os.chdir(kext_path_build)
|
||||
extension = ".zip"
|
||||
for item in os.listdir(kext_path_build): # loop through items in dir
|
||||
if item.endswith(extension): # check for ".zip" extension
|
||||
file_name = os.path.abspath(item) # get full path of files
|
||||
zip_ref = zipfile.ZipFile(file_name) # create zipfile object
|
||||
zip_ref.extractall(kext_path_build) # extract file to dir
|
||||
zip_ref.close() # close file
|
||||
os.remove(file_name) # delete zipped file
|
||||
rmtree("__MACOSX")
|
||||
os.chdir(build_path)
|
||||
rmtree("__MACOSX")
|
||||
os.remove(opencore_path_build)
|
||||
os.chdir(current_path)
|
||||
BuildOpenCore.CleanBuildFolder()
|
||||
|
||||
print("")
|
||||
print("Your OpenCore EFI has been built at:")
|
||||
print(" %s" % opencore_path_done)
|
||||
print(" %s" % Versions.opencore_path_done)
|
||||
print("")
|
||||
AutoBuilderMenu = raw_input("Press any key to return to previous menu: ")
|
||||
if AutoBuilderMenu=="1":
|
||||
@@ -593,7 +197,7 @@ while MainMenu:
|
||||
SMBIOSMenuYN = raw_input("Is this correcy?(y/n)")
|
||||
if SMBIOSMenuYN in {"y", "Y", "yes", "Yes"}:
|
||||
SMBIOSMenu=False
|
||||
current_model = SMBIOSOption
|
||||
BuildOpenCore.current_model = SMBIOSOption
|
||||
MainMenu=True
|
||||
# Set variabel to show we're not patching the system
|
||||
# Ensures we don't use logic for determining the Wifi card model
|
||||
|
||||
346
Resources/BuildOpenCore.py
Normal file
346
Resources/BuildOpenCore.py
Normal file
@@ -0,0 +1,346 @@
|
||||
# Commands for building the EFI and SMBIOS
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from shutil import copy
|
||||
from shutil import rmtree
|
||||
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
import Versions
|
||||
import ModelArray
|
||||
|
||||
#print(Versions.opencore_version)
|
||||
|
||||
# Find SMBIOS of machine
|
||||
current_model = subprocess.Popen("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE)
|
||||
current_model = [line.strip().split(": ", 1)[1] for line in current_model.stdout.read().split("\n") if line.strip().startswith("Model Identifier")][0]
|
||||
|
||||
def BuildEFI():
|
||||
|
||||
if not os.path.exists(Versions.build_path):
|
||||
os.makedirs(Versions.build_path)
|
||||
print("Created Build Folder")
|
||||
else:
|
||||
print("Build Folder already present, skipping")
|
||||
# Copy OpenCore into Build Folder
|
||||
|
||||
if os.path.exists(Versions.opencore_path_build):
|
||||
print("Deleting old copy of OpenCore zip")
|
||||
os.remove(Versions.opencore_path_build)
|
||||
if os.path.exists(Versions.opencore_path_done):
|
||||
print("Deleting old copy of OpenCore folder")
|
||||
rmtree(Versions.opencore_path_done)
|
||||
print("")
|
||||
print("- Adding OpenCore v%s" % Versions.opencore_version)
|
||||
copy(Versions.opencore_path, Versions.build_path)
|
||||
zipfile.ZipFile(Versions.opencore_path_build).extractall(Versions.build_path)
|
||||
|
||||
print("- Adding config.plist v%s" % Versions.opencore_version)
|
||||
# Setup config.plist for editing
|
||||
copy(Versions.plist_path, Versions.plist_path_build)
|
||||
with open(Versions.plist_path_build_full, 'r') as file :
|
||||
Versions.plist_data = file.read()
|
||||
|
||||
print("- Adding Lilu %s" % Versions.lilu_version)
|
||||
copy(Versions.lilu_path, Versions.kext_path_build)
|
||||
|
||||
print("- Adding WhateverGreen %s" % Versions.whatevergreen_version)
|
||||
copy(Versions.whatevergreen_path, Versions.kext_path_build)
|
||||
|
||||
# Checks for kexts
|
||||
# CPU Kext Patches
|
||||
if current_model in ModelArray.DualSocket:
|
||||
print("- Adding AppleMCEReporterDisabler v%s" % Versions.mce_version)
|
||||
copy(Versions.mce_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AppleMCEReporterDisabler-->",
|
||||
"<true/><!--AppleMCEReporterDisabler-->"
|
||||
)
|
||||
|
||||
if current_model in ModelArray.SSEEmulator:
|
||||
print("- Adding AAAMouSSE v%s" % Versions.mousse_version)
|
||||
copy(Versions.mousse_version, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AAAMouSSE-->",
|
||||
"<true/><!--AAAMouSSE-->"
|
||||
)
|
||||
if current_model in ModelArray.MissingSSE42:
|
||||
print("- Adding telemetrap %s" % Versions.telemetrap_version)
|
||||
copy(Versions.telemetrap_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--telemetrap-->",
|
||||
"<true/><!--telemetrap-->"
|
||||
)
|
||||
|
||||
# Ethernet Patches
|
||||
|
||||
if current_model in ModelArray.EthernetNvidia:
|
||||
print("- Adding nForceEthernet v%s" % Versions.nforce_version)
|
||||
copy(Versions.nforce_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--nForceEthernet-->",
|
||||
"<true/><!--nForceEthernet-->"
|
||||
)
|
||||
if current_model in ModelArray.EthernetMarvell:
|
||||
print("- Adding MarvelYukonEthernet v%s" % Versions.marvel_version)
|
||||
copy(Versions.marvel_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--MarvelYukonEthernet-->",
|
||||
"<true/><!--MarvelYukonEthernet-->"
|
||||
)
|
||||
if current_model in ModelArray.EthernetBroadcom:
|
||||
print("- Adding CatalinaBCM5701Ethernet %s" % Versions.bcm570_version)
|
||||
copy(Versions.bcm570_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--CatalinaBCM5701Ethernet-->",
|
||||
"<true/><!--CatalinaBCM5701Ethernet-->"
|
||||
)
|
||||
|
||||
# Wifi Patches
|
||||
|
||||
if current_model in ModelArray.WifiAtheros:
|
||||
print("- Adding IO80211HighSierra v%s" % Versions.io80211high_sierra_version)
|
||||
copy(Versions.io80211high_sierra_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--IO80211HighSierra-->",
|
||||
"<true/><!--IO80211HighSierra-->"
|
||||
)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AirPortAtheros40-->",
|
||||
"<true/><!--AirPortAtheros40-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM94328:
|
||||
print("- Wifi patches currently unsupported")
|
||||
# TO-DO: Add El Capitan's IO80211
|
||||
if current_model in ModelArray.WifiBCM94322:
|
||||
print("- Adding IO80211Mojave %s" % Versions.io80211mojave_version)
|
||||
copy(Versions.io80211mojave_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--IO80211Mojave-->",
|
||||
"<true/><!--IO80211Mojave-->"
|
||||
)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AirPortBrcm4331-->",
|
||||
"<true/><!--AirPortBrcm4331-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM943224:
|
||||
print("- Adding IO80211Mojave %s" % Versions.io80211mojave_version)
|
||||
copy(Versions.io80211mojave_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--IO80211Mojave-->",
|
||||
"<true/><!--IO80211Mojave-->"
|
||||
)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AirPortBrcm4331-->",
|
||||
"<true/><!--AirPortBrcm4331-->"
|
||||
)
|
||||
if current_model in ModelArray.WifiBCM94331:
|
||||
print("- Adding AirportBrcmFixup and appling fake ID")
|
||||
copy(Versions.airportbcrmfixup_path, Versions.kext_path_build)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AirportBrcmFixup-->",
|
||||
"<true/><!--AirportBrcmFixup-->"
|
||||
)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"<false/><!--AirPortBrcmNIC_Injector-->",
|
||||
"<true/><!--AirPortBrcmNIC_Injector-->"
|
||||
)
|
||||
if current_model in ("iMac13,1", "iMac13,2"):
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"#PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)",
|
||||
"PciRoot(0x0)/Pci(0x1C,0x3)Pci(0x0,0x0)"
|
||||
)
|
||||
else:
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"#PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)",
|
||||
"PciRoot(0x0)/Pci(0x1C,0x1)Pci(0x0,0x0)"
|
||||
)
|
||||
usb_map_path = os.path.join(Versions.current_path, "payloads/Kexts/Maps/Zip/" "USB-Map-%s.zip" % current_model)
|
||||
if os.path.exists(usb_map_path):
|
||||
print("- Adding USB Map for %s" % current_model)
|
||||
copy(usb_map_path, Versions.kext_path_build)
|
||||
map_name = ("USB-Map-%s.kext" % current_model)
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"USB-Map-SMBIOS.kext",
|
||||
map_name
|
||||
)
|
||||
|
||||
def BuildSMBIOS():
|
||||
# Add new SMBIOS data
|
||||
if current_model in ModelArray.MacBookAir61:
|
||||
print("- Spoofing to MacBookAir6,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookAir6,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookAir62:
|
||||
print("- Spoofing to MacBookAir6,2")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookAir6,2"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookPro111:
|
||||
print("- Spoofing to MacBookPro11,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookPro11,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacBookPro112:
|
||||
print("- Spoofing to MacBookPro11,2")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacBookPro11,2"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.Macmini71:
|
||||
print("- Spoofing to Macmini7,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
" Macmini7,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.iMac151:
|
||||
print("- Spoofing to iMac15,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"iMac15,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.iMac144:
|
||||
print("- Spoofing to iMac14,4")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"iMac14,4"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
if current_model in ModelArray.MacPro71:
|
||||
print("- Spoofing to MacPro7,1")
|
||||
# Patch SMBIOS
|
||||
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"iMac19,1",
|
||||
"MacPro7,1"
|
||||
)
|
||||
# Patch Number Serial
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"W00000000001",
|
||||
"Dortania-SN"
|
||||
)
|
||||
# Patch MLB
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"M0000000000000001",
|
||||
"Dortania-MLB"
|
||||
)
|
||||
|
||||
# Patch UUID
|
||||
uuidGen = subprocess.Popen(["uuidgen"], stdout=subprocess.PIPE).communicate()[0]
|
||||
Versions.plist_data = Versions.plist_data.replace(
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
uuidGen
|
||||
)
|
||||
|
||||
def CleanBuildFolder():
|
||||
# Clean up Build Folder
|
||||
print("")
|
||||
print("Cleaning build folder")
|
||||
os.chdir(Versions.kext_path_build)
|
||||
for item in os.listdir(Versions.kext_path_build):
|
||||
if item.endswith(".zip"):
|
||||
file_name = os.path.abspath(item)
|
||||
zip_ref = zipfile.ZipFile(file_name)
|
||||
zip_ref.extractall(Versions.kext_path_build)
|
||||
zip_ref.close()
|
||||
os.remove(file_name)
|
||||
# Clean up Python's unzip
|
||||
if os.path.exists("__MACOSX"):
|
||||
rmtree("__MACOSX")
|
||||
os.chdir(Versions.build_path)
|
||||
if os.path.exists("__MACOSX"):
|
||||
rmtree("__MACOSX")
|
||||
os.remove(Versions.opencore_path_build)
|
||||
os.chdir(Versions.current_path)
|
||||
65
Resources/Versions.py
Normal file
65
Resources/Versions.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Define Files
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from shutil import copy
|
||||
from shutil import rmtree
|
||||
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# List build versions
|
||||
opencore_version = "0.6.3"
|
||||
lilu_version = "1.4.9"
|
||||
whatevergreen_version = "1.4.4"
|
||||
airportbcrmfixup_version = "2.1.1"
|
||||
bcm570_version = "1.0.0"
|
||||
marvel_version = "1.0.0"
|
||||
nforce_version = "1.0.0"
|
||||
mce_version = "1.0.0"
|
||||
mousse_version = "0.93"
|
||||
telemetrap_version = "1.0.0"
|
||||
io80211high_sierra_version = "1.0.0"
|
||||
io80211mojave_version = "1.0.0"
|
||||
|
||||
# List current location
|
||||
current_path = os.getcwd()
|
||||
|
||||
# Payload Location
|
||||
# OpenCore
|
||||
opencore_path = os.path.join(current_path, "payloads/OpenCore/" "OpenCore-v%s.zip" % opencore_version)
|
||||
plist_path = os.path.join(current_path, "payloads/Config/v%s/" "config.plist" % opencore_version)
|
||||
|
||||
# ACPI
|
||||
pci_ssdt_path = os.path.join(current_path, "payloads/ACPI/" "SSDT-CPBG.aml")
|
||||
|
||||
# Drivers
|
||||
nvme_driver_path = os.path.join(current_path, "payloads/Drivers/" "NvmExpressDxe.efi")
|
||||
|
||||
# Kexts
|
||||
lilu_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "Lilu-v%s.zip" % lilu_version)
|
||||
whatevergreen_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "WhateverGreen-v%s.zip" % whatevergreen_version)
|
||||
airportbcrmfixup_path = os.path.join(current_path, "payloads/Kexts/Acidanthera/" "AirportBrcmFixup-v%s.zip" % airportbcrmfixup_version)
|
||||
bcm570_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "CatalinaBCM5701Ethernet-v%s.zip" % bcm570_version)
|
||||
marvel_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "MarvelYukonEthernet-v%s.zip" % marvel_version)
|
||||
nforce_path = os.path.join(current_path, "payloads/Kexts/Ethernet/" "nForceEthernet-v%s.zip" % nforce_version)
|
||||
mce_path = os.path.join(current_path, "payloads/Kexts/Misc/" "AppleMCEReporterDisabler-v%s.zip" % mce_version)
|
||||
mousse_path = os.path.join(current_path, "payloads/Kexts/SSE/" "AAAMouSSE-v%s.zip" % mousse_version)
|
||||
telemetrap_path = os.path.join(current_path, "payloads/Kexts/SSE/" "telemetrap-v%s.zip" % telemetrap_version)
|
||||
io80211high_sierra_path = os.path.join(current_path, "payloads/Kexts/Wifi/" "IO80211HighSierra-v%s.zip" % io80211high_sierra_version)
|
||||
io80211mojave_path = os.path.join(current_path, "payloads/Kexts/Wifi/" "IO80211Mojave-v%s.zip" % io80211mojave_version)
|
||||
|
||||
# Build Location
|
||||
opencore_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s.zip" % opencore_version)
|
||||
plist_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/" % opencore_version)
|
||||
plist_path_build_full = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/config.plist" % opencore_version)
|
||||
acpi_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/ACPI" % opencore_version)
|
||||
drivers_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/Drivers" % opencore_version)
|
||||
kext_path_build = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s/EFI/OC/Kexts" % opencore_version)
|
||||
opencore_path_done = os.path.join(current_path, "Build-Folder/" "OpenCore-v%s" % opencore_version)
|
||||
build_path = os.path.join(current_path, r'Build-Folder/')
|
||||
|
||||
# Tools
|
||||
macserial_path = os.path.join(current_path, "payloads/" "Tools")
|
||||
@@ -1,4 +1,4 @@
|
||||
# Source: CorpNewt
|
||||
# Credit: CorpNewt
|
||||
from os.path import dirname, basename, isfile
|
||||
import glob
|
||||
modules = glob.glob(dirname(__file__)+"/*.py")
|
||||
|
||||
Reference in New Issue
Block a user