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:
- uses: actions/checkout@v3
- 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: 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"'

View File

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

View File

@@ -823,8 +823,6 @@ 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
@@ -1010,7 +1008,22 @@ class wx_python_gui:
)
)
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
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.stderr = menu_redirect.RedirectText(self.text_box, True)
wx.GetApp().Yield()
while self.constants.unpack_thread.is_alive():
time.sleep(0.1)
try:
sys_patch.PatchSysVolume(self.constants.custom_model or self.constants.computer.real_model, self.constants, self.patches).start_unpatch()
except Exception as e:

View File

@@ -1,6 +1,7 @@
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
from __future__ import print_function
import plistlib
import subprocess
import sys
@@ -46,6 +47,7 @@ class OpenCoreLegacyPatcher:
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:
@@ -67,7 +69,7 @@ class OpenCoreLegacyPatcher:
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 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 attach ./payloads.dmg -mountpoint tmp -nobrowse
@@ -76,7 +78,7 @@ class OpenCoreLegacyPatcher:
print("- Creating payloads directory")
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
if use_zip is True:
@@ -86,22 +88,18 @@ class OpenCoreLegacyPatcher:
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")
print(f"Output: {output.stdout.decode('utf-8')}")
print(f"Return code: {output.returncode}")
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:
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()}")
@@ -110,17 +108,14 @@ class OpenCoreLegacyPatcher:
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")
# Grab info on all dmgs mounted
dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
dmg_info = plistlib.loads(dmg_info.stdout)
for image in dmg_info["images"]:
if image["image-path"].endswith("payloads.dmg"):
print(f"- Unmounting payloads.dmg")
subprocess.run(["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def main_menu(self):

View File

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