Set dmg as mount type

This commit is contained in:
Mykola Grymalyuk
2022-05-18 16:08:47 -06:00
parent b98fa0ced9
commit 053641bf4f
5 changed files with 35 additions and 26 deletions

View File

@@ -17,7 +17,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: python3 create_offline_build.py - run: python3 create_offline_build.py
- run: zip -P password -r payloads.zip payloads - run: hdiutil create ./tmp.dmg -megabytes 32000 -format UDZO -ov -volname "payloads" -fs HFS+ -srcfolder ./payloads -passphrase password -encryption
- run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher-GUI.spec - run: /Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller OpenCore-Patcher-GUI.spec
- run: python3 ./payloads/binary.py $branch $commiturl $commitdate - 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: 'codesign -s "Developer ID Application: Mykola Grymalyuk (S74BDJXQMD)" -v --force --deep --timestamp --entitlements ./payloads/entitlements.plist -o runtime "dist/OpenCore-Patcher.app"'

View File

@@ -9,7 +9,7 @@ block_cipher = None
a = Analysis(['OpenCore-Patcher-GUI.command'], a = Analysis(['OpenCore-Patcher-GUI.command'],
pathex=[], pathex=[],
binaries=[], binaries=[],
datas=[('payloads.zip', '.')], datas=[('payloads.dmg', '.')],
hiddenimports=[], hiddenimports=[],
hookspath=[], hookspath=[],
hooksconfig={}, hooksconfig={},

View File

@@ -823,8 +823,6 @@ class wx_python_gui:
# Button: Start Root Patching # Button: Start Root Patching
# Button: Revert Root Patches # Button: Revert Root Patches
# Button: Return to Main Menu # Button: Return to Main Menu
while self.constants.unpack_thread.is_alive():
time.sleep(0.1)
self.frame.DestroyChildren() self.frame.DestroyChildren()
# Header # Header
@@ -1010,7 +1008,22 @@ class wx_python_gui:
) )
) )
self.developer_note.Centre(wx.HORIZONTAL) self.developer_note.Centre(wx.HORIZONTAL)
self.frame.SetSize(-1, self.developer_note.GetPosition().y + self.developer_note.GetSize().height + 80)
self.progress_bar_new = wx.Gauge(self.frame, range=100, size=(200, 10))
self.progress_bar_new.SetPosition(
wx.Point(
self.developer_note.GetPosition().x,
self.developer_note.GetPosition().y + self.developer_note.GetSize().height + 10
)
)
self.progress_bar_new.SetValue(0)
self.progress_bar_new.Centre(wx.HORIZONTAL)
self.progress_bar_new.Pulse()
self.frame.SetSize(-1, self.progress_bar_new.GetPosition().y + self.progress_bar_new.GetSize().height + 60)
self.frame.Show()
while self.constants.unpack_thread.is_alive():
wx.GetApp().Yield()
# Download resources # Download resources
sys.stdout=menu_redirect.RedirectLabel(self.developer_note) sys.stdout=menu_redirect.RedirectLabel(self.developer_note)
@@ -1154,6 +1167,8 @@ class wx_python_gui:
sys.stdout = menu_redirect.RedirectText(self.text_box, True) sys.stdout = menu_redirect.RedirectText(self.text_box, True)
sys.stderr = menu_redirect.RedirectText(self.text_box, True) sys.stderr = menu_redirect.RedirectText(self.text_box, True)
wx.GetApp().Yield() wx.GetApp().Yield()
while self.constants.unpack_thread.is_alive():
time.sleep(0.1)
try: try:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch() sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch()
except Exception as e: except Exception as e:

View File

