diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 58d074572..ffac87d0d 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -15,10 +15,6 @@ from Resources import * # List build versions 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 MainMenu=True @@ -48,11 +44,12 @@ while MainMenu: print("---------------------------------------------------") print("") print(" 1. Build OpenCore") - print(" 2. Create macOS Installer - Not yet implemented") - print(" 3. Install OpenCore to USB/internal drive - Not yet implemented") - print(" 4. Change model") - print(" 5. Credits") - print(" 6. Exit") + print(" 2. Install OpenCore to USB/internal drive") + print(" 3. Change model") + print(" 4. Credits") + print(" 5. Exit") + macserialoutput = subprocess.Popen(["./payloads/tools/macserial", "-m", "MacBookAir6,1"], stdout=subprocess.PIPE).communicate()[0] + print(macserialoutput) print("") MainMenu = raw_input('Please select an option: ') @@ -87,12 +84,8 @@ while MainMenu: print("") BuildOpenCore.BuildEFI() BuildOpenCore.BuildSMBIOS() - # Save config.plist changes in memory - with open(Versions.plist_path_build_full, 'w') as file: - file.write(Versions.plist_data) - + BuildOpenCore.SavePlist() BuildOpenCore.CleanBuildFolder() - print("") print("Your OpenCore EFI has been built at:") print(" %s" % Versions.opencore_path_done) @@ -110,34 +103,8 @@ while MainMenu: else: 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") OpenCoreInstallerMenu=True while OpenCoreInstallerMenu: @@ -147,37 +114,34 @@ while MainMenu: print(" Install OpenCore to drive") print("#######################################################") print("") - print(" 1. Install to USB/internal drive - Not yet implemented") - print(" 2. Mount OpenCore drive - Not yet implemented") - print(" 3. Move OpenCore from USB to internal drive - Not yet implemented") - print(" 4. Return to main menu") + print(" 1. Install to USB/internal drive") + print(" 2. Return to main menu") print("") OpenCoreInstallerMenu = raw_input('Please select an option: ') if OpenCoreInstallerMenu=="1": - print("\n Not yet implemented") - # List all disks with GPT - # Mount user selected drive's EFI - # Copy OpenCore to EFI + os.system('clear') + if os.path.exists(Versions.opencore_path_done): + print("Found OpenCore in Build Folder") + 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": - 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...") OpenCoreInstallerMenu=False MainMenu=True else: print("\n Not Valid Choice Try again") - elif MainMenu=="4": + elif MainMenu=="3": SMBIOSMenu=True while SMBIOSMenu: os.system('clear') @@ -202,7 +166,7 @@ while MainMenu: # Set variabel to show we're not patching the system # Ensures we don't use logic for determining the Wifi card model CustomSMBIOS=True - elif MainMenu=="5": + elif MainMenu=="4": CreditMenu=True while CreditMenu: os.system('clear') @@ -224,7 +188,7 @@ while MainMenu: CreditMenu=False MainMenu=True - elif MainMenu=="6": + elif MainMenu=="5": print("\n Closing program...") sys.exit(1) else: diff --git a/README.md b/README.md index 901cac369..f01416333 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ Current TO-DO's with this patcher: * [x] Create OpenCore EFI * [ ] Generate new serials * [ ] Create macOS Installer -* [ ] Install OpenCore to USB -* [ ] Install OpenCore to internal drive +* [x] Install OpenCore to drive * [x] USB mapping * [ ] Legacy GPU Patches * ie. 2011 and older diff --git a/Resources/BuildOpenCore.py b/Resources/BuildOpenCore.py index 9fcb6e49f..f016ad4c4 100644 --- a/Resources/BuildOpenCore.py +++ b/Resources/BuildOpenCore.py @@ -4,6 +4,7 @@ from __future__ import print_function from shutil import copy from shutil import rmtree +from distutils.dir_util import copy_tree import os import json @@ -14,12 +15,12 @@ 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] +OCExist = False + def BuildEFI(): if not os.path.exists(Versions.build_path): @@ -171,7 +172,7 @@ def BuildEFI(): ) def BuildSMBIOS(): - # Add new SMBIOS data + # Add new SMBIOS data if current_model in ModelArray.MacBookAir61: print("- Spoofing to MacBookAir6,1") # Patch SMBIOS @@ -324,6 +325,10 @@ def BuildSMBIOS(): uuidGen ) +def SavePlist(): + with open(Versions.plist_path_build_full, 'w') as file: + file.write(Versions.plist_data) + def CleanBuildFolder(): # Clean up Build Folder print("") @@ -343,4 +348,29 @@ def CleanBuildFolder(): if os.path.exists("__MACOSX"): rmtree("__MACOSX") os.remove(Versions.opencore_path_build) - os.chdir(Versions.current_path) \ No newline at end of file + 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("") \ No newline at end of file