mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-21 03:04:31 +10:00
Switch to onedir option
This commit is contained in:
3
.github/workflows/build-app-wxpython.yml
vendored
3
.github/workflows/build-app-wxpython.yml
vendored
@@ -17,10 +17,11 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: python3 create_offline_build.py
|
||||
- run: zip -r payloads.zip payloads
|
||||
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher-GUI.spec
|
||||
- run: python3 ./payloads/binary.py $branch $commiturl $commitdate
|
||||
- run: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'
|
||||
- run: cd dist; zip -r ../OpenCore-Patcher-wxPython.app.zip OpenCore-Patcher.app
|
||||
- run: cd dist; ditto -c -k --sequesterRsrc --keepParent OpenCore-Patcher.app ../OpenCore-Patcher-wxPython.app.zip
|
||||
- run: ./../sign-wxpython.sh
|
||||
- run: packagesbuild ./payloads/InstallPackage/AutoPkg-Assets-Setup.pkgproj
|
||||
- run: mv ./OpenCore-Patcher-wxPython.app.zip ./OpenCore-Patcher-GUI.app.zip
|
||||
|
||||
@@ -7,9 +7,9 @@ block_cipher = None
|
||||
|
||||
|
||||
a = Analysis(['OpenCore-Patcher-GUI.command'],
|
||||
pathex=['resources', 'data', 'gui'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('payloads', 'payloads')],
|
||||
datas=[('payloads.zip', '.')],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
@@ -23,34 +23,38 @@ pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
a.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='OpenCore-Patcher',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None )
|
||||
app = BUNDLE(exe,
|
||||
coll = COLLECT(exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
name='OpenCore-Patcher')
|
||||
app = BUNDLE(coll,
|
||||
name='OpenCore-Patcher.app',
|
||||
icon="payloads/OC-Patcher.icns",
|
||||
bundle_identifier="com.dortania.opencore-legacy-patcher-wxpython",
|
||||
info_plist={
|
||||
"CFBundleShortVersionString": constants.Constants().patcher_version,
|
||||
"NSHumanReadableCopyright": constants.Constants().copyright_date,
|
||||
"LSMinimumSystemVersion": "10.10.0",
|
||||
"NSRequiresAquaSystemAppearance": False,
|
||||
"NSHighResolutionCapable": True,
|
||||
"Build Date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
|
||||
"BuildMachineOSBuild": subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode().strip(),
|
||||
"NSPrincipalClass": "NSApplication",
|
||||
"CFBundleShortVersionString": constants.Constants().patcher_version,
|
||||
"NSHumanReadableCopyright": constants.Constants().copyright_date,
|
||||
"LSMinimumSystemVersion": "10.10.0",
|
||||
"NSRequiresAquaSystemAppearance": False,
|
||||
"NSHighResolutionCapable": True,
|
||||
#"Build Date": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
|
||||
#"BuildMachineOSBuild": subprocess.run("sw_vers -buildVersion".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode().strip(),
|
||||
"NSPrincipalClass": "NSApplication",
|
||||
})
|
||||
|
||||
@@ -563,6 +563,10 @@ class wx_python_gui:
|
||||
|
||||
def build_start(self, event=None):
|
||||
self.build_opencore.Disable()
|
||||
|
||||
while self.constants.unpack_thread.is_alive():
|
||||
time.sleep(0.1)
|
||||
|
||||
build.BuildOpenCore(self.constants.custom_model or self.constants.computer.real_model, self.constants).build_opencore()
|
||||
# Once finished, change build_opencore button to "Install OpenCore"
|
||||
self.build_opencore.SetLabel("🔩 Install OpenCore")
|
||||
@@ -819,6 +823,8 @@ class wx_python_gui:
|
||||
# Button: Start Root Patching
|
||||
# Button: Revert Root Patches
|
||||
# Button: Return to Main Menu
|
||||
while self.constants.unpack_thread.is_alive():
|
||||
time.sleep(0.1)
|
||||
self.frame.DestroyChildren()
|
||||
|
||||
# Header
|
||||
|
||||
@@ -106,6 +106,7 @@ class Constants:
|
||||
self.launcher_script = None # Determine launch file (if run via Python)
|
||||
self.ignore_updates = False # Ignore OCLP updates
|
||||
self.wxpython_variant = False # Determine if using wxPython variant
|
||||
self.unpack_thread = None # Determine if unpack thread finished
|
||||
|
||||
## Hardware
|
||||
self.computer: device_probe.Computer = None # type: ignore
|
||||
|
||||
@@ -4,7 +4,11 @@ from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import atexit
|
||||
import time
|
||||
import threading
|
||||
|
||||
from resources import build, cli_menu, constants, utilities, device_probe, os_probe, defaults, arguments, install, tui_helpers
|
||||
from data import model_array
|
||||
@@ -40,7 +44,10 @@ class OpenCoreLegacyPatcher:
|
||||
launcher_script = launcher_script.replace("/resources/main.py", "/OpenCore-Patcher-GUI.command")
|
||||
self.constants.launcher_binary = launcher_binary
|
||||
self.constants.launcher_script = launcher_script
|
||||
self.constants.unpack_thread = threading.Thread(target=self.reroute_payloads)
|
||||
self.constants.unpack_thread.start()
|
||||
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
|
||||
|
||||
if utilities.check_cli_args() is not None:
|
||||
print("- Detected arguments, switching to CLI mode")
|
||||
self.constants.gui_mode = True # Assumes no user interaction is required
|
||||
@@ -54,6 +61,66 @@ class OpenCoreLegacyPatcher:
|
||||
else:
|
||||
print(f"- No arguments present, loading {'GUI' if self.constants.wxpython_variant is True else 'TUI'} mode")
|
||||
|
||||
def reroute_payloads(self):
|
||||
# if self.constants.launcher_binary and self.constants.wxpython_variant is True and not self.constants.launcher_script:
|
||||
if True:
|
||||
print("- Running in Binary GUI mode, switching to tmp directory")
|
||||
self.temp_dir = tempfile.TemporaryDirectory()
|
||||
print(f"- New payloads location: {self.temp_dir.name}")
|
||||
# hdiutil create ./tmp.dmg -megabytes 32000 -ov -volname "payloads" -fs HFS+ -srcfolder ./payloads -megabytes 32000
|
||||
# hdiutil convert ./tmp.dmg -format UDZO -o payloads.dmg
|
||||
|
||||
# hdiutil attach ./payloads.dmg -mountpoint tmp -nobrowse
|
||||
|
||||
# create payloads directory
|
||||
print("- Creating payloads directory")
|
||||
Path(self.temp_dir.name / Path("payloads")).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
use_zip = False
|
||||
# unzip payloads.zip to payloads directory
|
||||
|
||||
if use_zip is True:
|
||||
print("- Unzipping payloads.zip")
|
||||
output = subprocess.run(["unzip", "-o", "-q", "-d", self.temp_dir.name, f"{self.constants.payload_path}.zip"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if output.returncode == 0:
|
||||
print(f"- Unzipped payloads.zip successfully: {self.temp_dir.name}")
|
||||
self.constants.current_path = Path(self.temp_dir.name)
|
||||
self.constants.payload_path = Path(self.temp_dir.name) / Path("payloads")
|
||||
print(f"self.constants.current_path: {self.constants.current_path}")
|
||||
print(f"self.constants.payload_path: {self.constants.payload_path}")
|
||||
else:
|
||||
print("- Failed to unzip payloads.zip, skipping")
|
||||
else:
|
||||
output = subprocess.run(["hdiutil", "attach", f"{self.constants.payload_path}.dmg", "-mountpoint", Path(self.temp_dir.name / Path("payloads")), "-nobrowse", "-shadow", Path(self.temp_dir.name / Path("payloads_overlay"))], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if output.returncode == 0:
|
||||
print("- Mounted payloads.dmg")
|
||||
self.constants.current_path = Path(self.temp_dir.name)
|
||||
self.constants.payload_path = Path(self.temp_dir.name) / Path("payloads")
|
||||
print(f"self.constants.current_path: {self.constants.current_path}")
|
||||
print(f"self.constants.payload_path: {self.constants.payload_path}")
|
||||
atexit.register(self.clean_up)
|
||||
|
||||
else:
|
||||
print("- Failed to mount payloads.dmg")
|
||||
print(f"Output: {output.stdout.decode()}")
|
||||
print(f"Return Code: {output.returncode}")
|
||||
print("- Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
def clean_up(self):
|
||||
output = subprocess.run(["hdiutil", "detach", f"{self.temp_dir.name}/payloads"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if output.returncode == 0:
|
||||
print("- Unmounted payloads.dmg successfully")
|
||||
else:
|
||||
print("- Failed to unmount payloads.dmg, sleeping for 1 seconds and trying again")
|
||||
time.sleep(1)
|
||||
output = subprocess.run(["hdiutil", "detach", f"{self.temp_dir.name}/payloads"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if output.returncode == 0:
|
||||
print("- Unmounted payloads.dmg successfully")
|
||||
else:
|
||||
print("- Failed to unmount payloads.dmg, skipping")
|
||||
|
||||
|
||||
def main_menu(self):
|
||||
response = None
|
||||
while not (response and response == -1):
|
||||
|
||||
Reference in New Issue
Block a user