Create Auto Root Patching system by gandolf243 · Pull Request #570 · oclp-t2/OpenCore-Legacy-Patcher-T2 · GitHub
Skip to content

Create Auto Root Patching system - #570

Draft
gandolf243 wants to merge 22 commits into
mainfrom
feature/autorootpatch
Draft

gandolf243 wants to merge 22 commits into
mainfrom
feature/autorootpatch

Conversation

@gandolf243

Copy link
Copy Markdown
Collaborator

App checks for updates
   ↓ 
finds autodownload.json
   ↓ 
downloads autodownload.json
   ↓
gets the name of the package to download from `autodownload.json` and appends it to the URL
   ↓
downloads the pkg
   ↓
checks which installer it has (the main installer or AutoAssets)
   ↓
-----------------------------------------------------------------------------------------
|        Installer                        |                    AutoAssets               |
-----------------------------------------------------------------------------------------
| starts the standard install             |      asks the user if they want to          |
|         finish                          |      update OpenCore and have               |
|-----------------------------------------|      them select disk/partition.            |
                                          -----------------------------------------------
  ↓
ask the user to click reboot and tells them that the mac will reboot several times.
  ↓
generates a LaunchDeamon(so that the installer process can pass because it will be running as root)
  ↓
installs it to /Library/LaunchDeamons/
  ↓
sudo reboot ⏻
  ↓
macOS starts back up
  ↓
triggers LaunchDeamon just before loginwindow
  ↓
LaunchDeamon checks for /System/Library/CoreServices/OpenCore-Legacy-Patcher.plist, it is found
  ↓
revert root patches
  ↓
reboots ⏻
  ↓
starts back up unpatched
  ↓
LaunchDeamon installes OCLPT2
  ↓
LaunchDeamon triggers build and install of OpenCore to the disk the user selected
  ↓
LaunchDeamon removes the AutoAssets.pkg and the LaunchDeamon
  ↓
LaunchDeamon triggers root patching
  ↓
sudo reboot ⏻
  ↓
macOS boots the patched volume
  ↓
happy user is now running the latest root patches and OpenCore

@matteoiacca, here is the pull request

Removed comments related to PyInstaller bootloader compilation instructions.
@gandolf243

Copy link
Copy Markdown
Collaborator Author

@matteoiacca

Copy link
Copy Markdown

@gandolf243!

Telling the user upfront that the Mac will restart multiple times is definitely an improvement. Before we dive deep into coding the daemon scripts, here are a few technical hurdles we should plan for:

  1. Network availability in early boot:
    • If the patcher needs to download anything online (KDKs, missing payload assets, or packages), a LaunchDaemon running before loginwindow won't have Wi-Fi connected yet (network connections and Keychain credentials typically initialize at/after login). The package would need to be 100% offline/self-contained.
  2. Reducing reboot cycles:
    • Having 3 reboots is still quite heavy. Ideally, we should see if we can do the revert + stage new patches in a single boot cycle, or at most 1–2 reboots.
  3. Rollback & Failsafe:
    • We need a reliable fallback so that if patching fails halfway through (e.g. disk space, SIP/SSV verification), the daemon doesn't loop or leave the system unbootable without recovery.
  4. Quick note on requirements.txt:
    • The comment removed in the initial commit documents why --no-binary=pyinstaller needs PYINSTALLER_COMPILE_BOOTLOADER for 10.13 High Sierra hosts. We should probably keep that comment intact and keep this branch focused strictly on the auto-patcher logic.

Let's break this down into smaller steps: first, test the CLI commands needed for an unattended unpatch/repatch flow, then build the daemon wrapper around it once the core commands are bulletproof.

@gandolf243 gandolf243 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matteoiacca, thanks!

  1. Fix KDK download issues:

    • before showing the reboot option, OCLPT2 checks that the KDK is installed and extracted.
  2. Reboot workaround:

    • after the user clicks reboot, we revert back to the last sealed snapshot bless --mount / --bootefi --last-sealed-snapshot
    • this means that now all we have to do is make sure that AutoAssets.pkg deletes itself and/or the LaunchDaemon.
  3. Setup a reboot cap:

    • setup a cap so that it can only reboot say five times.
  4. requirements.txt:

    • I only did that so that I could create this pull request, it can be fixed later