@@ -1,6 +1,7 @@
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
from __future__ import print_function from __future__ import print_function
import plistlib
import subprocess import subprocess
import sys import sys
@@ -46,6 +47,7 @@ class OpenCoreLegacyPatcher:
self.constants.launcher_script = launcher_script self.constants.launcher_script = launcher_script
self.constants.unpack_thread = threading.Thread(target=self.reroute_payloads) self.constants.unpack_thread = threading.Thread(target=self.reroute_payloads)
self.constants.unpack_thread.start() self.constants.unpack_thread.start()
defaults.generate_defaults.probe(self.computer.real_model, True, self.constants) defaults.generate_defaults.probe(self.computer.real_model, True, self.constants)
if utilities.check_cli_args() is not None: if utilities.check_cli_args() is not None:
@@ -67,7 +69,7 @@ class OpenCoreLegacyPatcher:
print("- Running in Binary GUI mode, switching to tmp directory") print("- Running in Binary GUI mode, switching to tmp directory")
self.temp_dir = tempfile.TemporaryDirectory() self.temp_dir = tempfile.TemporaryDirectory()
print(f"- New payloads location: {self.temp_dir.name}") 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 create ./tmp.dmg -megabytes 32000 -format UDZO -ov -volname "payloads" -fs HFS+ -srcfolder ./payloads -passphrase password -encryption
# hdiutil convert ./tmp.dmg -format UDZO -o payloads.dmg # hdiutil convert ./tmp.dmg -format UDZO -o payloads.dmg
# hdiutil attach ./payloads.dmg -mountpoint tmp -nobrowse # hdiutil attach ./payloads.dmg -mountpoint tmp -nobrowse
@@ -76,7 +78,7 @@ class OpenCoreLegacyPatcher:
print("- Creating payloads directory") print("- Creating payloads directory")
Path(self.temp_dir.name / Path("payloads")).mkdir(parents=True, exist_ok=True) Path(self.temp_dir.name / Path("payloads")).mkdir(parents=True, exist_ok=True)
use_zip = True use_zip = False
# unzip payloads.zip to payloads directory # unzip payloads.zip to payloads directory
if use_zip is True: if use_zip is True:
@@ -86,22 +88,18 @@ class OpenCoreLegacyPatcher:
print(f"- Unzipped payloads.zip successfully: {self.temp_dir.name}") print(f"- Unzipped payloads.zip successfully: {self.temp_dir.name}")
self.constants.current_path = Path(self.temp_dir.name) self.constants.current_path = Path(self.temp_dir.name)
self.constants.payload_path = Path(self.temp_dir.name) / Path("payloads") 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: else:
print("- Failed to unzip payloads.zip, skipping") print("- Failed to unzip payloads.zip, skipping")
print(f"Output: {output.stdout.decode('utf-8')}") print(f"Output: {output.stdout.decode('utf-8')}")
print(f"Return code: {output.returncode}") print(f"Return code: {output.returncode}")
else: 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) self.clean_up()
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")), "-passphrase", "password"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if output.returncode == 0: if output.returncode == 0:
print("- Mounted payloads.dmg") print("- Mounted payloads.dmg")
self.constants.current_path = Path(self.temp_dir.name) self.constants.current_path = Path(self.temp_dir.name)
self.constants.payload_path = Path(self.temp_dir.name) / Path("payloads") 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) atexit.register(self.clean_up)
else: else:
print("- Failed to mount payloads.dmg") print("- Failed to mount payloads.dmg")
print(f"Output: {output.stdout.decode()}") print(f"Output: {output.stdout.decode()}")
@@ -110,17 +108,14 @@ class OpenCoreLegacyPatcher:
sys.exit(1) sys.exit(1)
def clean_up(self): def clean_up(self):
output = subprocess.run(["hdiutil", "detach", f"{self.temp_dir.name}/payloads"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # Grab info on all dmgs mounted
if output.returncode == 0: dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Unmounted payloads.dmg successfully") dmg_info = plistlib.loads(dmg_info.stdout)
else:
print("- Failed to unmount payloads.dmg, sleeping for 1 seconds and trying again") for image in dmg_info["images"]:
time.sleep(1) if image["image-path"].endswith("payloads.dmg"):
output = subprocess.run(["hdiutil", "detach", f"{self.temp_dir.name}/payloads"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) print(f"- Unmounting payloads.dmg")
if output.returncode == 0: subprocess.run(["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print("- Unmounted payloads.dmg successfully")
else:
print("- Failed to unmount payloads.dmg, skipping")
def main_menu(self): def main_menu(self):

View File

@@ -23,8 +23,7 @@ class grab_patcher_support_pkg:
shutil.rmtree(self.constants.payload_local_binaries_root_path) shutil.rmtree(self.constants.payload_local_binaries_root_path)
download_result = None download_result = None
local_zip = Path(self.constants.payload_path) / f"Universal-Binaries.zip" if Path(self.constants.payload_local_binaries_root_path_zip).exists():
if Path(local_zip).exists():
print(f"- Found local Universal-Binaries.zip, skipping download") print(f"- Found local Universal-Binaries.zip, skipping download")
download_result = True download_result = True
else: else: