Restructure into package format

This commit is contained in:
Mykola Grymalyuk
2024-03-31 21:27:36 -06:00
parent d02d89b9c0
commit 463bed4e06
81 changed files with 881 additions and 464 deletions

View File

@@ -38,7 +38,7 @@ jobs:
# p12-password: ${{ secrets.MAC_NOTARIZATION_PASSWORD }} # p12-password: ${{ secrets.MAC_NOTARIZATION_PASSWORD }}
- name: Codesign Binary - name: Codesign Binary
run: 'codesign -s "${{ env.MAC_CODESIGN_IDENTITY }}" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"' run: 'codesign -s "${{ env.MAC_CODESIGN_IDENTITY }}" -v --force --deep --timestamp --entitlements ./ci_tooling/entitlements/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
- name: Package Binary - name: Package Binary
run: cd dist; ditto -c -k --sequesterRsrc --keepParent OpenCore-Patcher.app ../OpenCore-Patcher-wxPython.app.zip run: cd dist; ditto -c -k --sequesterRsrc --keepParent OpenCore-Patcher.app ../OpenCore-Patcher-wxPython.app.zip
@@ -47,7 +47,7 @@ jobs:
run: xcrun notarytool submit OpenCore-Patcher-wxPython.app.zip --apple-id "${{ env.MAC_NOTARIZATION_USERNAME }}" --password "${{ env.MAC_NOTARIZATION_PASSWORD }}" --team-id "${{ env.MAC_NOTARIZATION_TEAM_ID }}" run: xcrun notarytool submit OpenCore-Patcher-wxPython.app.zip --apple-id "${{ env.MAC_NOTARIZATION_USERNAME }}" --password "${{ env.MAC_NOTARIZATION_PASSWORD }}" --team-id "${{ env.MAC_NOTARIZATION_TEAM_ID }}"
- name: Generate support package - name: Generate support package
run: /usr/local/bin/packagesbuild ./payloads/InstallPackage/AutoPkg-Assets-Setup.pkgproj run: /usr/local/bin/packagesbuild ./ci_tooling/autopkg/AutoPkg-Assets-Setup.pkgproj
- name: Prepare App for Upload - name: Prepare App for Upload
run: mv ./OpenCore-Patcher-wxPython.app.zip ./OpenCore-Patcher-GUI.app.zip run: mv ./OpenCore-Patcher-wxPython.app.zip ./OpenCore-Patcher-GUI.app.zip

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""
# Generate stand alone application for OpenCore-Patcher Build-Binary.command: Generate stand alone application for OpenCore-Patcher
# Copyright (C) 2022-2023 - Mykola Grymalyuk """
import os import os
import sys import sys
@@ -12,7 +12,7 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources import constants from opencore_legacy_patcher import constants
class CreateBinary: class CreateBinary:
@@ -229,7 +229,6 @@ class CreateBinary:
"Config", "Config",
"Drivers", "Drivers",
"Icon", "Icon",
"InstallPackage",
"Kexts", "Kexts",
"OpenCore", "OpenCore",
"Tools", "Tools",
@@ -237,10 +236,7 @@ class CreateBinary:
] ]
whitelist_files = [ whitelist_files = [
"entitlements.plist",
"launcher.sh",
"OC-Patcher-TUI.icns",
"OC-Patcher.icns",
] ]

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk """
from resources import main PyInstaller Entry Point
"""
from opencore_legacy_patcher import main
if __name__ == '__main__': if __name__ == '__main__':
main.OpenCoreLegacyPatcher() main()

View File