Thank you for your feedback!

@albert-mueller

Copy link
Copy Markdown
Collaborator
  • Starting Patch Process

  • Determining Required Patch set for Darwin 25
    Bypassing SIP validation - host detected as VMware VM with allow_vmware_root_patching enabled (test-only, see host_is_vmware_vm)
    This is designed only for advanced developers to test the syntax of the root patching process.
    Bypassing AMFI validation - host detected as VMware VM with allow_vmware_root_patching enabled (test-only, see host_is_vmware_vm)

  • Verifying whether Root Patching possible

  • Patcher is capable of patching

  • Unprivileged hdiutil attach failed, retrying with administrator privileges

  • Failed to mount Universal-Binaries.dmg
    Subprocess failed.
    Command: ['/usr/bin/hdiutil', 'attach', '-noverify', '/Library/Application Support/albert-mueller/OpenCore-Patcher-T2/OpenCore-Patcher-T2.app/Contents/Frameworks/Universal-Binaries.dmg', '-mountpoint', '/var/folders/9g/6ywz29657hdgf2p3p0nkysth0000gn/T/tmpuy312q33/payloads/Universal-Binaries', '-nobrowse', '-shadow', '/var/folders/9g/6ywz29657hdgf2p3p0nkysth0000gn/T/tmpuy312q33/payloads/Universal-Binaries_overlay', '-stdinpass']
    Return Code: 1
    Standard Output:
    hdiutil: attach failed - Permission denied
    Standard Error:
    Elevated hdiutil attach did not mount the image

  • Critical resources missing, cannot continue with patching!!!

Testing in a virtual machine. After returning to the menu and back to the root patching, it succeeds. However, this is what I tested from main. And did so inside a virtual machine.
@gandolf243 @matteoiacca

@albert-mueller

Copy link
Copy Markdown
Collaborator

@gandolf243 @matteoiacca Also, it is a good idea to make this function opt in or opt out so if the user faces a corrupted patch, it can't just trigger a kernel panic and the patcher to render the machine unbootable indefinately on its own.

@albert-mueller

Copy link
Copy Markdown
Collaborator
  • Starting Patch Process
  • Determining Required Patch set for Darwin 25
    Bypassing SIP validation - host detected as VMware VM with allow_vmware_root_patching enabled (test-only, see host_is_vmware_vm)
    This is designed only for advanced developers to test the syntax of the root patching process.
    Bypassing AMFI validation - host detected as VMware VM with allow_vmware_root_patching enabled (test-only, see host_is_vmware_vm)
  • Verifying whether Root Patching possible
  • Patcher is capable of patching
  • Unprivileged hdiutil attach failed, retrying with administrator privileges
  • Failed to mount Universal-Binaries.dmg
    Subprocess failed.
    Command: ['/usr/bin/hdiutil', 'attach', '-noverify', '/Library/Application Support/albert-mueller/OpenCore-Patcher-T2/OpenCore-Patcher-T2.app/Contents/Frameworks/Universal-Binaries.dmg', '-mountpoint', '/var/folders/9g/6ywz29657hdgf2p3p0nkysth0000gn/T/tmpuy312q33/payloads/Universal-Binaries', '-nobrowse', '-shadow', '/var/folders/9g/6ywz29657hdgf2p3p0nkysth0000gn/T/tmpuy312q33/payloads/Universal-Binaries_overlay', '-stdinpass']
    Return Code: 1
    Standard Output:
    hdiutil: attach failed - Permission denied
    Standard Error:
    Elevated hdiutil attach did not mount the image
  • Critical resources missing, cannot continue with patching!!!

Testing in a virtual machine. After returning to the menu and back to the root patching, it succeeds. However, this is what I tested from main. And did so inside a virtual machine. @gandolf243 @matteoiacca

It's a good idea to fix somehow this issue before implementing this new function.
@gandolf243 @matteoiacca

@albert-mueller
albert-mueller marked this pull request as ready for review October 25, 2026 14:10
@albert-mueller
albert-mueller marked this pull request as draft October 25, 2026 14:10
@gandolf243

Copy link
Copy Markdown
Collaborator Author

@albert-mueller, @Medelcartelinc, we have some work to do here, any ideas of what to do and how to get started?

@albert-mueller

Copy link
Copy Markdown
Collaborator

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants