Skip to content

Commit

Permalink
Restructure into package format
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Apr 1, 2024
1 parent d02d89b commit 463bed4
Show file tree
Hide file tree
Showing 81 changed files with 881 additions and 464 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-app-wxpython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# p12-password: ${{ secrets.MAC_NOTARIZATION_PASSWORD }}

- 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
run: cd dist; ditto -c -k --sequesterRsrc --keepParent OpenCore-Patcher.app ../OpenCore-Patcher-wxPython.app.zip
Expand All @@ -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 }}"

- 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
run: mv ./OpenCore-Patcher-wxPython.app.zip ./OpenCore-Patcher-GUI.app.zip
Expand Down
14 changes: 5 additions & 9 deletions Build-Binary.command
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

# Generate stand alone application for OpenCore-Patcher
# Copyright (C) 2022-2023 - Mykola Grymalyuk
"""
Build-Binary.command: Generate stand alone application for OpenCore-Patcher
"""

import os
import sys
Expand All @@ -12,7 +12,7 @@ import subprocess

from pathlib import Path

from resources import constants
from opencore_legacy_patcher import constants


class CreateBinary:
Expand Down Expand Up @@ -229,18 +229,14 @@ class CreateBinary:
"Config",
"Drivers",
"Icon",
"InstallPackage",
"Kexts",
"OpenCore",
"Tools",
"Launch Services",
]

whitelist_files = [
"entitlements.plist",
"launcher.sh",
"OC-Patcher-TUI.icns",
"OC-Patcher.icns",

]


Expand Down
9 changes: 6 additions & 3 deletions OpenCore-Patcher-GUI.command
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/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__':
main.OpenCoreLegacyPatcher()
main()
4 changes: 2 additions & 2 deletions OpenCore-Patcher-GUI.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from PyInstaller.building.build_main import Analysis

sys.path.append(os.path.abspath(os.getcwd()))

from resources import constants
from opencore_legacy_patcher import constants

block_cipher = None

Expand Down Expand Up @@ -70,7 +70,7 @@ coll = COLLECT(exe,

app = BUNDLE(coll,
name='OpenCore-Patcher.app',
icon="payloads/OC-Patcher.icns",
icon="payloads/Icon/AppIcons/OC-Patcher.icns",
bundle_identifier="com.dortania.opencore-legacy-patcher",
info_plist={
"CFBundleName": "OpenCore Legacy Patcher",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
57 changes: 0 additions & 57 deletions data/amfi_data.py

This file was deleted.

1 change: 1 addition & 0 deletions opencore_legacy_patcher/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .application_entry import main
29 changes: 21 additions & 8 deletions resources/main.py → opencore_legacy_patcher/application_entry.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
"""
application_entry.py: Project entry point
"""

import os
import sys
import time
import logging
import threading

from pathlib import Path

from resources.wx_gui import gui_entry
from resources import (
constants,
utilities,
from . import constants

from .wx_gui import gui_entry

from .detections import (
device_probe,
os_probe,
os_probe
)
from .utilities import (
utilities,
defaults,
arguments,
reroute_payloads,
commit_info,
logging_handler,
analytics_handler,
analytics_handler
)


Expand All @@ -43,7 +50,7 @@ def _generate_base_data(self) -> None:
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)
os.setpgrp()
Expand Down Expand Up @@ -111,3 +118,9 @@ def _generate_base_data(self) -> None:
time.sleep(0.1)

arguments.arguments(self.constants)

def main():
"""
Main entry point
"""
OpenCoreLegacyPatcher()
16 changes: 8 additions & 8 deletions resources/constants.py → opencore_legacy_patcher/constants.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# pylint: disable=multiple-statements
# Defines versioning, file paths and other settings for the patcher
# Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
"""
constants.py: Defines versioning, file paths and other settings for the patcher
"""

from pathlib import Path
from typing import Optional
from pathlib import Path
from typing import Optional
from packaging import version

from resources import device_probe
from data import os_data
from .datasets import os_data
from .detections import device_probe


class Constants:
Expand Down Expand Up @@ -739,7 +739,7 @@ def icns_resource_path(self):

@property
def app_icon_path(self):
return self.payload_path / Path("OC-Patcher.icns")
return self.payload_path / Path("Icon/AppIcons/OC-Patcher.icns")

@property
def icon_path_external(self):
Expand Down
63 changes: 63 additions & 0 deletions opencore_legacy_patcher/datasets/amfi_data.py
Original file line number Diff line number Diff line change
@@ -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"
"""
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
bluetooth_data.py: Enum for Bluetooth Chipsets
"""

import enum


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
cpu_data.py: CPU Generation Data
"""

import enum


Expand Down
Original file line number Diff line number Diff line change
@@ -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 = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Example Hardware probe of multiple models
# To be used when running validation tests
from resources import device_probe
"""
example_data.py: Sample Hardware probes, for use in OpenCore Legacy Patcher validation
"""

from ..detections import device_probe


class MacBook:

Expand Down
Original file line number Diff line number Diff line change
@@ -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 = [
# MacBook
"MacBook5,1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from curses.ascii import isdigit
"""
os_data.py: OS Version Data
"""

import enum

from curses.ascii import isdigit


class os_data(enum.IntEnum):
# OS Versions, Based off Major Kernel Version
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
# Courteous of envytools as well as MacRumors:
# https://envytools.readthedocs.io/en/latest/hw/pciid.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from data import os_data
"""
sip_data.py: System Integrity Protection Data
"""

from . import os_data


class system_integrity_protection:
csr_values = {
# Source: macOS 11.4 (XNU's csr.h)
Expand Down
Loading

0 comments on commit 463bed4

Please sign in to comment.