@@ -13,7 +13,7 @@ from PyInstaller.building.build_main import Analysis
sys.path.append(os.path.abspath(os.getcwd())) sys.path.append(os.path.abspath(os.getcwd()))
from resources import constants from opencore_legacy_patcher import constants
block_cipher = None block_cipher = None
@@ -70,7 +70,7 @@ coll = COLLECT(exe,
app = BUNDLE(coll, app = BUNDLE(coll,
name='OpenCore-Patcher.app', name='OpenCore-Patcher.app',
icon="payloads/OC-Patcher.icns", icon="payloads/Icon/AppIcons/OC-Patcher.icns",
bundle_identifier="com.dortania.opencore-legacy-patcher", bundle_identifier="com.dortania.opencore-legacy-patcher",
info_plist={ info_plist={
"CFBundleName": "OpenCore Legacy Patcher", "CFBundleName": "OpenCore Legacy Patcher",

View File

@@ -1,57 +0,0 @@
# Copyright (C) 2022, Mykola Grymalyuk
# Within AppleMobileFileIntegrity.kext, Apple has a bitmask-based boot-arg (ex. amfi=128)
# Below information is from reversed values in 13.0 Beta 6's AppleMobileFileIntegrity.kext
# Currently only 'amfi=3' has been used by Apple publicly
# - 0x3 used in 11.0.1 dyld source:
# - https://github.com/apple-oss-distributions/dyld/blob/5c9192436bb195e7a8fe61f22a229ee3d30d8222/testing/test-cases/kernel-hello-world.dtest/main.c#L2
import enum
class AppleMobileFileIntegrity(enum.IntEnum):
# Names set are solely for readability
# Internal names are unknown
AMFI_ALLOW_TASK_FOR_PID: int = 0x1 # Allow Task for PID (alt. amfi_unrestrict_task_for_pid=0x1)
AMFI_ALLOW_INVALID_SIGNATURE: int = 0x2 # Reduce sig enforcement (alt. amfi_allow_any_signature=0x1)
AMFI_LV_ENFORCE_THIRD_PARTY: int = 0x4 # Don't mark external binaries as platform binaries
AMFI_UNKNOWN_1: int = 0x8
AMFI_UNKNOWN_2: int = 0x10
AMFI_UNKNOWN_3: int = 0x20
AMFI_UNKNOWN_4: int = 0x40
AMFI_ALLOW_EVERYTHING: int = 0x80 # Disable sig enforcement and Library Validation (alt. amfi_get_out_of_my_way=0x1)
# Internally within AMFI.kext, Apple references 0x2 and 0x80 as both 'Disable signature enforcement'
# However 0x80 is a higher privilege than 0x2, and breaks TCC support in OS (ex. Camera, Microphone, etc prompts)
# Supported boot-args within AMFI.kext, last compared against 13.0 Beta 6
#
# Within _initializeAppleMobileFileIntegrity():
# - amfi_unrestrict_task_for_pid=0x1
# - amfi_dev_mode_policy=0x1
# - amfi_allow_any_signature=0x1
# - amfi_get_out_of_my_way=0x1
# - amfi_unrestricted_local_signing=0x1
# - pmap_cs_unrestricted_local_signing=0x1
# - amfi_ready_to_roll=0x1
# - cs_enforcement_disable=0x1
#
# Within AMFIInitializeLocalSigningPublicKey():
# - -restore
#
# Within macOSPolicyConfigurationInit():
# - amfi_force_policy=0x1
# - amfi_block_unsigned_code=0x1
# - amfi_force_cs_kill=0x1
# - amfi_hsp_disable=0x1
# - amfi_hsp_logging=0x1
# - amfi_allow_bni_as_platform=0x1
# - amfi_allow_non_platform=0x1
# - amfi_prevent_old_entitled_platform_binaries=0x1
# - amfi_allow_only_tc=0x1
# - amfi_allow_only_tc_override=0x1
#
# Within configurationSettingsInit()
# - amfi_enforce_launch_constraints=0x1
# - amfi_allow_3p_launch_constraints=0x1
# - BATS_TESTPLAN_ID="Custom Team ID"

View File

@@ -0,0 +1 @@
from .application_entry import main

View File

@@ -1,24 +1,31 @@
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk """
application_entry.py: Project entry point
"""
import os import os
import sys import sys
import time import time
import logging import logging
import threading import threading
from pathlib import Path from pathlib import Path
from resources.wx_gui import gui_entry from . import constants
from resources import (
constants, from .wx_gui import gui_entry
utilities,
from .detections import (
device_probe, device_probe,
os_probe, os_probe
)
from .utilities import (
utilities,
defaults, defaults,
arguments, arguments,
reroute_payloads, reroute_payloads,
commit_info, commit_info,
logging_handler, logging_handler,
analytics_handler, analytics_handler
) )
@@ -43,7 +50,7 @@ class OpenCoreLegacyPatcher:
Generate base data required for the patcher to run Generate base data required for the patcher to run
""" """
self.constants.wxpython_variant: bool = True self.constants.wxpython_variant = True
# Ensure we live after parent process dies (ie. LaunchAgent) # Ensure we live after parent process dies (ie. LaunchAgent)
os.setpgrp() os.setpgrp()
@@ -111,3 +118,9 @@ class OpenCoreLegacyPatcher:
time.sleep(0.1) time.sleep(0.1)
arguments.arguments(self.constants) arguments.arguments(self.constants)
def main():
"""
Main entry point
"""
OpenCoreLegacyPatcher()

View File

@@ -1,13 +1,13 @@
# pylint: disable=multiple-statements """
# Defines versioning, file paths and other settings for the patcher constants.py: Defines versioning, file paths and other settings for the patcher
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk """
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
from packaging import version from packaging import version
from resources import device_probe from .datasets import os_data
from data import os_data from .detections import device_probe
class Constants: class Constants:
@@ -739,7 +739,7 @@ class Constants:
@property @property
def app_icon_path(self): def app_icon_path(self):
return self.payload_path / Path("OC-Patcher.icns") return self.payload_path / Path("Icon/AppIcons/OC-Patcher.icns")
@property @property
def icon_path_external(self): def icon_path_external(self):

View File

@@ -0,0 +1,63 @@
"""
amfi_data.py: AppleMobileFileIntegrity Bitmask Data
"""
"""
Within AppleMobileFileIntegrity.kext, Apple has a bitmask-based boot-arg (ex. amfi=128)
Below information is from reversed values in 13.0 Beta 6's AppleMobileFileIntegrity.kext
Currently only 'amfi=3' has been used by Apple publicly
- 0x3 used in 11.0.1 dyld source:
- https://github.com/apple-oss-distributions/dyld/blob/5c9192436bb195e7a8fe61f22a229ee3d30d8222/testing/test-cases/kernel-hello-world.dtest/main.c#L2
"""
import enum
class AppleMobileFileIntegrity(enum.IntEnum):
# Names set are solely for readability
# Internal names are unknown
AMFI_ALLOW_TASK_FOR_PID: int = 0x1 # Allow Task for PID (alt. amfi_unrestrict_task_for_pid=0x1)
AMFI_ALLOW_INVALID_SIGNATURE: int = 0x2 # Reduce sig enforcement (alt. amfi_allow_any_signature=0x1)
AMFI_LV_ENFORCE_THIRD_PARTY: int = 0x4 # Don't mark external binaries as platform binaries
AMFI_UNKNOWN_1: int = 0x8
AMFI_UNKNOWN_2: int = 0x10
AMFI_UNKNOWN_3: int = 0x20
AMFI_UNKNOWN_4: int = 0x40
AMFI_ALLOW_EVERYTHING: int = 0x80 # Disable sig enforcement and Library Validation (alt. amfi_get_out_of_my_way=0x1)
"""
Internally within AMFI.kext, Apple references 0x2 and 0x80 as both 'Disable signature enforcement'
However 0x80 is a higher privilege than 0x2, and breaks TCC support in OS (ex. Camera, Microphone, etc prompts)
Supported boot-args within AMFI.kext, last compared against 13.0 Beta 6
Within _initializeAppleMobileFileIntegrity():
- amfi_unrestrict_task_for_pid=0x1
- amfi_dev_mode_policy=0x1
- amfi_allow_any_signature=0x1
- amfi_get_out_of_my_way=0x1
- amfi_unrestricted_local_signing=0x1
- pmap_cs_unrestricted_local_signing=0x1
- amfi_ready_to_roll=0x1
- cs_enforcement_disable=0x1
Within AMFIInitializeLocalSigningPublicKey():
- -restore
Within macOSPolicyConfigurationInit():
- amfi_force_policy=0x1
- amfi_block_unsigned_code=0x1
- amfi_force_cs_kill=0x1
- amfi_hsp_disable=0x1
- amfi_hsp_logging=0x1
- amfi_allow_bni_as_platform=0x1
- amfi_allow_non_platform=0x1
- amfi_prevent_old_entitled_platform_binaries=0x1
- amfi_allow_only_tc=0x1
- amfi_allow_only_tc_override=0x1
Within configurationSettingsInit()
- amfi_enforce_launch_constraints=0x1
- amfi_allow_3p_launch_constraints=0x1
- BATS_TESTPLAN_ID="Custom Team ID"
"""

View File

@@ -1,3 +1,7 @@
"""
bluetooth_data.py: Enum for Bluetooth Chipsets
"""
import enum import enum

View File

@@ -1,3 +1,7 @@
"""
cpu_data.py: CPU Generation Data
"""
import enum import enum

View File

@@ -1,4 +1,9 @@
# Comprised of https://github.com/sindresorhus/github-markdown-css and additions for OCLP """
css_data.py: CSS data for project's update window
Comprised of https://github.com/sindresorhus/github-markdown-css and additions for OCLP
"""
updater_css = """ updater_css = """

View File

@@ -1,6 +1,9 @@
# Example Hardware probe of multiple models """
# To be used when running validation tests example_data.py: Sample Hardware probes, for use in OpenCore Legacy Patcher validation
from resources import device_probe """
from ..detections import device_probe
class MacBook: class MacBook:

View File

@@ -1,5 +1,8 @@
# Lists all models and required patches """
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk model_array.py: Datasets for different models
"""
SupportedSMBIOS = [ SupportedSMBIOS = [
# MacBook # MacBook
"MacBook5,1", "MacBook5,1",

View File

@@ -1,6 +1,11 @@
from curses.ascii import isdigit """
os_data.py: OS Version Data
"""
import enum import enum
from curses.ascii import isdigit
class os_data(enum.IntEnum): class os_data(enum.IntEnum):
# OS Versions, Based off Major Kernel Version # OS Versions, Based off Major Kernel Version

View File

@@ -1,4 +1,8 @@
# Array of Device IDs for different devices """
pci_data.py: PCI Device IDs for different vendors and devices
"""
class nvidia_ids: class nvidia_ids:
# Courteous of envytools as well as MacRumors: # Courteous of envytools as well as MacRumors:
# https://envytools.readthedocs.io/en/latest/hw/pciid.html # https://envytools.readthedocs.io/en/latest/hw/pciid.html

View File

@@ -1,4 +1,10 @@
from data import os_data """
sip_data.py: System Integrity Protection Data
"""
from . import os_data
class system_integrity_protection: class system_integrity_protection:
csr_values = { csr_values = {
# Source: macOS 11.4 (XNU's csr.h) # Source: macOS 11.4 (XNU's csr.h)

View File

@@ -1,24 +1,35 @@
# Defines Model Data """
# Terms: smbios_data.py: SMBIOS Dictionary for model data
# AAPL: AppleInternal Model (ie. not released to public) """
# Board ID: The board ID is a unique identifier for the motherboard.
# Firmware Features: Hex bitmask denoting supported abilities of firmware. (ie. APFS, Large BaseSystem, etc.)
# Secure Boot Model: T2/Apple Silicon Model Identifier
# CPU Generation: Stock CPU supported by the board (generally lowest generation)
# Wireless Model: Driver used for wireless networking
# Bluetooth Model: Chipset model
# Screen Size: Size of the screen in inches (generally lowest size if multiple in same model)
# UGA Graphics: If model needs UGA to GOP conversion
# Ethernet Chipset: Vendor of the ethernet chipset (if multiple unique chipset within Vendor, chipset name is used)
# nForce Chipset: If model uses nForce chipset
# Switchable GPUs: If model uses a GMUX
# Stock GPUs: GPUs variations shipped
# Reference: """
# https://github.com/acidanthera/OpenCorePkg/blob/master/Library/OcMacInfoLib/AutoGenerated.c Terms:
AAPL: AppleInternal Model (ie. not released to public)
Board ID: The board ID is a unique identifier for the motherboard.
Firmware Features: Hex bitmask denoting supported abilities of firmware. (ie. APFS, Large BaseSystem, etc.)
Secure Boot Model: T2/Apple Silicon Model Identifier
CPU Generation: Stock CPU supported by the board (generally lowest generation)
Wireless Model: Driver used for wireless networking
Bluetooth Model: Chipset model
Screen Size: Size of the screen in inches (generally lowest size if multiple in same model)
UGA Graphics: If model needs UGA to GOP conversion
Ethernet Chipset: Vendor of the ethernet chipset (if multiple unique chipset within Vendor, chipset name is used)
nForce Chipset: If model uses nForce chipset
Switchable GPUs: If model uses a GMUX
Stock GPUs: GPUs variations shipped
Reference:
https://github.com/acidanthera/OpenCorePkg/blob/master/Library/OcMacInfoLib/AutoGenerated.c
"""
from ..detections import device_probe
from . import (
cpu_data,
os_data,
bluetooth_data
)
from resources import device_probe
from data import cpu_data, os_data, bluetooth_data
smbios_dictionary = { smbios_dictionary = {
"MacBook1,1": { "MacBook1,1": {

View File

@@ -1,9 +1,10 @@
# Dictionary defining patch sets used during Root Volume patching (sys_patch.py) """
# Copyright (C) 2022-2023, Mykola Grymalyuk sys_patch_dict.py: Dictionary defining patch sets used during Root Volume patching (sys_patch.py)
"""
import packaging.version import packaging.version
from data import os_data from . import os_data
class SystemPatchDictionary(): class SystemPatchDictionary():

View File

@@ -1,7 +1,12 @@
"""
usb_data.py: USB Device IDs for different vendors and devices
"""
class AppleIDs: class AppleIDs:
# All top case devices use Vendor ID 05ac # All top case devices use Vendor ID 05ac
Modern_AppleUSBTCKeyboard = [ Modern_AppleUSBTCKeyboard = [
0x223, 0x223,
0x224, 0x224,
0x225, 0x225,
0x230, 0x230,
@@ -53,7 +58,7 @@ class AppleIDs:
0x22a, 0x22a,
0x22b 0x22b
] ]
AppleUSBTrackpad = [ AppleUSBTrackpad = [
0x20e, 0x20e,
0x20f, 0x20f,
@@ -75,7 +80,7 @@ class AppleIDs:
] ]
AppleUSBMultiTouch = [ AppleUSBMultiTouch = [
0x223, 0x223,
0x224, 0x224,
0x225, 0x225,
0x230, 0x230,

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,11 @@
# Determine AppleMobileFileIntegrity's OS configuration """
# Copyright (C) 2022-2023, Mykola Grymalyuk amfi_detect.py: Determine AppleMobileFileIntegrity's OS configuration
"""
import enum import enum
from resources import utilities
from data import amfi_data from ..utilities import utilities
from ..datasets import amfi_data
class AmfiConfigDetectLevel(enum.IntEnum): class AmfiConfigDetectLevel(enum.IntEnum):

View File

@@ -1,18 +1,24 @@
# Hardware probing """
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk device_probe.py: Hardware probing
"""
import binascii
import enum import enum
import itertools import itertools
import subprocess import subprocess
import plistlib import plistlib
import hashlib import hashlib
from pathlib import Path from pathlib import Path
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type, Union from typing import Any, ClassVar, Optional, Type, Union
from resources import utilities, ioreg from ..utilities import utilities
from data import pci_data, usb_data from ..detections import ioreg
from ..datasets import (
pci_data,
usb_data
)
def class_code_to_bytes(class_code: int) -> bytes: def class_code_to_bytes(class_code: int) -> bytes:

View File

@@ -1,5 +1,6 @@
# PyObjc Handling for IOKit """
# Copyright (C) 2020-2022, Dhinak G ioreg.py: PyObjc Handling for IOKit
"""
from typing import NewType, Union from typing import NewType, Union
import objc import objc

View File

@@ -1,8 +1,10 @@
# Probe for OS data """
os_probe.py: OS Host information
"""
import platform import platform
import subprocess
import plistlib import plistlib
import subprocess
class OSProbe: class OSProbe:

View File

@@ -1,12 +1,20 @@
# Class for handling Bluetooth Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk bluetooth.py: Class for handling Bluetooth Patches, invocation from build.py
"""
import logging import logging
import binascii import binascii
from resources import constants, device_probe from . import support
from resources.build import support
from data import smbios_data, bluetooth_data from .. import constants
from ..detections import device_probe
from ..datasets import (
smbios_data,
bluetooth_data
)
class BuildBluetooth: class BuildBluetooth:

View File

@@ -1,19 +1,35 @@
# Class for generating OpenCore Configurations tailored for Macs """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk build.py: Class for generating OpenCore Configurations tailored for Macs
"""
import copy import copy
import pickle import pickle
import plistlib
import shutil import shutil
import zipfile
import logging import logging
import zipfile
import plistlib
from pathlib import Path from pathlib import Path
from datetime import date from datetime import date
from resources import constants, utilities from .. import constants
from resources.build import bluetooth, firmware, graphics_audio, support, storage, smbios, security, misc
from resources.build.networking import wired, wireless from ..utilities import utilities
from .networking import (
wired,
wireless
)
from . import (
bluetooth,
firmware,
graphics_audio,
support,
storage,
smbios,
security,
misc
)
def rmtree_handler(func, path, exc_info) -> None: def rmtree_handler(func, path, exc_info) -> None:

View File

@@ -1,5 +1,6 @@
# Class for handling CPU and Firmware Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk firmware.py: Class for handling CPU and Firmware Patches, invocation from build.py
"""
import shutil import shutil
import logging import logging
@@ -7,9 +8,18 @@ import binascii
from pathlib import Path from pathlib import Path
from resources import constants, generate_smbios, device_probe from . import support
from resources.build import support
from data import smbios_data, cpu_data, os_data from .. import constants
from ..utilities import generate_smbios
from ..detections import device_probe
from ..datasets import (
smbios_data,
cpu_data,
os_data
)
class BuildFirmware: class BuildFirmware:

View File

@@ -1,5 +1,6 @@
# Class for handling Graphics and Audio Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk graphics_audio.py: Class for handling Graphics and Audio Patches, invocation from build.py
"""
import shutil import shutil
import logging import logging
@@ -7,9 +8,20 @@ import binascii
from pathlib import Path from pathlib import Path
from resources import constants, device_probe, utilities from . import support
from resources.build import support
from data import smbios_data, model_array, os_data, cpu_data, video_bios_data from .. import constants
from ..utilities import utilities
from ..detections import device_probe
from ..datasets import (
smbios_data,
model_array,
os_data,
cpu_data,
video_bios_data
)
class BuildGraphicsAudio: class BuildGraphicsAudio:

View File

@@ -1,5 +1,6 @@
# Class for handling Misc Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk misc.py: Class for handling Misc Patches, invocation from build.py
"""
import shutil import shutil
import logging import logging
@@ -7,15 +8,24 @@ import binascii
from pathlib import Path from pathlib import Path
from resources import constants, device_probe, generate_smbios, utilities from . import support
from resources.build import support
from data import model_array, smbios_data, cpu_data from .. import constants
from ..utilities import generate_smbios
from ..detections import device_probe
from ..datasets import (
model_array,
smbios_data,
cpu_data
)
class BuildMiscellaneous: class BuildMiscellaneous:
""" """
Build Library for Miscellaneous Hardware and Software Support Build Library for Miscellaneous Hardware and Software Support
xw
Invoke from build.py Invoke from build.py
""" """

View File

@@ -1,9 +1,17 @@
# Class for handling Wired Networking Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk wired.py: Class for handling Wired Networking Patches, invocation from build.py
"""
from resources import constants, device_probe from .. import support
from resources.build import support
from data import smbios_data, cpu_data from ... import constants
from ...detections import device_probe
from ...datasets import (
smbios_data,
cpu_data
)
class BuildWiredNetworking: class BuildWiredNetworking:

View File

@@ -1,11 +1,17 @@
# Class for handling Wireless Networking Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk wireless.py: Class for handling Wireless Networking Patches, invocation from build.py
"""
import logging import logging
from resources import constants, device_probe, utilities from .. import support
from resources.build import support
from data import smbios_data from ... import constants
from ...datasets import smbios_data
from ...utilities import utilities
from ...detections import device_probe
class BuildWirelessNetworking: class BuildWirelessNetworking:

View File

@@ -1,11 +1,16 @@
# Class for handling macOS Security Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk security.py: Class for handling macOS Security Patches, invocation from build.py
"""
import logging import logging
import binascii import binascii
from resources import constants, utilities, device_probe from . import support
from resources.build import support
from .. import constants
from ..utilities import utilities
from ..detections import device_probe
class BuildSecurity: class BuildSecurity:

View File

@@ -1,5 +1,6 @@
# Class for handling SMBIOS Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk smbios.py: Class for handling SMBIOS Patches, invocation from build.py
"""
import ast import ast
import uuid import uuid
@@ -10,9 +11,19 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources import constants, utilities, generate_smbios from . import support
from resources.build import support
from data import smbios_data, cpu_data, model_array from .. import constants
from ..utilities import (
utilities,
generate_smbios
)
from ..datasets import (
smbios_data,
cpu_data,
model_array
)
class BuildSMBIOS: class BuildSMBIOS:

View File

@@ -1,11 +1,21 @@
# Class for handling Storage Controller Patches, invocation from build.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk storage.py: Class for handling Storage Controller Patches, invocation from build.py
"""
import logging import logging
from resources import constants, device_probe, utilities from . import support
from resources.build import support
from data import model_array, smbios_data, cpu_data from .. import constants
from ..utilities import utilities
from ..detections import device_probe
from ..datasets import (
model_array,
smbios_data,
cpu_data
)
class BuildStorage: class BuildStorage:

View File

@@ -1,5 +1,6 @@
# Utility class for build functions """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk support.py: Utility class for build functions
"""
import shutil import shutil
import typing import typing
@@ -10,7 +11,7 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources import constants, utilities from .. import constants
class BuildSupport: class BuildSupport:

View File

@@ -1,36 +1,39 @@
# Framework for mounting and patching macOS root volume """
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk sys_patch.py: Framework for mounting and patching macOS root volume
"""
# System based off of Apple's Kernel Debug Kit (KDK) """
# - https://developer.apple.com/download/all/ System based off of Apple's Kernel Debug Kit (KDK)
- https://developer.apple.com/download/all/
# The system relies on mounting the APFS volume as a live read/write volume The system relies on mounting the APFS volume as a live read/write volume
# We perform our required edits, then create a new snapshot for the system boot We perform our required edits, then create a new snapshot for the system boot
# The manual process is as follows: The manual process is as follows:
# 1. Find the Root Volume 1. Find the Root Volume
# 'diskutil info / | grep "Device Node:"' 'diskutil info / | grep "Device Node:"'
# 2. Convert Snapshot Device Node to Root Volume Device Node 2. Convert Snapshot Device Node to Root Volume Device Node
# /dev/disk3s1s1 -> /dev/disk3s1 (strip last 's1') /dev/disk3s1s1 -> /dev/disk3s1 (strip last 's1')
# 3. Mount the APFS volume as a read/write volume 3. Mount the APFS volume as a read/write volume
# 'sudo mount -o nobrowse -t apfs /dev/disk5s5 /System/Volumes/Update/mnt1' 'sudo mount -o nobrowse -t apfs /dev/disk5s5 /System/Volumes/Update/mnt1'
# 4. Perform edits to the system (ie. create new KernelCollection) 4. Perform edits to the system (ie. create new KernelCollection)
# 'sudo kmutil install --volume-root /System/Volumes/Update/mnt1/ --update-all' 'sudo kmutil install --volume-root /System/Volumes/Update/mnt1/ --update-all'
# 5. Create a new snapshot for the system boot 5. Create a new snapshot for the system boot
# 'sudo bless --folder /System/Volumes/Update/mnt1/System/Library/CoreServices --bootefi --create-snapshot' 'sudo bless --folder /System/Volumes/Update/mnt1/System/Library/CoreServices --bootefi --create-snapshot'
# Additionally Apple's APFS snapshot system supports system rollbacks: Additionally Apple's APFS snapshot system supports system rollbacks:
# 'sudo bless --mount /System/Volumes/Update/mnt1 --bootefi --last-sealed-snapshot' 'sudo bless --mount /System/Volumes/Update/mnt1 --bootefi --last-sealed-snapshot'
# Note: root volume rollbacks are unstable in Big Sur due to quickly discarding the original snapshot Note: root volume rollbacks are unstable in Big Sur due to quickly discarding the original snapshot
# - Generally within 2~ boots, the original snapshot is discarded - Generally within 2~ boots, the original snapshot is discarded
# - Monterey always preserves the original snapshot allowing for reliable rollbacks - Monterey always preserves the original snapshot allowing for reliable rollbacks
# Alternative to mounting via 'mount', Apple's update system uses 'mount_apfs' directly Alternative to mounting via 'mount', Apple's update system uses 'mount_apfs' directly
# '/sbin/mount_apfs -R /dev/disk5s5 /System/Volumes/Update/mnt1' '/sbin/mount_apfs -R /dev/disk5s5 /System/Volumes/Update/mnt1'
# With macOS Ventura, you will also need to install the KDK onto root if you plan to use kmutil With macOS Ventura, you will also need to install the KDK onto root if you plan to use kmutil
# This is because Apple removed on-disk binaries (ref: https://github.com/dortania/OpenCore-Legacy-Patcher/issues/998) This is because Apple removed on-disk binaries (ref: https://github.com/dortania/OpenCore-Legacy-Patcher/issues/998)
# 'sudo ditto /Library/Developer/KDKs/<KDK Version>/System /System/Volumes/Update/mnt1/System' 'sudo ditto /Library/Developer/KDKs/<KDK Version>/System /System/Volumes/Update/mnt1/System'
"""
import logging import logging
import plistlib import plistlib
@@ -40,10 +43,11 @@ import applescript
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
from resources import constants, utilities, kdk_handler from .. import constants
from resources.sys_patch import sys_patch_detect, sys_patch_auto, sys_patch_helpers, sys_patch_generate from ..utilities import utilities, kdk_handler
from ..sys_patch import sys_patch_detect, sys_patch_auto, sys_patch_helpers, sys_patch_generate
from data import os_data from ..datasets import os_data
class PatchSysVolume: class PatchSysVolume:

View File

@@ -1,23 +1,35 @@
# Copyright (C) 2022, Mykola Grymalyuk """
# Copyright (c) 2023 Jazzzny sys_patch_auto.py: Library of functions for launch services, including automatic patching
"""
import wx import wx
import wx.html2 import wx.html2
import requests
import markdown2 import hashlib
import logging import logging
import plistlib import plistlib
import requests
import markdown2
import subprocess import subprocess
import webbrowser import webbrowser
import hashlib
from pathlib import Path from pathlib import Path
from .. import constants
from resources import utilities, updates, global_settings, network_handler, constants from ..datasets import css_data
from resources.sys_patch import sys_patch_detect from ..sys_patch import sys_patch_detect
from resources.wx_gui import gui_entry, gui_support
from data import css_data from ..wx_gui import (
gui_entry,
gui_support
)
from ..utilities import (
utilities,
updates,
global_settings,
network_handler
)
class AutomaticSysPatch: class AutomaticSysPatch:

View File

@@ -1,18 +1,32 @@
# Hardware Detection Logic for Root Patching """
# Returns a dictionary of patches with boolean values sys_patch_detect.py: Hardware Detection Logic for Root Patching
# Used when supplying data to sys_patch.py """
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
import logging import logging
import plistlib import plistlib
import py_sip_xnu
import packaging.version
from pathlib import Path from pathlib import Path
import packaging.version from .. import constants
import py_sip_xnu
from data import cpu_data, model_array, os_data, sip_data, smbios_data from ..detections import (
from resources import (amfi_detect, constants, device_probe, kdk_handler, amfi_detect,
network_handler, utilities) device_probe
)
from ..utilities import (
kdk_handler,
network_handler,
utilities
)
from ..datasets import (
cpu_data,
model_array,
os_data,
sip_data,
smbios_data
)
class DetectRootPatch: class DetectRootPatch:

View File

@@ -1,8 +1,15 @@
# Generate patch set for use in sys_patch.py """
sys_patch_generate.py: Class for generating patch sets for the current host
"""
import logging import logging
from resources import constants, utilities, device_probe from .. import constants
from data import sys_patch_dict
from ..datasets import sys_patch_dict
from ..utilities import utilities
from ..detections import device_probe
class GenerateRootPatchSets: class GenerateRootPatchSets:
""" """

View File

@@ -1,17 +1,25 @@
# Additional support functions for sys_patch.py """
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk sys_patch_helpers.py: Additional support functions for sys_patch.py
"""
import plistlib
import os import os
import logging import logging
import plistlib
import subprocess import subprocess
from typing import Union from typing import Union
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
from data import os_data from .. import constants
from resources import bplist, constants, generate_smbios, utilities
from ..datasets import os_data
from ..utilities import (
bplist,
generate_smbios,
utilities
)
class SysPatchHelpers: class SysPatchHelpers:

View File

@@ -1,9 +1,19 @@
"""
analytics_handler.py: Analytics and Crash Reporting Handler
"""
import json
import datetime import datetime
import plistlib import plistlib
from pathlib import Path
import json
from resources import network_handler, constants, global_settings from pathlib import Path
from .. import constants
from ..utilities import (
network_handler,
global_settings
)
DATE_FORMAT: str = "%Y-%m-%d %H-%M-%S" DATE_FORMAT: str = "%Y-%m-%d %H-%M-%S"

View File

@@ -1,3 +1,7 @@
"""
arguments.py: CLI argument handling
"""
import sys import sys
import time import time
import logging import logging
@@ -7,11 +11,25 @@ import subprocess
from pathlib import Path from pathlib import Path
from data import model_array, os_data from .. import constants
from resources.build import build
from resources.sys_patch import sys_patch, sys_patch_auto from ..wx_gui import gui_entry
from resources import defaults, utilities, validation, constants from ..efi_builder import build
from resources.wx_gui import gui_entry
from ..datasets import (
model_array,
os_data
)
from ..sys_patch import (
sys_patch,
sys_patch_auto
)
from ..utilities import (
utilities,
defaults,
validation
)
# Generic building args # Generic building args

View File

@@ -1,7 +1,11 @@
# Parse Commit Info from binary's info.plist """
commit_info.py: Parse Commit Info from binary's info.plist
"""
import plistlib
from pathlib import Path from pathlib import Path
import plistlib
class ParseCommitInfo: class ParseCommitInfo:

View File

@@ -1,14 +1,19 @@
# Generate Default Data """
defaults.py: Generate default data for host/target
"""
import subprocess import subprocess
from resources import ( from .. import constants
from ..detections import device_probe
from ..utilities import (
utilities, utilities,
device_probe,
generate_smbios, generate_smbios,
global_settings, global_settings
constants
) )
from data import ( from ..datasets import (
smbios_data, smbios_data,
cpu_data, cpu_data,
os_data os_data
@@ -25,16 +30,16 @@ class GenerateDefaults:
self.host_is_target: bool = host_is_target self.host_is_target: bool = host_is_target
# Reset Variables # Reset Variables
self.constants.sip_status: bool = True self.constants.sip_status = True
self.constants.secure_status: bool = False self.constants.secure_status = False
self.constants.disable_cs_lv: bool = False self.constants.disable_cs_lv = False
self.constants.disable_amfi: bool = False self.constants.disable_amfi = False
self.constants.fu_status: bool = True self.constants.fu_status = True
self.constants.fu_arguments: str = None self.constants.fu_arguments = None
self.constants.custom_serial_number: str = "" self.constants.custom_serial_number = ""
self.constants.custom_board_serial_number: str = "" self.constants.custom_board_serial_number = ""
if self.host_is_target is True: if self.host_is_target is True:
for gpu in self.constants.computer.gpus: for gpu in self.constants.computer.gpus:

View File

@@ -1,8 +1,18 @@
from data import smbios_data, os_data, cpu_data """
from resources import utilities generate_smbios.py: SMBIOS generation for OpenCore Legacy Patcher
"""
import logging import logging
from ..utilities import utilities
from ..datasets import (
smbios_data,
os_data,
cpu_data
)
def set_smbios_model_spoof(model): def set_smbios_model_spoof(model):
try: try:
smbios_data.smbios_dictionary[model]["Screen Size"] smbios_data.smbios_dictionary[model]["Screen Size"]

View File

@@ -1,13 +1,18 @@
# Alternative to Apple's 'defaults' tool """
# Store data in '/Users/Shared' global_settings.py: Library for querying and writing global enviroment settings
# This is to ensure compatibility when running without a user
# ie. during automated patching Alternative to Apple's 'defaults' tool
Store data in '/Users/Shared'
This is to ensure compatibility when running without a user
ie. during automated patching
"""
import os
import logging
import plistlib
import subprocess
from pathlib import Path from pathlib import Path
import plistlib
import logging
import os
import subprocess
class GlobalEnviromentSettings: class GlobalEnviromentSettings:

View File

@@ -1,6 +1,6 @@
# Installation of OpenCore files to ESP """
# Usage solely for TUI install.py: Installation of OpenCore files to ESP
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk """
import logging import logging
import plistlib import plistlib
@@ -9,8 +9,10 @@ import applescript
from pathlib import Path from pathlib import Path
from resources import utilities, constants from .. import constants
from data import os_data
from ..datasets import os_data
from ..utilities import utilities
class tui_disk_installation: class tui_disk_installation:

View File

@@ -1,7 +1,9 @@
# Validate the integrity of Apple downloaded files via .chunklist and .integrityDataV1 files """
# Based off of chunklist.py: integrity_verification.py: Validate the integrity of Apple downloaded files via .chunklist and .integrityDataV1 files
# - https://gist.github.com/dhinakg/cbe30edf31ddc153fd0b0c0570c9b041
# Copyright (C) 2021-2023, Dhinak G, Mykola Grymalyuk Based off of chunklist.py:
- https://gist.github.com/dhinakg/cbe30edf31ddc153fd0b0c0570c9b041
"""
import enum import enum
import hashlib import hashlib

View File

@@ -1,22 +1,26 @@
# Module for parsing and determining best Kernel Debug Kit for host OS """
# Copyright (C) 2022-2023, Dhinak G, Mykola Grymalyuk kdk_handler.py: Module for parsing and determining best Kernel Debug Kit for host OS
"""
import datetime
from pathlib import Path
from typing import cast
import tempfile
import plistlib
import packaging.version
import requests
import subprocess
import os import os
import logging import logging
import plistlib
import requests
import tempfile
import subprocess
import packaging.version
from resources import utilities, network_handler, constants from typing import cast
from data import os_data from pathlib import Path
from .. import constants
from ..datasets import os_data
from ..utilities import (
utilities,
network_handler
)
KDK_INSTALL_PATH: str = "/Library/Developer/KDKs" KDK_INSTALL_PATH: str = "/Library/Developer/KDKs"
KDK_INFO_PLIST: str = "KDKInfo.plist" KDK_INFO_PLIST: str = "KDKInfo.plist"
@@ -89,7 +93,7 @@ class KernelDebugKitObject:
self._get_latest_kdk() self._get_latest_kdk()
def _get_remote_kdks(self) -> list or None: def _get_remote_kdks(self) -> list:
""" """
Fetches a list of available KDKs from the KdkSupportPkg API Fetches a list of available KDKs from the KdkSupportPkg API
Additionally caches the list for future use, avoiding extra API calls Additionally caches the list for future use, avoiding extra API calls
@@ -247,7 +251,7 @@ class KernelDebugKitObject:
self.success = True self.success = True
def retrieve_download(self, override_path: str = "") -> network_handler.DownloadObject or None: def retrieve_download(self, override_path: str = "") -> network_handler.DownloadObject:
""" """
Returns a DownloadObject for the KDK Returns a DownloadObject for the KDK
@@ -381,7 +385,7 @@ class KernelDebugKitObject:
return True return True
def _local_kdk_installed(self, match: str = None, check_version: bool = False) -> str or None: def _local_kdk_installed(self, match: str = None, check_version: bool = False) -> str:
""" """
Checks if KDK matching build is installed Checks if KDK matching build is installed
If so, validates it has not been corrupted If so, validates it has not been corrupted

View File

@@ -1,3 +1,7 @@
"""
logging_handler.py: Initialize logging framework for program
"""
import os import os
import sys import sys
import pprint import pprint
@@ -10,7 +14,12 @@ import applescript
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
from resources import constants, analytics_handler, global_settings from .. import constants
from ..utilities import (
analytics_handler,
global_settings
)
class InitializeLoggingSupport: class InitializeLoggingSupport:

View File

@@ -1,15 +1,22 @@
# Handler for macOS installers, both local and remote """
macos_installer_handler.py: Handler for macOS installers, both local and remote
"""
from pathlib import Path
import plistlib
import subprocess
import tempfile
import enum import enum
import logging import logging
import plistlib
import tempfile
import subprocess
import applescript import applescript
from data import os_data from pathlib import Path
from resources import network_handler, utilities
from ..datasets import os_data
from ..utilities import (
network_handler,
utilities
)
APPLICATION_SEARCH_PATH: str = "/Applications" APPLICATION_SEARCH_PATH: str = "/Applications"

View File

@@ -1,7 +1,9 @@
# Library dedicated to Network Handling tasks including downloading files """
# Primarily based around the DownloadObject class, which provides a simple network_handler.py: Library dedicated to Network Handling tasks including downloading files
# object for libraries to query download progress and status
# Copyright (C) 2023, Mykola Grymalyuk Primarily based around the DownloadObject class, which provides a simple
object for libraries to query download progress and status
"""
import time import time
import requests import requests
@@ -10,9 +12,11 @@ import logging
import enum import enum
import hashlib import hashlib
import atexit import atexit
from typing import Union
from pathlib import Path from pathlib import Path
from resources import utilities from ..utilities import utilities
SESSION = requests.Session() SESSION = requests.Session()
@@ -218,7 +222,7 @@ class DownloadObject:
self._download(display_progress) self._download(display_progress)
def download_simple(self, verify_checksum: bool = False) -> str or bool: def download_simple(self, verify_checksum: bool = False) -> Union[str, bool]:
""" """
Alternative to download(), mimics utilities.py's old download_file() function Alternative to download(), mimics utilities.py's old download_file() function

View File

@@ -1,15 +1,19 @@
# Reroute binaries to tmp directory, and mount a disk image of the payloads """
# Implements a shadowfile to avoid direct writes to the dmg reroute_payloads.py: Reroute binaries to tmp directory, and mount a disk image of the payloads
# Copyright (C) 2022, Mykola Grymalyuk Implements a shadowfile to avoid direct writes to the dmg
"""
import plistlib
from pathlib import Path
import subprocess
import tempfile
import atexit import atexit
import plistlib
import tempfile
import subprocess
import logging import logging
from resources import constants from pathlib import Path
from .. import constants
class RoutePayloadDiskImage: class RoutePayloadDiskImage:

View File

@@ -1,13 +1,19 @@
# Copyright (C) 2022, Mykola Grymalyuk """
# Check whether new updates are available for OpenCore Legacy Patcher binary updates.py: Check for OpenCore Legacy Patcher binary updates
# Call check_binary_updates() to determine if any updates are available
# Returns dict with Link and Version of the latest binary update if available
import logging
from typing import Optional, Union
Call check_binary_updates() to determine if any updates are available
Returns dict with Link and Version of the latest binary update if available
"""
import logging
from typing import Optional, Union
from packaging import version from packaging import version
from resources import constants, network_handler from .. import constants
from ..utilities import network_handler
REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest" REPO_LATEST_RELEASE_URL: str = "https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest"

View File

@@ -1,20 +1,29 @@
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk """
utilities.py: Utility functions for OpenCore Legacy Patcher
"""
import argparse
import atexit
import binascii
import logging
import math
import os import os
import plistlib
import re import re
import math
import atexit
import shutil import shutil
import logging
import argparse
import binascii
import plistlib
import subprocess import subprocess
from pathlib import Path
import py_sip_xnu import py_sip_xnu
from data import os_data, sip_data from pathlib import Path
from resources import constants, ioreg
from .. import constants
from ..detections import ioreg
from ..datasets import (
os_data,
sip_data
)
def hexswap(input_hex: str): def hexswap(input_hex: str):
@@ -553,7 +562,7 @@ def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
return subprocess.run(["/usr/bin/sudo"] + [args[0][0]] + args[0][1:], **kwargs) return subprocess.run(["/usr/bin/sudo"] + [args[0][0]] + args[0][1:], **kwargs)
def fetch_staged_update(variant: str = "Update") -> (str, str): def fetch_staged_update(variant: str = "Update") -> tuple[str, str]:
""" """
Check for staged macOS update Check for staged macOS update
Supported variants: Supported variants:

View File

@@ -1,11 +1,24 @@
"""
validation.py: Validation class for the patcher
"""
import logging import logging
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from resources.sys_patch import sys_patch_helpers from .. import constants
from resources.build import build
from resources import constants, network_handler from ..sys_patch import sys_patch_helpers
from data import example_data, model_array, sys_patch_dict, os_data from ..utilities import network_handler
from ..efi_builder import build
from ..datasets import (
example_data,
model_array,
sys_patch_dict,
os_data
)
class PatcherValidation: class PatcherValidation:

View File

@@ -1,12 +1,14 @@
# About frame, just to sat """
gui_about.py: About frame
"""
import wx import wx
import wx.adv import wx.adv
import logging import logging
from resources.wx_gui import gui_support from .. import constants
from resources import constants from ..wx_gui import gui_support
class AboutFrame(wx.Frame): class AboutFrame(wx.Frame):

View File

@@ -1,12 +1,17 @@
# Generate UI for Building OpenCore """
gui_build.py: Generate UI for Building OpenCore
"""
import wx import wx
import logging import logging
import threading import threading
import traceback import traceback
from resources import constants from .. import constants
from resources.build import build
from resources.wx_gui import ( from ..efi_builder import build
from ..wx_gui import (
gui_main_menu, gui_main_menu,
gui_install_oc, gui_install_oc,
gui_support gui_support

View File

@@ -1,5 +1,5 @@
""" """
UI to display to users before a macOS update is applied gui_cache_os_update.py: UI to display to users before a macOS update is applied
Primarily for caching updates required for incoming OS (ex. KDKs) Primarily for caching updates required for incoming OS (ex. KDKs)
""" """
@@ -11,8 +11,9 @@ import threading
from pathlib import Path from pathlib import Path
from resources import constants, kdk_handler, utilities from .. import constants
from resources.wx_gui import gui_support, gui_download from ..utilities import kdk_handler, utilities
from ..wx_gui import gui_support, gui_download
class OSUpdateFrame(wx.Frame): class OSUpdateFrame(wx.Frame):

View File

@@ -1,16 +1,19 @@
# Generate UI for downloading files """
gui_download.py: Generate UI for downloading files
"""
import wx import wx
import logging import logging
from resources import ( from .. import constants
constants,
from ..wx_gui import gui_support
from ..utilities import (
network_handler, network_handler,
utilities utilities
) )
from resources.wx_gui import gui_support
class DownloadFrame(wx.Frame): class DownloadFrame(wx.Frame):
""" """
@@ -67,7 +70,7 @@ class DownloadFrame(wx.Frame):
self.download_obj.download() self.download_obj.download()
while self.download_obj.is_active(): while self.download_obj.is_active():
percentage: int = round(self.download_obj.get_percent()) percentage: int = round(self.download_obj.get_percent())
if percentage == 0: if percentage == 0:
percentage = 1 percentage = 1

View File

@@ -1,11 +1,17 @@
# Entry point for the wxPython GUI """
gui_entry.py: Entry point for the wxPython GUI
"""
import wx import wx
import sys import sys
import atexit import atexit
import logging import logging
from resources import constants from .. import constants
from resources.wx_gui import (
from ..sys_patch import sys_patch_detect
from ..wx_gui import (
gui_cache_os_update, gui_cache_os_update,
gui_main_menu, gui_main_menu,
gui_build, gui_build,
@@ -13,7 +19,6 @@ from resources.wx_gui import (
gui_sys_patch_start, gui_sys_patch_start,
gui_update, gui_update,
) )
from resources.sys_patch import sys_patch_detect
class SupportedEntryPoints: class SupportedEntryPoints:

View File

@@ -1,11 +1,14 @@
# Generate UI for help menu """
gui_help.py: GUI Help Menu
"""
import wx import wx
import logging import logging
import webbrowser import webbrowser
from resources import constants from .. import constants
from resources.wx_gui import gui_support from ..wx_gui import gui_support
class HelpFrame(wx.Frame): class HelpFrame(wx.Frame):

View File

@@ -1,11 +1,22 @@
"""
gui_install_oc.py: Frame for installing OpenCore to disk
"""
import wx import wx
import threading
import logging import logging
import threading
import traceback import traceback
from resources.wx_gui import gui_main_menu, gui_support, gui_sys_patch_display from .. import constants
from resources import constants, install
from data import os_data from ..datasets import os_data
from ..utilities import install
from ..wx_gui import (
gui_main_menu,
gui_support,
gui_sys_patch_display
)
class InstallOCFrame(wx.Frame): class InstallOCFrame(wx.Frame):

View File

@@ -1,25 +1,34 @@
"""
gui_macos_installer_download.py: macOS Installer Download Frame
"""
import wx import wx
import locale
import logging import logging
import threading import threading
import webbrowser import webbrowser
import locale
from pathlib import Path from pathlib import Path
from resources.wx_gui import ( from .. import constants
from ..datasets import (
os_data,
smbios_data,
cpu_data
)
from ..wx_gui import (
gui_main_menu, gui_main_menu,
gui_support, gui_support,
gui_download, gui_download,
gui_macos_installer_flash gui_macos_installer_flash
) )
from resources import ( from ..utilities import (
constants,
macos_installer_handler, macos_installer_handler,
utilities, utilities,
network_handler, network_handler,
integrity_verification integrity_verification
) )
from data import os_data, smbios_data, cpu_data
class macOSInstallerDownloadFrame(wx.Frame): class macOSInstallerDownloadFrame(wx.Frame):
@@ -51,7 +60,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
Convert icon to bitmap Convert icon to bitmap
""" """
return wx.Bitmap(wx.Bitmap(icon, wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(size[0], size[1], wx.IMAGE_QUALITY_HIGH)) return wx.Bitmap(wx.Bitmap(icon, wx.BITMAP_TYPE_ICON).ConvertToImage().Rescale(size[0], size[1], wx.IMAGE_QUALITY_HIGH))
def _macos_version_to_icon(self, version: int) -> int: def _macos_version_to_icon(self, version: int) -> int:
""" """
Convert macOS version to icon Convert macOS version to icon
@@ -143,20 +152,20 @@ class macOSInstallerDownloadFrame(wx.Frame):
""" """
Display available installers in frame Display available installers in frame
""" """
bundles = [wx.BitmapBundle.FromBitmaps(icon) for icon in self.icons] bundles = [wx.BitmapBundle.FromBitmaps(icon) for icon in self.icons]
self.frame_modal.Destroy() self.frame_modal.Destroy()
self.frame_modal = wx.Dialog(self, title="Select macOS Installer", size=(460, 500)) self.frame_modal = wx.Dialog(self, title="Select macOS Installer", size=(460, 500))
# Title: Select macOS Installer # Title: Select macOS Installer
title_label = wx.StaticText(self.frame_modal, label="Select macOS Installer", pos=(-1,-1)) title_label = wx.StaticText(self.frame_modal, label="Select macOS Installer", pos=(-1,-1))
title_label.SetFont(gui_support.font_factory(19, wx.FONTWEIGHT_BOLD)) title_label.SetFont(gui_support.font_factory(19, wx.FONTWEIGHT_BOLD))
# macOS Installers list # macOS Installers list
id = wx.NewIdRef() id = wx.NewIdRef()
self.list = wx.ListCtrl(self.frame_modal, id, style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER | wx.BORDER_SUNKEN) self.list = wx.ListCtrl(self.frame_modal, id, style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_NO_HEADER | wx.BORDER_SUNKEN)
self.list.SetSmallImages(bundles) self.list.SetSmallImages(bundles)
@@ -226,7 +235,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
checkboxsizer = wx.BoxSizer(wx.HORIZONTAL) checkboxsizer = wx.BoxSizer(wx.HORIZONTAL)
checkboxsizer.Add(self.showolderversions_checkbox, 0, wx.ALIGN_CENTRE | wx.RIGHT, 5) checkboxsizer.Add(self.showolderversions_checkbox, 0, wx.ALIGN_CENTRE | wx.RIGHT, 5)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
sizer.AddSpacer(10) sizer.AddSpacer(10)
sizer.Add(title_label, 0, wx.ALIGN_CENTRE | wx.ALL, 0) sizer.Add(title_label, 0, wx.ALIGN_CENTRE | wx.ALL, 0)
@@ -253,15 +262,15 @@ class macOSInstallerDownloadFrame(wx.Frame):
wx.MessageDialog(self.frame_modal, "Download link copied to clipboard", "", wx.OK | wx.ICON_INFORMATION).ShowModal() wx.MessageDialog(self.frame_modal, "Download link copied to clipboard", "", wx.OK | wx.ICON_INFORMATION).ShowModal()
def on_select_list(self, event): def on_select_list(self, event):
if self.list.GetSelectedItemCount() > 0: if self.list.GetSelectedItemCount() > 0:
self.select_button.Enable() self.select_button.Enable()
self.copy_button.Enable() self.copy_button.Enable()
else: else:
self.select_button.Disable() self.select_button.Disable()
self.copy_button.Disable() self.copy_button.Disable()
def on_download_installer(self, installers: dict) -> None: def on_download_installer(self, installers: dict) -> None:
""" """
Download macOS installer Download macOS installer
@@ -322,7 +331,7 @@ class macOSInstallerDownloadFrame(wx.Frame):
self._validate_installer(list(installers.values())[selected_item]['integrity']) self._validate_installer(list(installers.values())[selected_item]['integrity'])
def _validate_installer(self, chunklist_link: str) -> None: def _validate_installer(self, chunklist_link: str) -> None:
""" """
Validate macOS installer Validate macOS installer

View File

@@ -1,3 +1,7 @@
"""
gui_macos_installer_flash.py: macOS Installer Flash Frame
"""
import wx import wx
import time import time
import logging import logging
@@ -8,15 +12,21 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources.wx_gui import gui_main_menu, gui_build, gui_support from .. import constants
from resources import (
constants, from ..datasets import os_data
from ..wx_gui import (
gui_main_menu,
gui_build,
gui_support
)
from ..utilities import (
macos_installer_handler, macos_installer_handler,
utilities, utilities,
network_handler, network_handler,
kdk_handler, kdk_handler,
) )
from data import os_data
class macOSInstallerFlashFrame(wx.Frame): class macOSInstallerFlashFrame(wx.Frame):

View File

@@ -1,19 +1,31 @@
# Generate GUI for main menu """
# Portions of this file Copyright (c) 2023 Jazzzny gui_main_menu.py: Generate GUI for main menu
"""
import wx import wx
import wx.html2 import wx.html2
import markdown2
import requests
import sys import sys
import logging import logging
import requests
import markdown2
import threading import threading
import webbrowser import webbrowser
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from resources.wx_gui import ( from .. import constants
from ..utilities import (
global_settings,
updates
)
from ..datasets import (
os_data,
css_data
)
from ..wx_gui import (
gui_build, gui_build,
gui_macos_installer_download, gui_macos_installer_download,
gui_support, gui_support,
@@ -22,12 +34,6 @@ from resources.wx_gui import (
gui_sys_patch_display, gui_sys_patch_display,
gui_update, gui_update,
) )
from resources import (
constants,
global_settings,
updates
)
from data import os_data, css_data
class MainFrame(wx.Frame): class MainFrame(wx.Frame):

View File

@@ -1,26 +1,32 @@
"""
gui_settings.py: Settings Frame for the GUI
"""
import os
import wx import wx
import wx.adv import wx.adv
import pprint import pprint
import logging import logging
import py_sip_xnu import py_sip_xnu
import subprocess import subprocess
import os
from pathlib import Path from pathlib import Path
from resources.sys_patch.sys_patch import PatchSysVolume
from resources.wx_gui import ( from .. import constants
from ..sys_patch import sys_patch
from ..wx_gui import (
gui_support, gui_support,
gui_update gui_update
) )
from resources import ( from ..utilities import (
constants,
global_settings, global_settings,
defaults, defaults,
generate_smbios, generate_smbios,
network_handler network_handler
) )
from data import ( from ..datasets import (
model_array, model_array,
sip_data, sip_data,
smbios_data, smbios_data,
@@ -1322,7 +1328,7 @@ Hardware Information:
wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal() wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
else: else:
#Don't need to pass model as we're bypassing all logic #Don't need to pass model as we're bypassing all logic
if PatchSysVolume("",self.constants)._mount_root_vol() == True: if sys_patch.PatchSysVolume("",self.constants)._mount_root_vol() == True:
wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before saving the Root Volume", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before saving the Root Volume", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal()
else: else:
wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
@@ -1332,7 +1338,7 @@ Hardware Information:
wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal() wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal()
else: else:
#Don't need to pass model as we're bypassing all logic #Don't need to pass model as we're bypassing all logic
if PatchSysVolume("",self.constants)._rebuild_root_volume() == True: if sys_patch.PatchSysVolume("",self.constants)._rebuild_root_volume() == True:
wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal()
else: else:
wx.MessageDialog(self.parent, "Root Volume update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() wx.MessageDialog(self.parent, "Root Volume update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal()

View File

@@ -1,21 +1,30 @@
import datetime """
import logging gui_support.py: Utilities for interacting with wxPython GUI
import os """
import plistlib
import random
import subprocess
import sys
import threading
import time
from pathlib import Path
import os
import wx
import sys
import time
import logging
import plistlib
import threading
import subprocess
import applescript import applescript
import packaging.version import packaging.version
import wx
from data import model_array, os_data, smbios_data from pathlib import Path
from resources import constants, device_probe
from resources.wx_gui import gui_about from .. import constants
from ..wx_gui import gui_about
from ..detections import device_probe
from ..datasets import (
model_array,
os_data,
smbios_data
)
def get_font_face(): def get_font_face():

View File

@@ -1,19 +1,20 @@
"""
gui_sys_patch_display.py: Display root patching menu
"""
import wx
import os import os
import wx
import logging import logging
import plistlib import plistlib
import threading import threading
from pathlib import Path from pathlib import Path
from resources import ( from .. import constants
constants,
) from ..sys_patch import sys_patch_detect
from resources.sys_patch import (
sys_patch_detect from ..wx_gui import (
)
from resources.wx_gui import (
gui_main_menu, gui_main_menu,
gui_support, gui_support,
gui_sys_patch_start, gui_sys_patch_start,

View File

@@ -1,3 +1,6 @@
"""
gui_sys_patch_start.py: Root Patching Frame
"""
import wx import wx
import sys import sys
@@ -10,20 +13,21 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources import ( from .. import constants
constants,
kdk_handler, from ..datasets import os_data
) from ..utilities import kdk_handler
from resources.sys_patch import (
from ..sys_patch import (
sys_patch, sys_patch,
sys_patch_detect sys_patch_detect
) )
from resources.wx_gui import ( from ..wx_gui import (
gui_main_menu, gui_main_menu,
gui_support, gui_support,
gui_download, gui_download,
) )
from data import os_data
class SysPatchStartFrame(wx.Frame): class SysPatchStartFrame(wx.Frame):

View File

@@ -1,4 +1,7 @@
# Generate UI for updating the patcher """
gui_update.py: Generate UI for updating the patcher
"""
import wx import wx
import sys import sys
import time import time
@@ -9,9 +12,13 @@ import subprocess
from pathlib import Path from pathlib import Path
from resources.wx_gui import gui_download, gui_support from .. import constants
from resources import (
constants, from ..wx_gui import (
gui_download,
gui_support
)
from ..utilities import (
network_handler, network_handler,
updates updates
) )

Binary file not shown.

View File

@@ -1,5 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
chmod +x OpenCore-Patcher
open OpenCore-Patcher