mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 20:10:14 +10:00
Add basic EFI installation
This commit is contained in:
@@ -15,10 +15,6 @@ from Resources import *
|
|||||||
# List build versions
|
# List build versions
|
||||||
patcher_version = "0.0.1"
|
patcher_version = "0.0.1"
|
||||||
|
|
||||||
# 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]
|
|
||||||
|
|
||||||
CustomSMBIOS=False
|
CustomSMBIOS=False
|
||||||
MainMenu=True
|
MainMenu=True
|
||||||
|
|
||||||
@@ -48,11 +44,12 @@ while MainMenu:
|
|||||||
print("---------------------------------------------------")
|
print("---------------------------------------------------")
|
||||||
print("")
|
print("")
|
||||||
print(" 1. Build OpenCore")
|
print(" 1. Build OpenCore")
|
||||||
print(" 2. Create macOS Installer - Not yet implemented")
|
print(" 2. Install OpenCore to USB/internal drive")
|
||||||
print(" 3. Install OpenCore to USB/internal drive - Not yet implemented")
|
print(" 3. Change model")
|
||||||
print(" 4. Change model")
|
print(" 4. Credits")
|
||||||
print(" 5. Credits")
|
print(" 5. Exit")
|
||||||
print(" 6. Exit")
|
macserialoutput = subprocess.Popen(["./payloads/tools/macserial", "-m", "MacBookAir6,1"], stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
print(macserialoutput)
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
MainMenu = raw_input('Please select an option: ')
|
MainMenu = raw_input('Please select an option: ')
|
||||||
@@ -87,12 +84,8 @@ while MainMenu:
|
|||||||
print("")
|
print("")
|
||||||
BuildOpenCore.BuildEFI()
|
BuildOpenCore.BuildEFI()
|
||||||
BuildOpenCore.BuildSMBIOS()
|
BuildOpenCore.BuildSMBIOS()
|
||||||
# Save config.plist changes in memory
|
BuildOpenCore.SavePlist()
|
||||||
with open(Versions.plist_path_build_full, 'w') as file:
|
|
||||||
file.write(Versions.plist_data)
|
|
||||||
|
|
||||||
BuildOpenCore.CleanBuildFolder()
|
BuildOpenCore.CleanBuildFolder()
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
print("Your OpenCore EFI has been built at:")
|
print("Your OpenCore EFI has been built at:")
|
||||||
print(" %s" % Versions.opencore_path_done)
|
print(" %s" % Versions.opencore_path_done)
|
||||||
@@ -110,34 +103,8 @@ while MainMenu:
|
|||||||
else:
|
else:
|
||||||
print("\n Not Valid Choice Try again")
|
print("\n Not Valid Choice Try again")
|
||||||
|
|
||||||
|
|
||||||
if MainMenu=="2":
|
|
||||||
macOSInstallerMenu=True
|
|
||||||
while macOSInstallerMenu:
|
|
||||||
os.system('clear')
|
|
||||||
|
|
||||||
print("#######################################################")
|
|
||||||
print(" Create macOS Installer")
|
|
||||||
print("#######################################################")
|
|
||||||
print("")
|
|
||||||
print(" Supported OSes:")
|
|
||||||
print("")
|
|
||||||
print(" 1. macOS 11, Big Sur - Not yet implemented")
|
|
||||||
print(" 2. Return to main menu")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
macOSInstallerMenu = raw_input('Please select an option: ')
|
|
||||||
|
|
||||||
if macOSInstallerMenu=="1":
|
|
||||||
print("\n Not yet implemented")
|
|
||||||
elif macOSInstallerMenu=="2":
|
|
||||||
print("\n Returning to main menu...")
|
|
||||||
macOSInstallerMenu=False
|
|
||||||
MainMenu=True
|
|
||||||
else:
|
|
||||||
print("\n Not Valid Choice Try again")
|
|
||||||
|
|
||||||
elif MainMenu=="3":
|
elif MainMenu=="2":
|
||||||
print("\n Not yet implemented")
|
print("\n Not yet implemented")
|
||||||
OpenCoreInstallerMenu=True
|
OpenCoreInstallerMenu=True
|
||||||
while OpenCoreInstallerMenu:
|
while OpenCoreInstallerMenu:
|
||||||
@@ -147,37 +114,34 @@ while MainMenu:
|
|||||||
print(" Install OpenCore to drive")
|
print(" Install OpenCore to drive")
|
||||||
print("#######################################################")
|
print("#######################################################")
|
||||||
print("")
|
print("")
|
||||||
print(" 1. Install to USB/internal drive - Not yet implemented")
|
print(" 1. Install to USB/internal drive")
|
||||||
print(" 2. Mount OpenCore drive - Not yet implemented")
|
print(" 2. Return to main menu")
|
||||||
print(" 3. Move OpenCore from USB to internal drive - Not yet implemented")
|
|
||||||
print(" 4. Return to main menu")
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
OpenCoreInstallerMenu = raw_input('Please select an option: ')
|
OpenCoreInstallerMenu = raw_input('Please select an option: ')
|
||||||
|
|
||||||
if OpenCoreInstallerMenu=="1":
|
if OpenCoreInstallerMenu=="1":
|
||||||
print("\n Not yet implemented")
|
os.system('clear')
|
||||||
# List all disks with GPT
|
if os.path.exists(Versions.opencore_path_done):
|
||||||
# Mount user selected drive's EFI
|
print("Found OpenCore in Build Folder")
|
||||||
# Copy OpenCore to EFI
|
BuildOpenCore.ListDiskutil()
|
||||||
|
BuildOpenCore.MoveOpenCore()
|
||||||
|
else:
|
||||||
|
print("OpenCore folder missing!")
|
||||||
|
print("Please build OpenCore first")
|
||||||
|
print("")
|
||||||
|
OpenCoreInstallerMenu = raw_input("Press any key to exit: ")
|
||||||
|
if OpenCoreInstallerMenu=="1":
|
||||||
|
print("Returning to main menu...")
|
||||||
|
OpenCoreInstallerMenu=False
|
||||||
elif OpenCoreInstallerMenu=="2":
|
elif OpenCoreInstallerMenu=="2":
|
||||||
print("\n Not yet implemented")
|
|
||||||
# Mount OpenCore boot drive
|
|
||||||
# sudo diskutil mount $(nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-path | sed 's/.*GPT,\([^,]*\),.*/\1/')
|
|
||||||
elif OpenCoreInstallerMenu=="3":
|
|
||||||
print("\n Not yet implemented")
|
|
||||||
# Mount OpenCore Boot drive
|
|
||||||
# Copy EFI to Backup folder
|
|
||||||
# Ask user for internal drive
|
|
||||||
# sudo diskutil mount $(nvram 4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102:boot-path | sed 's/.*GPT,\([^,]*\),.*/\1/')
|
|
||||||
elif OpenCoreInstallerMenu=="4":
|
|
||||||
print("\n Returning to main menu...")
|
print("\n Returning to main menu...")
|
||||||
OpenCoreInstallerMenu=False
|
OpenCoreInstallerMenu=False
|
||||||
MainMenu=True
|
MainMenu=True
|
||||||
else:
|
else:
|
||||||
print("\n Not Valid Choice Try again")
|
print("\n Not Valid Choice Try again")
|
||||||
|
|
||||||
elif MainMenu=="4":
|
elif MainMenu=="3":
|
||||||
SMBIOSMenu=True
|
SMBIOSMenu=True
|
||||||
while SMBIOSMenu:
|
while SMBIOSMenu:
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
@@ -202,7 +166,7 @@ while MainMenu:
|
|||||||
# Set variabel to show we're not patching the system
|
# Set variabel to show we're not patching the system
|
||||||
# Ensures we don't use logic for determining the Wifi card model
|
# Ensures we don't use logic for determining the Wifi card model
|
||||||
CustomSMBIOS=True
|
CustomSMBIOS=True
|
||||||
elif MainMenu=="5":
|
elif MainMenu=="4":
|
||||||
CreditMenu=True
|
CreditMenu=True
|
||||||
while CreditMenu:
|
while CreditMenu:
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
@@ -224,7 +188,7 @@ while MainMenu:
|
|||||||
CreditMenu=False
|
CreditMenu=False
|
||||||
MainMenu=True
|
MainMenu=True
|
||||||
|
|
||||||
elif MainMenu=="6":
|
elif MainMenu=="5":
|
||||||
print("\n Closing program...")
|
print("\n Closing program...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ Current TO-DO's with this patcher:
|
|||||||
* [x] Create OpenCore EFI
|
* [x] Create OpenCore EFI
|
||||||
* [ ] Generate new serials
|
* [ ] Generate new serials
|
||||||
* [ ] Create macOS Installer
|
* [ ] Create macOS Installer
|
||||||
* [ ] Install OpenCore to USB
|
* [x] Install OpenCore to drive
|
||||||
* [ ] Install OpenCore to internal drive
|
|
||||||
* [x] USB mapping
|
* [x] USB mapping
|
||||||
* [ ] Legacy GPU Patches
|
* [ ] Legacy GPU Patches
|
||||||
* ie. 2011 and older
|
* ie. 2011 and older
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
from shutil import copy
|
from shutil import copy
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
from distutils.dir_util import copy_tree
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
@@ -14,12 +15,12 @@ import zipfile
|
|||||||
import Versions
|
import Versions
|
||||||
import ModelArray
|
import ModelArray
|
||||||
|
|
||||||
#print(Versions.opencore_version)
|
|
||||||
|
|
||||||
# Find SMBIOS of machine
|
# Find SMBIOS of machine
|
||||||
current_model = subprocess.Popen("system_profiler SPHardwareDataType".split(), stdout=subprocess.PIPE)
|
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 = [line.strip().split(": ", 1)[1] for line in current_model.stdout.read().split("\n") if line.strip().startswith("Model Identifier")][0]
|
||||||
|
|
||||||
|
OCExist = False
|
||||||
|
|
||||||
def BuildEFI():
|
def BuildEFI():
|
||||||
|
|
||||||
if not os.path.exists(Versions.build_path):
|
if not os.path.exists(Versions.build_path):
|
||||||
@@ -171,7 +172,7 @@ def BuildEFI():
|
|||||||
)
|
)
|
||||||
|
|
||||||
def BuildSMBIOS():
|
def BuildSMBIOS():
|
||||||
# Add new SMBIOS data
|
# Add new SMBIOS data
|
||||||
if current_model in ModelArray.MacBookAir61:
|
if current_model in ModelArray.MacBookAir61:
|
||||||
print("- Spoofing to MacBookAir6,1")
|
print("- Spoofing to MacBookAir6,1")
|
||||||
# Patch SMBIOS
|
# Patch SMBIOS
|
||||||
@@ -324,6 +325,10 @@ def BuildSMBIOS():
|
|||||||
uuidGen
|
uuidGen
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def SavePlist():
|
||||||
|
with open(Versions.plist_path_build_full, 'w') as file:
|
||||||
|
file.write(Versions.plist_data)
|
||||||
|
|
||||||
def CleanBuildFolder():
|
def CleanBuildFolder():
|
||||||
# Clean up Build Folder
|
# Clean up Build Folder
|
||||||
print("")
|
print("")
|
||||||
@@ -343,4 +348,29 @@ def CleanBuildFolder():
|
|||||||
if os.path.exists("__MACOSX"):
|
if os.path.exists("__MACOSX"):
|
||||||
rmtree("__MACOSX")
|
rmtree("__MACOSX")
|
||||||
os.remove(Versions.opencore_path_build)
|
os.remove(Versions.opencore_path_build)
|
||||||
os.chdir(Versions.current_path)
|
os.chdir(Versions.current_path)
|
||||||
|
|
||||||
|
def ListDiskutil():
|
||||||
|
DiskMenu = True
|
||||||
|
while DiskMenu:
|
||||||
|
os.system('clear')
|
||||||
|
diskList = subprocess.Popen(["diskutil", "list"], stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
print(diskList)
|
||||||
|
ChosenDisk = raw_input('Please select the disk you want to install OpenCore to(ie. disk1): ')
|
||||||
|
ChosenDisk = ChosenDisk + "s1"
|
||||||
|
print("Trying to mount %s" % ChosenDisk)
|
||||||
|
diskMount = subprocess.Popen(["sudo", "diskutil", "mount", ChosenDisk], stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
print(diskMount)
|
||||||
|
DiskMenu = raw_input("Press any key to continue: ")
|
||||||
|
|
||||||
|
def MoveOpenCore():
|
||||||
|
print("")
|
||||||
|
print("Coping OpenCore onto Volumes/EFI")
|
||||||
|
efiVol = "/Volumes/EFI"
|
||||||
|
if os.path.exists("/Volumes/EFI/EFI"):
|
||||||
|
print("Cleaning EFI folder")
|
||||||
|
rmtree("/Volumes/EFI/EFI")
|
||||||
|
if os.path.exists(Versions.opencore_path_done):
|
||||||
|
copy_tree(Versions.opencore_path_done, efiVol)
|
||||||
|
print("OpenCore transfer complete")
|
||||||
|
print("")
|
||||||
Reference in New Issue
Block a user