mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 05:40:01 +10:00
Merge pull request #1121 from dortania/subprocess-cleanup
Refactor subprocess usage
This commit is contained in:
+9
-11
@@ -126,7 +126,7 @@ class CreateBinary:
|
|||||||
if Path(f"./dist/OpenCore-Patcher.app").exists():
|
if Path(f"./dist/OpenCore-Patcher.app").exists():
|
||||||
print("Found OpenCore-Patcher.app, removing...")
|
print("Found OpenCore-Patcher.app, removing...")
|
||||||
rm_output = subprocess.run(
|
rm_output = subprocess.run(
|
||||||
["rm", "-rf", "./dist/OpenCore-Patcher.app"],
|
["/bin/rm", "-rf", "./dist/OpenCore-Patcher.app"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
if rm_output.returncode != 0:
|
if rm_output.returncode != 0:
|
||||||
@@ -152,13 +152,11 @@ class CreateBinary:
|
|||||||
print("Embedding icns...")
|
print("Embedding icns...")
|
||||||
for file in Path("payloads/Icon/AppIcons").glob("*.icns"):
|
for file in Path("payloads/Icon/AppIcons").glob("*.icns"):
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["cp", str(file), "./dist/OpenCore-Patcher.app/Contents/Resources/"],
|
["/bin/cp", str(file), "./dist/OpenCore-Patcher.app/Contents/Resources/"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _embed_key(self):
|
def _embed_key(self):
|
||||||
"""
|
"""
|
||||||
Embed developer key into binary
|
Embed developer key into binary
|
||||||
@@ -252,12 +250,12 @@ class CreateBinary:
|
|||||||
if file.name in whitelist_folders:
|
if file.name in whitelist_folders:
|
||||||
continue
|
continue
|
||||||
print(f"- Deleting {file.name}")
|
print(f"- Deleting {file.name}")
|
||||||
subprocess.run(["rm", "-rf", file])
|
subprocess.run(["/bin/rm", "-rf", file])
|
||||||
else:
|
else:
|
||||||
if file.name in whitelist_files:
|
if file.name in whitelist_files:
|
||||||
continue
|
continue
|
||||||
print(f"- Deleting {file.name}")
|
print(f"- Deleting {file.name}")
|
||||||
subprocess.run(["rm", "-f", file])
|
subprocess.run(["/bin/rm", "-f", file])
|
||||||
|
|
||||||
|
|
||||||
def _download_resources(self):
|
def _download_resources(self):
|
||||||
@@ -279,7 +277,7 @@ class CreateBinary:
|
|||||||
assert resource, "Resource cannot be empty"
|
assert resource, "Resource cannot be empty"
|
||||||
assert resource not in ("/", "."), "Resource cannot be root"
|
assert resource not in ("/", "."), "Resource cannot be root"
|
||||||
rm_output = subprocess.run(
|
rm_output = subprocess.run(
|
||||||
["rm", "-rf", f"./{resource}"],
|
["/bin/rm", "-rf", f"./{resource}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
if rm_output.returncode != 0:
|
if rm_output.returncode != 0:
|
||||||
@@ -293,7 +291,7 @@ class CreateBinary:
|
|||||||
|
|
||||||
download_result = subprocess.run(
|
download_result = subprocess.run(
|
||||||
[
|
[
|
||||||
"curl", "-LO",
|
"/usr/bin/curl", "-LO",
|
||||||
f"https://github.com/dortania/PatcherSupportPkg/releases/download/{patcher_support_pkg_version}/{resource}"
|
f"https://github.com/dortania/PatcherSupportPkg/releases/download/{patcher_support_pkg_version}/{resource}"
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
@@ -322,7 +320,7 @@ class CreateBinary:
|
|||||||
|
|
||||||
print("- Removing old payloads.dmg")
|
print("- Removing old payloads.dmg")
|
||||||
rm_output = subprocess.run(
|
rm_output = subprocess.run(
|
||||||
["rm", "-rf", "./payloads.dmg"],
|
["/bin/rm", "-rf", "./payloads.dmg"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
if rm_output.returncode != 0:
|
if rm_output.returncode != 0:
|
||||||
@@ -332,7 +330,7 @@ class CreateBinary:
|
|||||||
|
|
||||||
print("- Generating DMG...")
|
print("- Generating DMG...")
|
||||||
dmg_output = subprocess.run([
|
dmg_output = subprocess.run([
|
||||||
'hdiutil', 'create', './payloads.dmg',
|
'/usr/bin/hdiutil', 'create', './payloads.dmg',
|
||||||
'-megabytes', '32000', # Overlays can only be as large as the disk image allows
|
'-megabytes', '32000', # Overlays can only be as large as the disk image allows
|
||||||
'-format', 'UDZO', '-ov',
|
'-format', 'UDZO', '-ov',
|
||||||
'-volname', 'OpenCore Patcher Resources (Base)',
|
'-volname', 'OpenCore Patcher Resources (Base)',
|
||||||
@@ -410,7 +408,7 @@ class CreateBinary:
|
|||||||
path = "./dist/OpenCore-Patcher"
|
path = "./dist/OpenCore-Patcher"
|
||||||
print(f"- Removing {path}")
|
print(f"- Removing {path}")
|
||||||
rm_output = subprocess.run(
|
rm_output = subprocess.run(
|
||||||
["rm", "-rf", path],
|
["/bin/rm", "-rf", path],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
if rm_output.returncode != 0:
|
if rm_output.returncode != 0:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# OpenCore Legacy Patcher changelog
|
# OpenCore Legacy Patcher changelog
|
||||||
|
|
||||||
## 1.4.0
|
## 1.4.0
|
||||||
|
- Refactor subprocess invocations
|
||||||
|
|
||||||
## 1.3.0
|
## 1.3.0
|
||||||
- Resolve mismatched `CFBundleExecutable` and binary name for kexts.
|
- Resolve mismatched `CFBundleExecutable` and binary name for kexts.
|
||||||
|
|||||||
@@ -108,36 +108,36 @@ class GenerateKexts:
|
|||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
# Download source
|
# Download source
|
||||||
weg_source_zip = f"{temp_dir}/WhateverGreen-{self.weg_version}.zip"
|
weg_source_zip = f"{temp_dir}/WhateverGreen-{self.weg_version}.zip"
|
||||||
subprocess.run(["curl", "-L", weg_source_url, "-o", weg_source_zip], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/curl", "--location", weg_source_url, "--output", weg_source_zip], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
# Unzip source
|
# Unzip source
|
||||||
subprocess.run(["unzip", weg_source_zip, "-d", temp_dir], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/unzip", weg_source_zip, "-d", temp_dir], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
# Git clone MacKernelSDK into source
|
# Git clone MacKernelSDK into source
|
||||||
subprocess.run(["git", "clone", "https://github.com/acidanthera/MacKernelSDK", f"{temp_dir}/WhateverGreen-{self.weg_version}/MacKernelSDK"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/git", "clone", "https://github.com/acidanthera/MacKernelSDK", f"{temp_dir}/WhateverGreen-{self.weg_version}/MacKernelSDK"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
# Grab latest Lilu release, debug version
|
# Grab latest Lilu release, debug version
|
||||||
lilu_zip = f"{temp_dir}/Lilu-{self.lilu_version}-DEBUG.zip"
|
lilu_zip = f"{temp_dir}/Lilu-{self.lilu_version}-DEBUG.zip"
|
||||||
subprocess.run(["curl", "-L", lilu_url, "-o", lilu_zip], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/curl", "--location", lilu_url, "--output", lilu_zip], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
# Unzip Lilu into WEG source
|
# Unzip Lilu into WEG source
|
||||||
subprocess.run(["unzip", lilu_zip, "-d", f"{temp_dir}/WhateverGreen-{self.weg_version}"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/unzip", lilu_zip, "-d", f"{temp_dir}/WhateverGreen-{self.weg_version}"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
# Apply patch
|
# Apply patch
|
||||||
patch_path = Path("./Acidanthera/WhateverGreen-Navi-Backlight.patch").absolute()
|
patch_path = Path("./Acidanthera/WhateverGreen-Navi-Backlight.patch").absolute()
|
||||||
subprocess.run(["git", "apply", patch_path], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}")
|
subprocess.run(["/usr/bin/git", "apply", patch_path], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}")
|
||||||
|
|
||||||
# Build WEG
|
# Build WEG
|
||||||
for variant in ["Release", "Debug"]:
|
for variant in ["Release", "Debug"]:
|
||||||
subprocess.run(["xcodebuild", "-configuration", variant], cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}", check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/usr/bin/xcodebuild", "-configuration", variant], cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}", check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
# Zip Release
|
# Zip Release
|
||||||
for variant in ["RELEASE", "DEBUG"]:
|
for variant in ["RELEASE", "DEBUG"]:
|
||||||
dst_path = Path(f"./Acidanthera/WhateverGreen-v{self.weg_version}-Navi-{variant}.zip").absolute()
|
dst_path = Path(f"./Acidanthera/WhateverGreen-v{self.weg_version}-Navi-{variant}.zip").absolute()
|
||||||
subprocess.run(["zip", "-r", dst_path, "WhateverGreen.kext"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}/build/{'Release' if variant == 'RELEASE' else 'Debug'}")
|
subprocess.run(["/usr/bin/zip", "-r", dst_path, "WhateverGreen.kext"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=f"{temp_dir}/WhateverGreen-{self.weg_version}/build/{'Release' if variant == 'RELEASE' else 'Debug'}")
|
||||||
if Path(f"./Acidanthera/WhateverGreen-v{self.weg_old}-Navi-{variant}.zip").exists():
|
if Path(f"./Acidanthera/WhateverGreen-v{self.weg_old}-Navi-{variant}.zip").exists():
|
||||||
subprocess.run(["rm", f"./Acidanthera/WhateverGreen-v{self.weg_old}-Navi-{variant}.zip"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(["/bin/rm", f"./Acidanthera/WhateverGreen-v{self.weg_old}-Navi-{variant}.zip"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
self._update_constants_file("self.whatevergreen_navi_version", f"{self.weg_old}-Navi", f"{self.weg_version}-Navi")
|
self._update_constants_file("self.whatevergreen_navi_version", f"{self.weg_old}-Navi", f"{self.weg_version}-Navi")
|
||||||
|
|
||||||
@@ -212,14 +212,14 @@ class GenerateKexts:
|
|||||||
zip_name = f"{override_kext_zip_name}-v{remote_version}-{variant}.zip" if override_kext_zip_name else f"{kext_name}-v{remote_version}-{variant}.zip"
|
zip_name = f"{override_kext_zip_name}-v{remote_version}-{variant}.zip" if override_kext_zip_name else f"{kext_name}-v{remote_version}-{variant}.zip"
|
||||||
|
|
||||||
if Path(f"./{kext_folder}/{zip_name.replace(f'v{remote_version}', f'v{local_version}')}").exists():
|
if Path(f"./{kext_folder}/{zip_name.replace(f'v{remote_version}', f'v{local_version}')}").exists():
|
||||||
subprocess.run(["rm", "-rf", f"./{kext_folder}/{zip_name.replace(f'v{remote_version}', f'v{local_version}')}"])
|
subprocess.run(["/bin/rm", "-rf", f"./{kext_folder}/{zip_name.replace(f'v{remote_version}', f'v{local_version}')}"])
|
||||||
self._download_file(asset["browser_download_url"], f"./{kext_folder}/{zip_name}", f"{kext_name}.kext")
|
self._download_file(asset["browser_download_url"], f"./{kext_folder}/{zip_name}", f"{kext_name}.kext")
|
||||||
self._update_constants_file(KEXT_DICTIONARY[kext_folder][kext_name]["Constants Variable"], local_version, remote_version)
|
self._update_constants_file(KEXT_DICTIONARY[kext_folder][kext_name]["Constants Variable"], local_version, remote_version)
|
||||||
|
|
||||||
if override_kext_zip_name:
|
if override_kext_zip_name:
|
||||||
# rename zip file
|
# rename zip file
|
||||||
os.rename(f"./{kext_folder}/{zip_name}", f"./{kext_folder}/{kext_name}-v{remote_version}-{variant}.zip")
|
os.rename(f"./{kext_folder}/{zip_name}", f"./{kext_folder}/{kext_name}-v{remote_version}-{variant}.zip")
|
||||||
subprocess.run(["rm", "-rf", f"./{kext_folder}/{kext_name}-v{local_version}-{variant}.zip"])
|
subprocess.run(["/bin/rm", "-rf", f"./{kext_folder}/{kext_name}-v{local_version}-{variant}.zip"])
|
||||||
|
|
||||||
|
|
||||||
def _get_local_version(self, kext_folder, kext_name, variant):
|
def _get_local_version(self, kext_folder, kext_name, variant):
|
||||||
@@ -247,14 +247,14 @@ class GenerateKexts:
|
|||||||
f.write(download.content)
|
f.write(download.content)
|
||||||
|
|
||||||
# Unzip file
|
# Unzip file
|
||||||
subprocess.run(["unzip", "-q", f"{temp_dir}/temp.zip", "-d", f"{temp_dir}"], check=True)
|
subprocess.run(["/usr/bin/unzip", "-q", f"{temp_dir}/temp.zip", "-d", f"{temp_dir}"], check=True)
|
||||||
|
|
||||||
print(f" Moving {file} to {file_path}...")
|
print(f" Moving {file} to {file_path}...")
|
||||||
# Zip file
|
# Zip file
|
||||||
subprocess.run(["zip", "-q", "-r", Path(file_path).name, file], cwd=f"{temp_dir}", check=True)
|
subprocess.run(["/usr/bin/zip", "-q", "-r", Path(file_path).name, file], cwd=f"{temp_dir}", check=True)
|
||||||
|
|
||||||
# Move file
|
# Move file
|
||||||
subprocess.run(["mv", f"{temp_dir}/{Path(file_path).name}", file_path], check=True)
|
subprocess.run(["/bin/mv", f"{temp_dir}/{Path(file_path).name}", file_path], check=True)
|
||||||
|
|
||||||
|
|
||||||
def _update_constants_file(self, variable_name, old_version, new_version):
|
def _update_constants_file(self, variable_name, old_version, new_version):
|
||||||
|
|||||||
@@ -128,24 +128,24 @@ class GenerateOpenCore:
|
|||||||
for variant in BUILD_VARIANTS:
|
for variant in BUILD_VARIANTS:
|
||||||
print(f"Moving {variant} folder...")
|
print(f"Moving {variant} folder...")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mv", f"{self.working_dir}/OpenCore-{variant}-ROOT/X64", f"{self.working_dir}/OpenCore-{variant}"],
|
["/bin/mv", f"{self.working_dir}/OpenCore-{variant}-ROOT/X64", f"{self.working_dir}/OpenCore-{variant}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
if variant == "DEBUG":
|
if variant == "DEBUG":
|
||||||
for utility in IMPORTANT_UTILITIES:
|
for utility in IMPORTANT_UTILITIES:
|
||||||
print(f"Moving {utility} from {variant} variant...")
|
print(f"Moving {utility} from {variant} variant...")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", f"{self.working_dir}/{utility}"],
|
["/bin/rm", "-rf", f"{self.working_dir}/{utility}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mv", f"{self.working_dir}/OpenCore-{variant}-ROOT/Utilities/{utility}/{utility}", f"{self.working_dir}/{utility}"],
|
["/bin/mv", f"{self.working_dir}/OpenCore-{variant}-ROOT/Utilities/{utility}/{utility}", f"{self.working_dir}/{utility}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove root folder
|
# Remove root folder
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", f"{self.working_dir}/OpenCore-{variant}-ROOT"],
|
["/bin/rm", "-rf", f"{self.working_dir}/OpenCore-{variant}-ROOT"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -153,12 +153,12 @@ class GenerateOpenCore:
|
|||||||
print("Removing zip files...")
|
print("Removing zip files...")
|
||||||
# remove debug_zip
|
# remove debug_zip
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", self.debug_zip],
|
["/bin/rm", "-rf", self.debug_zip],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
# remove release_zip
|
# remove release_zip
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", self.release_zip],
|
["/bin/rm", "-rf", self.release_zip],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ class GenerateOpenCore:
|
|||||||
if (self.working_dir / f"OpenCore-{variant}").exists():
|
if (self.working_dir / f"OpenCore-{variant}").exists():
|
||||||
print(f" Deleting old {variant} variant...")
|
print(f" Deleting old {variant} variant...")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", f"{self.working_dir}/OpenCore-{variant}"],
|
["/bin/rm", "-rf", f"{self.working_dir}/OpenCore-{variant}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ class GenerateOpenCore:
|
|||||||
# Create S/L/C
|
# Create S/L/C
|
||||||
print(" Creating SLC folder")
|
print(" Creating SLC folder")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mkdir", "-p", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices"],
|
["/bin/mkdir", "-p", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -220,21 +220,21 @@ class GenerateOpenCore:
|
|||||||
print(" Relocating BOOT folder to SLC")
|
print(" Relocating BOOT folder to SLC")
|
||||||
for file in (self.working_dir / f"OpenCore-{variant}/EFI/BOOT").iterdir():
|
for file in (self.working_dir / f"OpenCore-{variant}/EFI/BOOT").iterdir():
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mv", f"{file}", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices"],
|
["/bin/mv", f"{file}", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Rename BOOTx64.efi to boot.efi
|
# Rename BOOTx64.efi to boot.efi
|
||||||
print(" Renaming BOOTx64.efi to boot.efi")
|
print(" Renaming BOOTx64.efi to boot.efi")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mv", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices/BOOTx64.efi", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices/boot.efi"],
|
["/bin/mv", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices/BOOTx64.efi", f"{self.working_dir}/OpenCore-{variant}/System/Library/CoreServices/boot.efi"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete BOOT folder
|
# Delete BOOT folder
|
||||||
print(" Deleting BOOT folder")
|
print(" Deleting BOOT folder")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", f"{self.working_dir}/OpenCore-{variant}/EFI/BOOT"],
|
["/bin/rm", "-rf", f"{self.working_dir}/OpenCore-{variant}/EFI/BOOT"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ class GenerateOpenCore:
|
|||||||
if Path(f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Drivers/{driver}").exists():
|
if Path(f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Drivers/{driver}").exists():
|
||||||
print(f" Deleting {driver}")
|
print(f" Deleting {driver}")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Drivers/{driver}"],
|
["/bin/rm", f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Drivers/{driver}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -256,7 +256,7 @@ class GenerateOpenCore:
|
|||||||
if Path(f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Tools/{tool}").exists():
|
if Path(f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Tools/{tool}").exists():
|
||||||
print(f" Deleting {tool}")
|
print(f" Deleting {tool}")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Tools/{tool}"],
|
["/bin/rm", f"{self.working_dir}/OpenCore-{variant}/EFI/OC/Tools/{tool}"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -265,21 +265,21 @@ class GenerateOpenCore:
|
|||||||
# Rename OpenCore-<variant> to OpenCore-Build
|
# Rename OpenCore-<variant> to OpenCore-Build
|
||||||
print(" Renaming OpenCore folder")
|
print(" Renaming OpenCore folder")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["mv", f"{self.working_dir}/OpenCore-{variant}", f"{self.working_dir}/OpenCore-Build"],
|
["/bin/mv", f"{self.working_dir}/OpenCore-{variant}", f"{self.working_dir}/OpenCore-Build"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create OpenCore-<variant>.zip
|
# Create OpenCore-<variant>.zip
|
||||||
print(" Creating OpenCore.zip")
|
print(" Creating OpenCore.zip")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", f"{self.working_dir}/OpenCore-Build", f"{self.working_dir}/OpenCore-{variant}.zip"],
|
["/usr/bin/ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", f"{self.working_dir}/OpenCore-Build", f"{self.working_dir}/OpenCore-{variant}.zip"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete OpenCore-Build
|
# Delete OpenCore-Build
|
||||||
print(" Deleting OpenCore-Build")
|
print(" Deleting OpenCore-Build")
|
||||||
subprocess.run (
|
subprocess.run (
|
||||||
["rm", "-rf", f"{self.working_dir}/OpenCore-Build"],
|
["/bin/rm", "-rf", f"{self.working_dir}/OpenCore-Build"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class arguments:
|
|||||||
"""
|
"""
|
||||||
Fetch KDK for incoming OS
|
Fetch KDK for incoming OS
|
||||||
"""
|
"""
|
||||||
results = subprocess.run(["ps", "-ax"], stdout=subprocess.PIPE)
|
results = subprocess.run(["/bin/ps", "-ax"], stdout=subprocess.PIPE)
|
||||||
if results.stdout.decode("utf-8").count("OpenCore-Patcher --cache_os") > 1:
|
if results.stdout.decode("utf-8").count("OpenCore-Patcher --cache_os") > 1:
|
||||||
logging.info("Another instance of OS caching is running, exiting")
|
logging.info("Another instance of OS caching is running, exiting")
|
||||||
return
|
return
|
||||||
@@ -154,7 +154,7 @@ class arguments:
|
|||||||
if "GPUCompanionBundles" not in kext_plist:
|
if "GPUCompanionBundles" not in kext_plist:
|
||||||
continue
|
continue
|
||||||
logging.info(f" - Removing {kext.name}")
|
logging.info(f" - Removing {kext.name}")
|
||||||
subprocess.run(["rm", "-rf", kext])
|
subprocess.run(["/bin/rm", "-rf", kext])
|
||||||
|
|
||||||
|
|
||||||
def _build_handler(self) -> None:
|
def _build_handler(self) -> None:
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class BuildSMBIOS:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
|
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
|
||||||
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.spoofed_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
macserial_output = subprocess.run([self.constants.macserial_path, "--generate", "--model", self.spoofed_model, "--num", "1"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
||||||
sn = macserial_output[0]
|
sn = macserial_output[0]
|
||||||
mlb = macserial_output[1]
|
mlb = macserial_output[1]
|
||||||
|
|||||||
@@ -329,9 +329,9 @@ class GenerateDefaults:
|
|||||||
|
|
||||||
for key in ["Moraea_BlurBeta"]:
|
for key in ["Moraea_BlurBeta"]:
|
||||||
# Enable BetaBlur if user hasn't disabled it
|
# Enable BetaBlur if user hasn't disabled it
|
||||||
is_key_enabled = subprocess.run(["defaults", "read", "-g", key], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
|
is_key_enabled = subprocess.run(["/usr/bin/defaults", "read", "-globalDomain", key], stdout=subprocess.PIPE).stdout.decode("utf-8").strip()
|
||||||
if is_key_enabled not in ["false", "0"]:
|
if is_key_enabled not in ["false", "0"]:
|
||||||
subprocess.run(["defaults", "write", "-g", key, "-bool", "true"])
|
subprocess.run(["/usr/bin/defaults", "write", "-globalDomain", key, "-bool", "true"])
|
||||||
|
|
||||||
def _check_amfipass_supported(self) -> None:
|
def _check_amfipass_supported(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -862,7 +862,7 @@ class Computer:
|
|||||||
# Reported model
|
# Reported model
|
||||||
entry = next(ioreg.ioiterator_to_list(ioreg.IOServiceGetMatchingServices(ioreg.kIOMasterPortDefault, ioreg.IOServiceMatching("IOPlatformExpertDevice".encode()), None)[1]))
|
entry = next(ioreg.ioiterator_to_list(ioreg.IOServiceGetMatchingServices(ioreg.kIOMasterPortDefault, ioreg.IOServiceMatching("IOPlatformExpertDevice".encode()), None)[1]))
|
||||||
self.reported_model = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperty(entry, "model", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)).strip(b"\0").decode() # type: ignore
|
self.reported_model = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperty(entry, "model", ioreg.kCFAllocatorDefault, ioreg.kNilOptions)).strip(b"\0").decode() # type: ignore
|
||||||
translated = subprocess.run("sysctl -in sysctl.proc_translated".split(), stdout=subprocess.PIPE).stdout.decode()
|
translated = subprocess.run(["/usr/sbin/sysctl", "-in", "sysctl.proc_translated"], stdout=subprocess.PIPE).stdout.decode()
|
||||||
if translated:
|
if translated:
|
||||||
board = "target-type"
|
board = "target-type"
|
||||||
else:
|
else:
|
||||||
@@ -894,14 +894,14 @@ class Computer:
|
|||||||
|
|
||||||
def cpu_probe(self):
|
def cpu_probe(self):
|
||||||
self.cpu = CPU(
|
self.cpu = CPU(
|
||||||
subprocess.run("sysctl machdep.cpu.brand_string".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
|
subprocess.run(["/usr/sbin/sysctl", "machdep.cpu.brand_string"], stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip(),
|
||||||
subprocess.run("sysctl machdep.cpu.features".split(), stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "),
|
subprocess.run(["/usr/sbin/sysctl", "machdep.cpu.features"], stdout=subprocess.PIPE).stdout.decode().partition(": ")[2].strip().split(" "),
|
||||||
self.cpu_get_leafs(),
|
self.cpu_get_leafs(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def cpu_get_leafs(self):
|
def cpu_get_leafs(self):
|
||||||
leafs = []
|
leafs = []
|
||||||
result = subprocess.run("sysctl machdep.cpu.leaf7_features".split(), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
result = subprocess.run(["/usr/sbin/sysctl", "machdep.cpu.leaf7_features"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
return result.stdout.decode().partition(": ")[2].strip().split(" ")
|
return result.stdout.decode().partition(": ")[2].strip().split(" ")
|
||||||
return leafs
|
return leafs
|
||||||
@@ -979,7 +979,7 @@ class Computer:
|
|||||||
def sata_disk_probe(self):
|
def sata_disk_probe(self):
|
||||||
# Get all SATA Controllers/Disks from 'system_profiler SPSerialATADataType'
|
# Get all SATA Controllers/Disks from 'system_profiler SPSerialATADataType'
|
||||||
# Determine whether SATA SSD is present and Apple-made
|
# Determine whether SATA SSD is present and Apple-made
|
||||||
sp_sata_data = plistlib.loads(subprocess.run(f"system_profiler SPSerialATADataType -xml".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
sp_sata_data = plistlib.loads(subprocess.run(["/usr/sbin/system_profiler", "SPSerialATADataType", "-xml"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
for root in sp_sata_data:
|
for root in sp_sata_data:
|
||||||
for ahci_controller in root["_items"]:
|
for ahci_controller in root["_items"]:
|
||||||
# Each AHCI controller will have its own entry
|
# Each AHCI controller will have its own entry
|
||||||
@@ -1015,7 +1015,7 @@ class Computer:
|
|||||||
self.oclp_sys_signed = sys_plist["Custom Signature"]
|
self.oclp_sys_signed = sys_plist["Custom Signature"]
|
||||||
|
|
||||||
def check_rosetta(self):
|
def check_rosetta(self):
|
||||||
result = subprocess.run("sysctl -in sysctl.proc_translated".split(), stdout=subprocess.PIPE).stdout.decode()
|
result = subprocess.run(["/usr/sbin/sysctl", "-in", "sysctl.proc_translated"], stdout=subprocess.PIPE).stdout.decode()
|
||||||
if "1" in result:
|
if "1" in result:
|
||||||
self.rosetta_active = True
|
self.rosetta_active = True
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class GlobalEnviromentSettings:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Set file permission to allow any user to write to log file
|
# Set file permission to allow any user to write to log file
|
||||||
result = subprocess.run(["chmod", "777", self.global_settings_plist], capture_output=True)
|
result = subprocess.run(["/bin/chmod", "777", self.global_settings_plist], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.warning("Failed to fix settings file permissions:")
|
logging.warning("Failed to fix settings file permissions:")
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
|
|||||||
+22
-22
@@ -22,16 +22,16 @@ class tui_disk_installation:
|
|||||||
# TODO: AllDisksAndPartitions is not supported in Snow Leopard and older
|
# TODO: AllDisksAndPartitions is not supported in Snow Leopard and older
|
||||||
try:
|
try:
|
||||||
# High Sierra and newer
|
# High Sierra and newer
|
||||||
disks = plistlib.loads(subprocess.run("diskutil list -plist physical".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disks = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "list", "-plist", "physical"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Sierra and older
|
# Sierra and older
|
||||||
disks = plistlib.loads(subprocess.run("diskutil list -plist".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disks = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "list", "-plist"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
for disk in disks["AllDisksAndPartitions"]:
|
for disk in disks["AllDisksAndPartitions"]:
|
||||||
disk_info = plistlib.loads(subprocess.run(f"diskutil info -plist {disk['DeviceIdentifier']}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disk_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", disk["DeviceIdentifier"]], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
try:
|
try:
|
||||||
all_disks[disk["DeviceIdentifier"]] = {"identifier": disk_info["DeviceNode"], "name": disk_info["MediaName"], "size": disk_info["TotalSize"], "partitions": {}}
|
all_disks[disk["DeviceIdentifier"]] = {"identifier": disk_info["DeviceNode"], "name": disk_info["MediaName"], "size": disk_info["TotalSize"], "partitions": {}}
|
||||||
for partition in disk["Partitions"]:
|
for partition in disk["Partitions"]:
|
||||||
partition_info = plistlib.loads(subprocess.run(f"diskutil info -plist {partition['DeviceIdentifier']}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
partition_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", partition["DeviceIdentifier"]], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
all_disks[disk["DeviceIdentifier"]]["partitions"][partition["DeviceIdentifier"]] = {
|
all_disks[disk["DeviceIdentifier"]]["partitions"][partition["DeviceIdentifier"]] = {
|
||||||
"fs": partition_info.get("FilesystemType", partition_info["Content"]),
|
"fs": partition_info.get("FilesystemType", partition_info["Content"]),
|
||||||
"type": partition_info["Content"],
|
"type": partition_info["Content"],
|
||||||
@@ -102,15 +102,15 @@ class tui_disk_installation:
|
|||||||
logging.info("Please disable Safe Mode and try again.")
|
logging.info("Please disable Safe Mode and try again.")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(f"diskutil mount {full_disk_identifier}".split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
result = subprocess.run(["/usr/sbin/diskutil", "mount", full_disk_identifier], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Mount failed")
|
logging.info("Mount failed")
|
||||||
logging.info(result.stderr.decode())
|
logging.info(result.stderr.decode())
|
||||||
return
|
return
|
||||||
|
|
||||||
partition_info = plistlib.loads(subprocess.run(f"diskutil info -plist {full_disk_identifier}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
partition_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", full_disk_identifier], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
parent_disk = partition_info["ParentWholeDisk"]
|
parent_disk = partition_info["ParentWholeDisk"]
|
||||||
drive_host_info = plistlib.loads(subprocess.run(f"diskutil info -plist {parent_disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
drive_host_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", parent_disk], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
sd_type = drive_host_info["MediaName"]
|
sd_type = drive_host_info["MediaName"]
|
||||||
try:
|
try:
|
||||||
ssd_type = drive_host_info["SolidState"]
|
ssd_type = drive_host_info["SolidState"]
|
||||||
@@ -125,49 +125,49 @@ class tui_disk_installation:
|
|||||||
|
|
||||||
if (mount_path / Path("EFI/OC")).exists():
|
if (mount_path / Path("EFI/OC")).exists():
|
||||||
logging.info("Removing preexisting EFI/OC folder")
|
logging.info("Removing preexisting EFI/OC folder")
|
||||||
subprocess.run(["rm", "-rf", mount_path / Path("EFI/OC")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/rm", "-rf", mount_path / Path("EFI/OC")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if (mount_path / Path("System")).exists():
|
if (mount_path / Path("System")).exists():
|
||||||
logging.info("Removing preexisting System folder")
|
logging.info("Removing preexisting System folder")
|
||||||
subprocess.run(["rm", "-rf", mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/rm", "-rf", mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if (mount_path / Path("boot.efi")).exists():
|
if (mount_path / Path("boot.efi")).exists():
|
||||||
logging.info("Removing preexisting boot.efi")
|
logging.info("Removing preexisting boot.efi")
|
||||||
subprocess.run(["rm", mount_path / Path("boot.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/rm", mount_path / Path("boot.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
logging.info("Copying OpenCore onto EFI partition")
|
logging.info("Copying OpenCore onto EFI partition")
|
||||||
subprocess.run(["mkdir", "-p", mount_path / Path("EFI")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/mkdir", "-p", mount_path / Path("EFI")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
subprocess.run(["cp", "-r", self.constants.opencore_release_folder / Path("EFI/OC"), mount_path / Path("EFI/OC")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", "-r", self.constants.opencore_release_folder / Path("EFI/OC"), mount_path / Path("EFI/OC")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
subprocess.run(["cp", "-r", self.constants.opencore_release_folder / Path("System"), mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", "-r", self.constants.opencore_release_folder / Path("System"), mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if Path(self.constants.opencore_release_folder / Path("boot.efi")).exists():
|
if Path(self.constants.opencore_release_folder / Path("boot.efi")).exists():
|
||||||
subprocess.run(["cp", self.constants.opencore_release_folder / Path("boot.efi"), mount_path / Path("boot.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", self.constants.opencore_release_folder / Path("boot.efi"), mount_path / Path("boot.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if self.constants.boot_efi is True:
|
if self.constants.boot_efi is True:
|
||||||
logging.info("Converting Bootstrap to BOOTx64.efi")
|
logging.info("Converting Bootstrap to BOOTx64.efi")
|
||||||
if (mount_path / Path("EFI/BOOT")).exists():
|
if (mount_path / Path("EFI/BOOT")).exists():
|
||||||
subprocess.run(["rm", "-rf", mount_path / Path("EFI/BOOT")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/rm", "-rf", mount_path / Path("EFI/BOOT")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
Path(mount_path / Path("EFI/BOOT")).mkdir()
|
Path(mount_path / Path("EFI/BOOT")).mkdir()
|
||||||
subprocess.run(["mv", mount_path / Path("System/Library/CoreServices/boot.efi"), mount_path / Path("EFI/BOOT/BOOTx64.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/mv", mount_path / Path("System/Library/CoreServices/boot.efi"), mount_path / Path("EFI/BOOT/BOOTx64.efi")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
subprocess.run(["rm", "-rf", mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/rm", "-rf", mount_path / Path("System")], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
if self._determine_sd_card(sd_type) is True:
|
if self._determine_sd_card(sd_type) is True:
|
||||||
logging.info("Adding SD Card icon")
|
logging.info("Adding SD Card icon")
|
||||||
subprocess.run(["cp", self.constants.icon_path_sd, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", self.constants.icon_path_sd, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
elif ssd_type is True:
|
elif ssd_type is True:
|
||||||
logging.info("Adding SSD icon")
|
logging.info("Adding SSD icon")
|
||||||
subprocess.run(["cp", self.constants.icon_path_ssd, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", self.constants.icon_path_ssd, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
elif disk_type == "USB":
|
elif disk_type == "USB":
|
||||||
logging.info("Adding External USB Drive icon")
|
logging.info("Adding External USB Drive icon")
|
||||||
subprocess.run(["cp", self.constants.icon_path_external, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", self.constants.icon_path_external, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
else:
|
else:
|
||||||
logging.info("Adding Internal Drive icon")
|
logging.info("Adding Internal Drive icon")
|
||||||
subprocess.run(["cp", self.constants.icon_path_internal, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/bin/cp", self.constants.icon_path_internal, mount_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
logging.info("Cleaning install location")
|
logging.info("Cleaning install location")
|
||||||
if not self.constants.recovery_status:
|
if not self.constants.recovery_status:
|
||||||
logging.info("Unmounting EFI partition")
|
logging.info("Unmounting EFI partition")
|
||||||
subprocess.run(["diskutil", "umount", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
subprocess.run(["/usr/sbin/diskutil", "umount", mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||||
|
|
||||||
logging.info("OpenCore transfer complete")
|
logging.info("OpenCore transfer complete")
|
||||||
|
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class KernelDebugKitObject:
|
|||||||
kdk_build = kdk_plist_data["ProductBuildVersion"]
|
kdk_build = kdk_plist_data["ProductBuildVersion"]
|
||||||
|
|
||||||
# Check pkg receipts for this build, will give a canonical list if all files that should be present
|
# Check pkg receipts for this build, will give a canonical list if all files that should be present
|
||||||
result = subprocess.run(["pkgutil", "--files", f"com.apple.pkg.KDK.{kdk_build}"], capture_output=True)
|
result = subprocess.run(["/usr/sbin/pkgutil", "--files", f"com.apple.pkg.KDK.{kdk_build}"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
# If pkg receipt is missing, we'll fallback to legacy validation
|
# If pkg receipt is missing, we'll fallback to legacy validation
|
||||||
logging.info(f"pkg receipt missing for {kdk_path.name}, falling back to legacy validation")
|
logging.info(f"pkg receipt missing for {kdk_path.name}, falling back to legacy validation")
|
||||||
@@ -468,7 +468,7 @@ class KernelDebugKitObject:
|
|||||||
logging.warning(f"KDK does not exist: {kdk_path}")
|
logging.warning(f"KDK does not exist: {kdk_path}")
|
||||||
return
|
return
|
||||||
|
|
||||||
rm_args = ["rm", "-rf" if Path(kdk_path).is_dir() else "-f", kdk_path]
|
rm_args = ["/bin/rm", "-rf" if Path(kdk_path).is_dir() else "-f", kdk_path]
|
||||||
|
|
||||||
result = utilities.elevated(rm_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = utilities.elevated(rm_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
@@ -538,7 +538,7 @@ class KernelDebugKitObject:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# TODO: should we use the checksum from the API?
|
# TODO: should we use the checksum from the API?
|
||||||
result = subprocess.run(["hdiutil", "verify", self.constants.kdk_download_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
result = subprocess.run(["/usr/bin/hdiutil", "verify", self.constants.kdk_download_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Error: Kernel Debug Kit checksum verification failed!")
|
logging.info("Error: Kernel Debug Kit checksum verification failed!")
|
||||||
logging.info(f"Output: {result.stderr.decode('utf-8')}")
|
logging.info(f"Output: {result.stderr.decode('utf-8')}")
|
||||||
@@ -612,7 +612,7 @@ class KernelDebugKitUtilities:
|
|||||||
|
|
||||||
logging.info(f"Extracting downloaded KDK disk image")
|
logging.info(f"Extracting downloaded KDK disk image")
|
||||||
with tempfile.TemporaryDirectory() as mount_point:
|
with tempfile.TemporaryDirectory() as mount_point:
|
||||||
result = subprocess.run(["hdiutil", "attach", kdk_path, "-mountpoint", mount_point, "-nobrowse"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = subprocess.run(["/usr/bin/hdiutil", "attach", kdk_path, "-mountpoint", mount_point, "-nobrowse"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to mount KDK:")
|
logging.info("Failed to mount KDK:")
|
||||||
logging.info(result.stdout.decode('utf-8'))
|
logging.info(result.stdout.decode('utf-8'))
|
||||||
@@ -644,7 +644,7 @@ class KernelDebugKitUtilities:
|
|||||||
Parameters:
|
Parameters:
|
||||||
mount_point (Path): Path to mount point
|
mount_point (Path): Path to mount point
|
||||||
"""
|
"""
|
||||||
subprocess.run(["hdiutil", "detach", mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
subprocess.run(["/usr/bin/hdiutil", "detach", mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
|
||||||
def _create_backup(self, kdk_path: Path, kdk_info_plist: Path) -> None:
|
def _create_backup(self, kdk_path: Path, kdk_info_plist: Path) -> None:
|
||||||
@@ -674,7 +674,7 @@ class KernelDebugKitUtilities:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not Path(KDK_INSTALL_PATH).exists():
|
if not Path(KDK_INSTALL_PATH).exists():
|
||||||
subprocess.run(["mkdir", "-p", KDK_INSTALL_PATH], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
subprocess.run(["/bin/mkdir", "-p", KDK_INSTALL_PATH], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
kdk_dst_name = f"KDK_{kdk_info_dict['version']}_{kdk_info_dict['build']}.pkg"
|
kdk_dst_name = f"KDK_{kdk_info_dict['version']}_{kdk_info_dict['build']}.pkg"
|
||||||
kdk_dst_path = Path(f"{KDK_INSTALL_PATH}/{kdk_dst_name}")
|
kdk_dst_path = Path(f"{KDK_INSTALL_PATH}/{kdk_dst_name}")
|
||||||
@@ -684,7 +684,7 @@ class KernelDebugKitUtilities:
|
|||||||
logging.info("Backup already exists, skipping")
|
logging.info("Backup already exists, skipping")
|
||||||
return
|
return
|
||||||
|
|
||||||
result = utilities.elevated(["cp", "-R", kdk_path, kdk_dst_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = utilities.elevated(["/bin/cp", "-R", kdk_path, kdk_dst_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to create KDK backup:")
|
logging.info("Failed to create KDK backup:")
|
||||||
logging.info(result.stdout.decode('utf-8'))
|
logging.info(result.stdout.decode('utf-8'))
|
||||||
@@ -130,7 +130,7 @@ class InitializeLoggingSupport:
|
|||||||
]
|
]
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
result = subprocess.run(["chmod", "777", path], capture_output=True)
|
result = subprocess.run(["/bin/chmod", "777", path], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.error(f"Failed to fix log file permissions")
|
logging.error(f"Failed to fix log file permissions")
|
||||||
if result.stdout:
|
if result.stdout:
|
||||||
@@ -251,7 +251,7 @@ class InitializeLoggingSupport:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if cant_log is True:
|
if cant_log is True:
|
||||||
subprocess.run(["open", "--reveal", self.log_filepath])
|
subprocess.run(["/usr/bin/open", "--reveal", self.log_filepath])
|
||||||
return
|
return
|
||||||
|
|
||||||
threading.Thread(target=analytics_handler.Analytics(self.constants).send_crash_report, args=(self.log_filepath,)).start()
|
threading.Thread(target=analytics_handler.Analytics(self.constants).send_crash_report, args=(self.log_filepath,)).start()
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ class InstallerCreation():
|
|||||||
logging.info(f"Creating temporary directory at {ia_tmp}")
|
logging.info(f"Creating temporary directory at {ia_tmp}")
|
||||||
# Delete all files in tmp_dir
|
# Delete all files in tmp_dir
|
||||||
for file in Path(ia_tmp).glob("*"):
|
for file in Path(ia_tmp).glob("*"):
|
||||||
subprocess.run(["rm", "-rf", str(file)])
|
subprocess.run(["/bin/rm", "-rf", str(file)])
|
||||||
|
|
||||||
# Copy installer to tmp (use CoW to avoid extra disk writes)
|
# Copy installer to tmp (use CoW to avoid extra disk writes)
|
||||||
args = ["cp", "-cR", installer_path, ia_tmp]
|
args = ["/bin/cp", "-cR", installer_path, ia_tmp]
|
||||||
if utilities.check_filesystem_type() != "apfs":
|
if utilities.check_filesystem_type() != "apfs":
|
||||||
# HFS+ disks do not support CoW
|
# HFS+ disks do not support CoW
|
||||||
args[1] = "-R"
|
args[1] = "-R"
|
||||||
@@ -179,13 +179,13 @@ fi
|
|||||||
# TODO: AllDisksAndPartitions is not supported in Snow Leopard and older
|
# TODO: AllDisksAndPartitions is not supported in Snow Leopard and older
|
||||||
try:
|
try:
|
||||||
# High Sierra and newer
|
# High Sierra and newer
|
||||||
disks = plistlib.loads(subprocess.run("diskutil list -plist physical".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disks = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "list", "-plist", "physical"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Sierra and older
|
# Sierra and older
|
||||||
disks = plistlib.loads(subprocess.run("diskutil list -plist".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disks = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "list", "-plist"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
|
|
||||||
for disk in disks["AllDisksAndPartitions"]:
|
for disk in disks["AllDisksAndPartitions"]:
|
||||||
disk_info = plistlib.loads(subprocess.run(f"diskutil info -plist {disk['DeviceIdentifier']}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
disk_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", disk["DeviceIdentifier"]], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
try:
|
try:
|
||||||
all_disks[disk["DeviceIdentifier"]] = {"identifier": disk_info["DeviceNode"], "name": disk_info["MediaName"], "size": disk_info["TotalSize"], "removable": disk_info["Internal"], "partitions": {}}
|
all_disks[disk["DeviceIdentifier"]] = {"identifier": disk_info["DeviceNode"], "name": disk_info["MediaName"], "size": disk_info["TotalSize"], "removable": disk_info["Internal"], "partitions": {}}
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -407,7 +407,7 @@ class RemoteInstallerCatalog:
|
|||||||
})
|
})
|
||||||
|
|
||||||
available_apps = {k: v for k, v in sorted(available_apps.items(), key=lambda x: x[1]['Version'])}
|
available_apps = {k: v for k, v in sorted(available_apps.items(), key=lambda x: x[1]['Version'])}
|
||||||
|
|
||||||
return available_apps
|
return available_apps
|
||||||
|
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ class LocalInstallerCatalog:
|
|||||||
|
|
||||||
output = subprocess.run(
|
output = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "attach", "-noverify", sharedsupport_path,
|
"/usr/bin/hdiutil", "attach", "-noverify", sharedsupport_path,
|
||||||
"-mountpoint", tmpdir,
|
"-mountpoint", tmpdir,
|
||||||
"-nobrowse",
|
"-nobrowse",
|
||||||
],
|
],
|
||||||
@@ -644,6 +644,6 @@ class LocalInstallerCatalog:
|
|||||||
detected_os = plist["Assets"][0]["OSVersion"]
|
detected_os = plist["Assets"][0]["OSVersion"]
|
||||||
|
|
||||||
# Unmount SharedSupport.dmg
|
# Unmount SharedSupport.dmg
|
||||||
subprocess.run(["hdiutil", "detach", tmpdir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
subprocess.run(["/usr/bin/hdiutil", "detach", tmpdir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
return (detected_build, detected_os)
|
return (detected_build, detected_os)
|
||||||
@@ -44,7 +44,7 @@ class OSProbe:
|
|||||||
str: OS version (ex. 12.0)
|
str: OS version (ex. 12.0)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = subprocess.run(["sw_vers", "-productVersion"], stdout=subprocess.PIPE)
|
result = subprocess.run(["/usr/bin/sw_vers", "-productVersion"], stdout=subprocess.PIPE)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise RuntimeError("Failed to detect OS version")
|
raise RuntimeError("Failed to detect OS version")
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RoutePayloadDiskImage:
|
|||||||
self._unmount_active_dmgs(unmount_all_active=False)
|
self._unmount_active_dmgs(unmount_all_active=False)
|
||||||
output = subprocess.run(
|
output = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "attach", "-noverify", f"{self.constants.payload_path_dmg}",
|
"/usr/bin/hdiutil", "attach", "-noverify", f"{self.constants.payload_path_dmg}",
|
||||||
"-mountpoint", Path(self.temp_dir.name / Path("payloads")),
|
"-mountpoint", Path(self.temp_dir.name / Path("payloads")),
|
||||||
"-nobrowse",
|
"-nobrowse",
|
||||||
"-shadow", Path(self.temp_dir.name / Path("payloads_overlay")),
|
"-shadow", Path(self.temp_dir.name / Path("payloads_overlay")),
|
||||||
@@ -67,7 +67,7 @@ class RoutePayloadDiskImage:
|
|||||||
unmount_all_active (bool): If True, unmount all active DMGs, otherwise only unmount our own DMG
|
unmount_all_active (bool): If True, unmount all active DMGs, otherwise only unmount our own DMG
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dmg_info = subprocess.run(["hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
dmg_info = subprocess.run(["/usr/bin/hdiutil", "info", "-plist"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
dmg_info = plistlib.loads(dmg_info.stdout)
|
dmg_info = plistlib.loads(dmg_info.stdout)
|
||||||
|
|
||||||
|
|
||||||
@@ -80,12 +80,12 @@ class RoutePayloadDiskImage:
|
|||||||
if self.temp_dir.name in image["shadow-path"]:
|
if self.temp_dir.name in image["shadow-path"]:
|
||||||
logging.info(f"Unmounting personal {variant}")
|
logging.info(f"Unmounting personal {variant}")
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
["/usr/bin/hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logging.info(f"Unmounting {variant} at: {image['system-entities'][0]['dev-entry']}")
|
logging.info(f"Unmounting {variant} at: {image['system-entities'][0]['dev-entry']}")
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
["/usr/bin/hdiutil", "detach", image["system-entities"][0]["dev-entry"], "-force"],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
@@ -209,7 +209,7 @@ class PatchSysVolume:
|
|||||||
if save_hid_cs is True and cs_path.exists():
|
if save_hid_cs is True and cs_path.exists():
|
||||||
logging.info("- Backing up IOHIDEventDriver CodeSignature")
|
logging.info("- Backing up IOHIDEventDriver CodeSignature")
|
||||||
# Note it's a folder, not a file
|
# Note it's a folder, not a file
|
||||||
utilities.elevated(["cp", "-r", cs_path, f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["/bin/cp", "-r", cs_path, f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
logging.info(f"- Merging KDK with Root Volume: {kdk_path.name}")
|
logging.info(f"- Merging KDK with Root Volume: {kdk_path.name}")
|
||||||
utilities.elevated(
|
utilities.elevated(
|
||||||
@@ -230,9 +230,9 @@ class PatchSysVolume:
|
|||||||
logging.info("- Restoring IOHIDEventDriver CodeSignature")
|
logging.info("- Restoring IOHIDEventDriver CodeSignature")
|
||||||
if not cs_path.exists():
|
if not cs_path.exists():
|
||||||
logging.info(" - CodeSignature folder missing, creating")
|
logging.info(" - CodeSignature folder missing, creating")
|
||||||
utilities.elevated(["mkdir", "-p", cs_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["/bin/mkdir", "-p", cs_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
utilities.elevated(["cp", "-r", f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak", cs_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["/bin/cp", "-r", f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak", cs_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
utilities.elevated(["rm", "-rf", f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
utilities.elevated(["/bin/rm", "-rf", f"{self.constants.payload_path}/IOHIDEventDriver_CodeSignature.bak"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
|
||||||
def _unpatch_root_vol(self):
|
def _unpatch_root_vol(self):
|
||||||
@@ -369,7 +369,7 @@ class PatchSysVolume:
|
|||||||
|
|
||||||
if self.skip_root_kmutil_requirement is True:
|
if self.skip_root_kmutil_requirement is True:
|
||||||
# Force rebuild the Auxiliary KC
|
# Force rebuild the Auxiliary KC
|
||||||
result = utilities.elevated(["killall", "syspolicyd", "kernelmanagerd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = utilities.elevated(["/usr/bin/killall", "syspolicyd", "kernelmanagerd"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("- Unable to remove kernel extension policy files")
|
logging.info("- Unable to remove kernel extension policy files")
|
||||||
logging.info(f"\nReason for Patch Failure ({result.returncode}):")
|
logging.info(f"\nReason for Patch Failure ({result.returncode}):")
|
||||||
@@ -422,7 +422,7 @@ class PatchSysVolume:
|
|||||||
"""
|
"""
|
||||||
if self.root_mount_path:
|
if self.root_mount_path:
|
||||||
logging.info("- Unmounting Root Volume (Don't worry if this fails)")
|
logging.info("- Unmounting Root Volume (Don't worry if this fails)")
|
||||||
utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
utilities.elevated(["/usr/sbin/diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode()
|
||||||
else:
|
else:
|
||||||
logging.info("- Skipping Root Volume unmount")
|
logging.info("- Skipping Root Volume unmount")
|
||||||
|
|
||||||
@@ -457,11 +457,11 @@ class PatchSysVolume:
|
|||||||
|
|
||||||
if (Path(self.mount_application_support) / Path("SkyLightPlugins/")).exists():
|
if (Path(self.mount_application_support) / Path("SkyLightPlugins/")).exists():
|
||||||
logging.info("- Found SkylightPlugins folder, removing old plugins")
|
logging.info("- Found SkylightPlugins folder, removing old plugins")
|
||||||
utilities.process_status(utilities.elevated(["rm", "-Rf", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", "-Rf", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
utilities.process_status(utilities.elevated(["mkdir", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/mkdir", f"{self.mount_application_support}/SkyLightPlugins"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
else:
|
else:
|
||||||
logging.info("- Creating SkylightPlugins folder")
|
logging.info("- Creating SkylightPlugins folder")
|
||||||
utilities.process_status(utilities.elevated(["mkdir", "-p", f"{self.mount_application_support}/SkyLightPlugins/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/mkdir", "-p", f"{self.mount_application_support}/SkyLightPlugins/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
|
|
||||||
def _delete_nonmetal_enforcement(self) -> None:
|
def _delete_nonmetal_enforcement(self) -> None:
|
||||||
@@ -471,10 +471,10 @@ class PatchSysVolume:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for arg in ["useMetal", "useIOP"]:
|
for arg in ["useMetal", "useIOP"]:
|
||||||
result = subprocess.run(["defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", arg], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode("utf-8").strip()
|
result = subprocess.run(["/usr/bin/defaults", "read", "/Library/Preferences/com.apple.CoreDisplay", arg], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode("utf-8").strip()
|
||||||
if result in ["0", "false", "1", "true"]:
|
if result in ["0", "false", "1", "true"]:
|
||||||
logging.info(f"- Removing non-Metal Enforcement Preference: {arg}")
|
logging.info(f"- Removing non-Metal Enforcement Preference: {arg}")
|
||||||
utilities.elevated(["defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", arg])
|
utilities.elevated(["/usr/bin/defaults", "delete", "/Library/Preferences/com.apple.CoreDisplay", arg])
|
||||||
|
|
||||||
|
|
||||||
def _clean_auxiliary_kc(self) -> None:
|
def _clean_auxiliary_kc(self) -> None:
|
||||||
@@ -516,15 +516,15 @@ class PatchSysVolume:
|
|||||||
|
|
||||||
relocation_path = "/Library/Relocated Extensions"
|
relocation_path = "/Library/Relocated Extensions"
|
||||||
if not Path(relocation_path).exists():
|
if not Path(relocation_path).exists():
|
||||||
utilities.elevated(["mkdir", relocation_path])
|
utilities.elevated(["/bin/mkdir", relocation_path])
|
||||||
|
|
||||||
for file in Path("/Library/Extensions").glob("*.kext"):
|
for file in Path("/Library/Extensions").glob("*.kext"):
|
||||||
try:
|
try:
|
||||||
if datetime.fromtimestamp(file.stat().st_mtime) < datetime(2021, 10, 1):
|
if datetime.fromtimestamp(file.stat().st_mtime) < datetime(2021, 10, 1):
|
||||||
logging.info(f" - Relocating {file.name} kext to {relocation_path}")
|
logging.info(f" - Relocating {file.name} kext to {relocation_path}")
|
||||||
if Path(relocation_path) / Path(file.name).exists():
|
if Path(relocation_path) / Path(file.name).exists():
|
||||||
utilities.elevated(["rm", "-Rf", relocation_path / Path(file.name)])
|
utilities.elevated(["/bin/rm", "-Rf", relocation_path / Path(file.name)])
|
||||||
utilities.elevated(["mv", file, relocation_path])
|
utilities.elevated(["/bin/mv", file, relocation_path])
|
||||||
except:
|
except:
|
||||||
# Some users have the most cursed /L*/E* folders
|
# Some users have the most cursed /L*/E* folders
|
||||||
# ex. Symlinks pointing to symlinks pointing to dead files
|
# ex. Symlinks pointing to symlinks pointing to dead files
|
||||||
@@ -545,8 +545,8 @@ class PatchSysVolume:
|
|||||||
if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path):
|
if sys_patch_helpers.SysPatchHelpers(self.constants).generate_patchset_plist(patchset, file_name, self.kdk_path):
|
||||||
logging.info("- Writing patchset information to Root Volume")
|
logging.info("- Writing patchset information to Root Volume")
|
||||||
if Path(destination_path_file).exists():
|
if Path(destination_path_file).exists():
|
||||||
utilities.process_status(utilities.elevated(["rm", destination_path_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", destination_path_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
utilities.process_status(utilities.elevated(["cp", f"{self.constants.payload_path}/{file_name}", destination_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/cp", f"{self.constants.payload_path}/{file_name}", destination_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
|
|
||||||
def _add_auxkc_support(self, install_file: str, source_folder_path: str, install_patch_directory: str, destination_folder_path: str) -> str:
|
def _add_auxkc_support(self, install_file: str, source_folder_path: str, install_patch_directory: str, destination_folder_path: str) -> str:
|
||||||
@@ -792,19 +792,19 @@ class PatchSysVolume:
|
|||||||
# Applicable for .kext, .app, .plugin, .bundle, all of which are directories
|
# Applicable for .kext, .app, .plugin, .bundle, all of which are directories
|
||||||
if Path(destination_folder + "/" + file_name).exists():
|
if Path(destination_folder + "/" + file_name).exists():
|
||||||
logging.info(f" - Found existing {file_name}, overwriting...")
|
logging.info(f" - Found existing {file_name}, overwriting...")
|
||||||
utilities.process_status(utilities.elevated(["rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
else:
|
else:
|
||||||
logging.info(f" - Installing: {file_name}")
|
logging.info(f" - Installing: {file_name}")
|
||||||
utilities.process_status(utilities.elevated(["cp", "-R", f"{source_folder}/{file_name}", destination_folder], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/cp", "-R", f"{source_folder}/{file_name}", destination_folder], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
self._fix_permissions(destination_folder + "/" + file_name)
|
self._fix_permissions(destination_folder + "/" + file_name)
|
||||||
else:
|
else:
|
||||||
# Assume it's an individual file, replace as normal
|
# Assume it's an individual file, replace as normal
|
||||||
if Path(destination_folder + "/" + file_name).exists():
|
if Path(destination_folder + "/" + file_name).exists():
|
||||||
logging.info(f" - Found existing {file_name}, overwriting...")
|
logging.info(f" - Found existing {file_name}, overwriting...")
|
||||||
utilities.process_status(utilities.elevated(["rm", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
else:
|
else:
|
||||||
logging.info(f" - Installing: {file_name}")
|
logging.info(f" - Installing: {file_name}")
|
||||||
utilities.process_status(utilities.elevated(["cp", f"{source_folder}/{file_name}", destination_folder], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/cp", f"{source_folder}/{file_name}", destination_folder], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
self._fix_permissions(destination_folder + "/" + file_name)
|
self._fix_permissions(destination_folder + "/" + file_name)
|
||||||
|
|
||||||
|
|
||||||
@@ -820,9 +820,9 @@ class PatchSysVolume:
|
|||||||
if Path(destination_folder + "/" + file_name).exists():
|
if Path(destination_folder + "/" + file_name).exists():
|
||||||
logging.info(f" - Removing: {file_name}")
|
logging.info(f" - Removing: {file_name}")
|
||||||
if Path(destination_folder + "/" + file_name).is_dir():
|
if Path(destination_folder + "/" + file_name).is_dir():
|
||||||
utilities.process_status(utilities.elevated(["rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", "-R", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
else:
|
else:
|
||||||
utilities.process_status(utilities.elevated(["rm", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", f"{destination_folder}/{file_name}"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
|
|
||||||
def _fix_permissions(self, destination_file: Path) -> None:
|
def _fix_permissions(self, destination_file: Path) -> None:
|
||||||
@@ -857,7 +857,7 @@ class PatchSysVolume:
|
|||||||
|
|
||||||
output = subprocess.run(
|
output = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "attach", "-noverify", f"{self.constants.payload_local_binaries_root_path_dmg}",
|
"/usr/bin/hdiutil", "attach", "-noverify", f"{self.constants.payload_local_binaries_root_path_dmg}",
|
||||||
"-mountpoint", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
"-mountpoint", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
||||||
"-nobrowse",
|
"-nobrowse",
|
||||||
"-shadow", Path(self.constants.payload_path / Path("Universal-Binaries_overlay")),
|
"-shadow", Path(self.constants.payload_path / Path("Universal-Binaries_overlay")),
|
||||||
@@ -890,7 +890,7 @@ class PatchSysVolume:
|
|||||||
|
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "attach", "-noverify", f"{self.constants.overlay_psp_path_dmg}",
|
"/usr/bin/hdiutil", "attach", "-noverify", f"{self.constants.overlay_psp_path_dmg}",
|
||||||
"-mountpoint", Path(self.constants.payload_path / Path("DortaniaInternal")),
|
"-mountpoint", Path(self.constants.payload_path / Path("DortaniaInternal")),
|
||||||
"-nobrowse",
|
"-nobrowse",
|
||||||
"-passphrase", password
|
"-passphrase", password
|
||||||
@@ -901,7 +901,7 @@ class PatchSysVolume:
|
|||||||
logging.info("- Mounted DortaniaInternal resources")
|
logging.info("- Mounted DortaniaInternal resources")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[
|
[
|
||||||
"ditto", f"{self.constants.payload_path / Path('DortaniaInternal')}", f"{self.constants.payload_path / Path('Universal-Binaries')}"
|
"/usr/bin/ditto", f"{self.constants.payload_path / Path('DortaniaInternal')}", f"{self.constants.payload_path / Path('Universal-Binaries')}"
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ Please check the Github page for more information about this release."""
|
|||||||
warning_str = f"""\n\nWARNING: We're unable to verify whether there are any new releases of OpenCore Legacy Patcher on Github. Be aware that you may be using an outdated version for this OS. If you're unsure, verify on Github that OpenCore Legacy Patcher {self.constants.patcher_version} is the latest official release"""
|
warning_str = f"""\n\nWARNING: We're unable to verify whether there are any new releases of OpenCore Legacy Patcher on Github. Be aware that you may be using an outdated version for this OS. If you're unsure, verify on Github that OpenCore Legacy Patcher {self.constants.patcher_version} is the latest official release"""
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"/usr/bin/osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f"""display dialog "OpenCore Legacy Patcher has detected you're running without Root Patches, and would like to install them.\n\nmacOS wipes all root patches during OS installs and updates, so they need to be reinstalled.\n\nFollowing Patches have been detected for your system: \n{patch_string}\nWould you like to apply these patches?{warning_str}" """
|
f"""display dialog "OpenCore Legacy Patcher has detected you're running without Root Patches, and would like to install them.\n\nmacOS wipes all root patches during OS installs and updates, so they need to be reinstalled.\n\nFollowing Patches have been detected for your system: \n{patch_string}\nWould you like to apply these patches?{warning_str}" """
|
||||||
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
||||||
@@ -182,7 +182,7 @@ Please check the Github page for more information about this release."""
|
|||||||
)
|
)
|
||||||
if output.returncode == 0:
|
if output.returncode == 0:
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"/usr/bin/osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f'''do shell script "{args_string}"'''
|
f'''do shell script "{args_string}"'''
|
||||||
f' with prompt "OpenCore Legacy Patcher would like to patch your root volume"'
|
f' with prompt "OpenCore Legacy Patcher would like to patch your root volume"'
|
||||||
@@ -238,7 +238,7 @@ Please check the Github page for more information about this release."""
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"/usr/bin/osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting {'a different' if self.constants.special_build else 'an outdated'} OpenCore build\n- Booted: {self.constants.computer.oclp_version}\n- Installed: {self.constants.patcher_version}\n\nWould you like to update the OpenCore bootloader?" """
|
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting {'a different' if self.constants.special_build else 'an outdated'} OpenCore build\n- Booted: {self.constants.computer.oclp_version}\n- Installed: {self.constants.patcher_version}\n\nWould you like to update the OpenCore bootloader?" """
|
||||||
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
||||||
@@ -304,7 +304,7 @@ Please check the Github page for more information about this release."""
|
|||||||
# Check if OpenCore is on a USB drive
|
# Check if OpenCore is on a USB drive
|
||||||
logging.info("- Boot Drive does not match macOS drive, checking if OpenCore is on a USB drive")
|
logging.info("- Boot Drive does not match macOS drive, checking if OpenCore is on a USB drive")
|
||||||
|
|
||||||
disk_info = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", root_disk], stdout=subprocess.PIPE).stdout)
|
disk_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", root_disk], stdout=subprocess.PIPE).stdout)
|
||||||
try:
|
try:
|
||||||
if disk_info["Ejectable"] is False:
|
if disk_info["Ejectable"] is False:
|
||||||
logging.info("- Boot Disk is not removable, skipping prompt")
|
logging.info("- Boot Disk is not removable, skipping prompt")
|
||||||
@@ -313,7 +313,7 @@ Please check the Github page for more information about this release."""
|
|||||||
logging.info("- Boot Disk is ejectable, prompting user to install to internal")
|
logging.info("- Boot Disk is ejectable, prompting user to install to internal")
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"/usr/bin/osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting OpenCore from an USB or External drive.\n\nIf you would like to boot your Mac normally without a USB drive plugged in, you can install OpenCore to the internal hard drive.\n\nWould you like to launch OpenCore Legacy Patcher and install to disk?" """
|
f"""display dialog "OpenCore Legacy Patcher has detected that you are booting OpenCore from an USB or External drive.\n\nIf you would like to boot your Mac normally without a USB drive plugged in, you can install OpenCore to the internal hard drive.\n\nWould you like to launch OpenCore Legacy Patcher and install to disk?" """
|
||||||
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
f'with icon POSIX file "{self.constants.app_icon_path}"',
|
||||||
@@ -362,12 +362,12 @@ Please check the Github page for more information about this release."""
|
|||||||
logging.info(f" - {name} checksums match, skipping")
|
logging.info(f" - {name} checksums match, skipping")
|
||||||
continue
|
continue
|
||||||
logging.info(f" - Existing service found, removing")
|
logging.info(f" - Existing service found, removing")
|
||||||
utilities.process_status(utilities.elevated(["rm", services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
# Create parent directories
|
# Create parent directories
|
||||||
if not Path(services[service]).parent.exists():
|
if not Path(services[service]).parent.exists():
|
||||||
logging.info(f" - Creating {Path(services[service]).parent} directory")
|
logging.info(f" - Creating {Path(services[service]).parent} directory")
|
||||||
utilities.process_status(utilities.elevated(["mkdir", "-p", Path(services[service]).parent], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/mkdir", "-p", Path(services[service]).parent], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
utilities.process_status(utilities.elevated(["cp", service, services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/cp", service, services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
# Set the permissions on the service
|
# Set the permissions on the service
|
||||||
utilities.process_status(utilities.elevated(["chmod", "644", services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["chmod", "644", services[service]], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
@@ -383,33 +383,33 @@ Please check the Github page for more information about this release."""
|
|||||||
|
|
||||||
if not Path("Library/Application Support/Dortania").exists():
|
if not Path("Library/Application Support/Dortania").exists():
|
||||||
logging.info("- Creating /Library/Application Support/Dortania/")
|
logging.info("- Creating /Library/Application Support/Dortania/")
|
||||||
utilities.process_status(utilities.elevated(["mkdir", "-p", "/Library/Application Support/Dortania"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/mkdir", "-p", "/Library/Application Support/Dortania"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
logging.info("- Copying OpenCore Patcher to /Library/Application Support/Dortania/")
|
logging.info("- Copying OpenCore Patcher to /Library/Application Support/Dortania/")
|
||||||
if Path("/Library/Application Support/Dortania/OpenCore-Patcher.app").exists():
|
if Path("/Library/Application Support/Dortania/OpenCore-Patcher.app").exists():
|
||||||
logging.info("- Deleting existing OpenCore-Patcher")
|
logging.info("- Deleting existing OpenCore-Patcher")
|
||||||
utilities.process_status(utilities.elevated(["rm", "-R", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/rm", "-R", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
# Strip everything after OpenCore-Patcher.app
|
# Strip everything after OpenCore-Patcher.app
|
||||||
path = str(self.constants.launcher_binary).split("/Contents/MacOS/OpenCore-Patcher")[0]
|
path = str(self.constants.launcher_binary).split("/Contents/MacOS/OpenCore-Patcher")[0]
|
||||||
logging.info(f"- Copying {path} to /Library/Application Support/Dortania/")
|
logging.info(f"- Copying {path} to /Library/Application Support/Dortania/")
|
||||||
utilities.process_status(utilities.elevated(["ditto", path, "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/usr/bin/ditto", path, "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
if not Path("/Library/Application Support/Dortania/OpenCore-Patcher.app").exists():
|
if not Path("/Library/Application Support/Dortania/OpenCore-Patcher.app").exists():
|
||||||
# Sometimes the binary the user launches may have a suffix (ie. OpenCore-Patcher 3.app)
|
# Sometimes the binary the user launches may have a suffix (ie. OpenCore-Patcher 3.app)
|
||||||
# We'll want to rename it to OpenCore-Patcher.app
|
# We'll want to rename it to OpenCore-Patcher.app
|
||||||
path = path.split("/")[-1]
|
path = path.split("/")[-1]
|
||||||
logging.info(f"- Renaming {path} to OpenCore-Patcher.app")
|
logging.info(f"- Renaming {path} to OpenCore-Patcher.app")
|
||||||
utilities.process_status(utilities.elevated(["mv", f"/Library/Application Support/Dortania/{path}", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/mv", f"/Library/Application Support/Dortania/{path}", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
subprocess.run(["xattr", "-cr", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
subprocess.run(["/usr/bin/xattr", "-cr", "/Library/Application Support/Dortania/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
# Making app alias
|
# Making app alias
|
||||||
# Simply an easy way for users to notice the app
|
# Simply an easy way for users to notice the app
|
||||||
# If there's already an alias or exiting app, skip
|
# If there's already an alias or exiting app, skip
|
||||||
if not Path("/Applications/OpenCore-Patcher.app").exists():
|
if not Path("/Applications/OpenCore-Patcher.app").exists():
|
||||||
logging.info("- Making app alias")
|
logging.info("- Making app alias")
|
||||||
utilities.process_status(utilities.elevated(["ln", "-s", "/Library/Application Support/Dortania/OpenCore-Patcher.app", "/Applications/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/ln", "-s", "/Library/Application Support/Dortania/OpenCore-Patcher.app", "/Applications/OpenCore-Patcher.app"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
|
|
||||||
def _create_rsr_monitor_daemon(self) -> bool:
|
def _create_rsr_monitor_daemon(self) -> bool:
|
||||||
@@ -444,7 +444,7 @@ Please check the Github page for more information about this release."""
|
|||||||
# Load the RSRMonitor plist
|
# Load the RSRMonitor plist
|
||||||
rsr_monitor_plist = plistlib.load(open(self.constants.rsr_monitor_launch_daemon_path, "rb"))
|
rsr_monitor_plist = plistlib.load(open(self.constants.rsr_monitor_launch_daemon_path, "rb"))
|
||||||
|
|
||||||
arguments = ["rm", "-Rfv"]
|
arguments = ["/bin/rm", "-Rfv"]
|
||||||
arguments += [f"/Library/Extensions/{kext}" for kext in kexts]
|
arguments += [f"/Library/Extensions/{kext}" for kext in kexts]
|
||||||
|
|
||||||
# Add the arguments to the RSRMonitor plist
|
# Add the arguments to the RSRMonitor plist
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ class SysPatchHelpers:
|
|||||||
if did_find:
|
if did_find:
|
||||||
with open(file_path, "wb") as f:
|
with open(file_path, "wb") as f:
|
||||||
plistlib.dump(data, f, sort_keys=False)
|
plistlib.dump(data, f, sort_keys=False)
|
||||||
subprocess.run(["killall", "NotificationCenter"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
subprocess.run(["/usr/bin/killall", "NotificationCenter"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
|
||||||
def install_rsr_repair_binary(self):
|
def install_rsr_repair_binary(self):
|
||||||
@@ -274,6 +274,6 @@ class SysPatchHelpers:
|
|||||||
|
|
||||||
src_dir = f"{LIBRARY_DIR}/{file.name}"
|
src_dir = f"{LIBRARY_DIR}/{file.name}"
|
||||||
if not Path(f"{DEST_DIR}/lib").exists():
|
if not Path(f"{DEST_DIR}/lib").exists():
|
||||||
utilities.process_status(utilities.elevated(["cp", "-cR", f"{src_dir}/lib", f"{DEST_DIR}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
utilities.process_status(utilities.elevated(["/bin/cp", "-cR", f"{src_dir}/lib", f"{DEST_DIR}/"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
|
||||||
|
|
||||||
break
|
break
|
||||||
+18
-18
@@ -108,13 +108,14 @@ def check_recovery():
|
|||||||
|
|
||||||
|
|
||||||
def get_disk_path():
|
def get_disk_path():
|
||||||
root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
root_partition_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
root_mount_path = root_partition_info["DeviceIdentifier"]
|
root_mount_path = root_partition_info["DeviceIdentifier"]
|
||||||
root_mount_path = root_mount_path[:-2] if root_mount_path.count("s") > 1 else root_mount_path
|
root_mount_path = root_mount_path[:-2] if root_mount_path.count("s") > 1 else root_mount_path
|
||||||
return root_mount_path
|
return root_mount_path
|
||||||
|
|
||||||
|
|
||||||
def check_if_root_is_apfs_snapshot():
|
def check_if_root_is_apfs_snapshot():
|
||||||
root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
root_partition_info = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
try:
|
try:
|
||||||
is_snapshotted = root_partition_info["APFSSnapshot"]
|
is_snapshotted = root_partition_info["APFSSnapshot"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -124,7 +125,7 @@ def check_if_root_is_apfs_snapshot():
|
|||||||
|
|
||||||
def check_seal():
|
def check_seal():
|
||||||
# 'Snapshot Sealed' property is only listed on booted snapshots
|
# 'Snapshot Sealed' property is only listed on booted snapshots
|
||||||
sealed = subprocess.run(["diskutil", "apfs", "list"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
sealed = subprocess.run(["/usr/sbin/diskutil", "apfs", "list"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if "Snapshot Sealed: Yes" in sealed.stdout.decode():
|
if "Snapshot Sealed: Yes" in sealed.stdout.decode():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -132,7 +133,7 @@ def check_seal():
|
|||||||
|
|
||||||
def check_filesystem_type():
|
def check_filesystem_type():
|
||||||
# Expected to return 'apfs' or 'hfs'
|
# Expected to return 'apfs' or 'hfs'
|
||||||
filesystem_type = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
filesystem_type = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", "/"], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
return filesystem_type["FilesystemType"]
|
return filesystem_type["FilesystemType"]
|
||||||
|
|
||||||
|
|
||||||
@@ -186,10 +187,10 @@ def check_kext_loaded(bundle_id: str) -> str:
|
|||||||
# no UUID for kextstat
|
# no UUID for kextstat
|
||||||
pattern = re.compile(re.escape(bundle_id) + r"\s+\((?P<version>.+)\)")
|
pattern = re.compile(re.escape(bundle_id) + r"\s+\((?P<version>.+)\)")
|
||||||
|
|
||||||
args = ["kextstat", "-l", "-b", bundle_id]
|
args = ["/usr/sbin/kextstat", "-list-only", "-bundle-id", bundle_id]
|
||||||
|
|
||||||
if Path("/usr/bin/kmutil").exists():
|
if Path("/usr/bin/kmutil").exists():
|
||||||
args = ["kmutil", "showloaded", "--list-only", "--variant-suffix", "release", "--optional-identifier", bundle_id]
|
args = ["/usr/bin/kmutil", "showloaded", "--list-only", "--variant-suffix", "release", "--optional-identifier", bundle_id]
|
||||||
|
|
||||||
kext_loaded = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
kext_loaded = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if kext_loaded.returncode != 0:
|
if kext_loaded.returncode != 0:
|
||||||
@@ -213,7 +214,7 @@ def check_oclp_boot():
|
|||||||
def check_monterey_wifi():
|
def check_monterey_wifi():
|
||||||
IO80211ElCap = "com.apple.iokit.IO80211ElCap"
|
IO80211ElCap = "com.apple.iokit.IO80211ElCap"
|
||||||
CoreCaptureElCap = "com.apple.driver.corecaptureElCap"
|
CoreCaptureElCap = "com.apple.driver.corecaptureElCap"
|
||||||
loaded_kexts: str = subprocess.run("kextcache".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
|
loaded_kexts: str = subprocess.run(["/usr/sbin/kextcache"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
|
||||||
if IO80211ElCap in loaded_kexts and CoreCaptureElCap in loaded_kexts:
|
if IO80211ElCap in loaded_kexts and CoreCaptureElCap in loaded_kexts:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -307,7 +308,7 @@ def patching_status(os_sip, os):
|
|||||||
|
|
||||||
if os > os_data.os_data.catalina and not check_filevault_skip():
|
if os > os_data.os_data.catalina and not check_filevault_skip():
|
||||||
# Assume non-OCLP Macs do not have our APFS seal patch
|
# Assume non-OCLP Macs do not have our APFS seal patch
|
||||||
fv_status: str = subprocess.run("fdesetup status".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
|
fv_status: str = subprocess.run(["/usr/bin/fdesetup", "status"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
|
||||||
if "FileVault is Off" in fv_status:
|
if "FileVault is Off" in fv_status:
|
||||||
fv_enabled = False
|
fv_enabled = False
|
||||||
else:
|
else:
|
||||||
@@ -340,8 +341,7 @@ def cls():
|
|||||||
|
|
||||||
def check_command_line_tools():
|
def check_command_line_tools():
|
||||||
# Determine whether Command Line Tools exist
|
# Determine whether Command Line Tools exist
|
||||||
# xcode-select -p
|
xcode_select = subprocess.run(["/usr/bin/xcode-select", "--print-path"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
xcode_select = subprocess.run("xcode-select -p".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
||||||
if xcode_select.returncode == 0:
|
if xcode_select.returncode == 0:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -420,7 +420,7 @@ def find_apfs_physical_volume(device):
|
|||||||
disk_list = None
|
disk_list = None
|
||||||
physical_disks = []
|
physical_disks = []
|
||||||
try:
|
try:
|
||||||
disk_list = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", device], stdout=subprocess.PIPE).stdout)
|
disk_list = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", device], stdout=subprocess.PIPE).stdout)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ def find_disk_off_uuid(uuid):
|
|||||||
# Find disk by UUID
|
# Find disk by UUID
|
||||||
disk_list = None
|
disk_list = None
|
||||||
try:
|
try:
|
||||||
disk_list = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", uuid], stdout=subprocess.PIPE).stdout)
|
disk_list = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", uuid], stdout=subprocess.PIPE).stdout)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
if disk_list:
|
if disk_list:
|
||||||
@@ -492,12 +492,12 @@ def get_free_space(disk=None):
|
|||||||
return free
|
return free
|
||||||
|
|
||||||
def grab_mount_point_from_disk(disk):
|
def grab_mount_point_from_disk(disk):
|
||||||
data = plistlib.loads(subprocess.run(f"diskutil info -plist {disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
data = plistlib.loads(subprocess.run(["/usr/sbin/diskutil", "info", "-plist", disk], stdout=subprocess.PIPE).stdout.decode().strip().encode())
|
||||||
return data["MountPoint"]
|
return data["MountPoint"]
|
||||||
|
|
||||||
def monitor_disk_output(disk):
|
def monitor_disk_output(disk):
|
||||||
# Returns MB written on drive
|
# Returns MB written on drive
|
||||||
output = subprocess.check_output(["iostat", "-Id", disk])
|
output = subprocess.check_output(["/usr/sbin/iostat", "-Id", disk])
|
||||||
output = output.decode("utf-8")
|
output = output.decode("utf-8")
|
||||||
# Grab second last entry (last is \n)
|
# Grab second last entry (last is \n)
|
||||||
output = output.split(" ")
|
output = output.split(" ")
|
||||||
@@ -509,7 +509,7 @@ def get_preboot_uuid() -> str:
|
|||||||
"""
|
"""
|
||||||
Get the UUID of the Preboot volume
|
Get the UUID of the Preboot volume
|
||||||
"""
|
"""
|
||||||
args = ["ioreg", "-a", "-n", "chosen", "-p", "IODeviceTree", "-r"]
|
args = ["/usr/sbin/ioreg", "-a", "-n", "chosen", "-p", "IODeviceTree", "-r"]
|
||||||
output = plistlib.loads(subprocess.run(args, stdout=subprocess.PIPE).stdout)
|
output = plistlib.loads(subprocess.run(args, stdout=subprocess.PIPE).stdout)
|
||||||
return output[0]["apfs-preboot-uuid"].strip(b"\0").decode()
|
return output[0]["apfs-preboot-uuid"].strip(b"\0").decode()
|
||||||
|
|
||||||
@@ -533,13 +533,13 @@ def block_os_updaters():
|
|||||||
if bad_process in current_process:
|
if bad_process in current_process:
|
||||||
if pid != "":
|
if pid != "":
|
||||||
logging.info(f"Killing Process: {pid} - {current_process.split('/')[-1]}")
|
logging.info(f"Killing Process: {pid} - {current_process.split('/')[-1]}")
|
||||||
subprocess.run(["kill", "-9", pid])
|
subprocess.run(["/bin/kill", "-9", pid])
|
||||||
break
|
break
|
||||||
|
|
||||||
def check_boot_mode():
|
def check_boot_mode():
|
||||||
# Check whether we're in Safe Mode or not
|
# Check whether we're in Safe Mode or not
|
||||||
try:
|
try:
|
||||||
sys_plist = plistlib.loads(subprocess.run(["system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout)
|
sys_plist = plistlib.loads(subprocess.run(["/usr/sbin/system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout)
|
||||||
return sys_plist[0]["_items"][0]["boot_mode"]
|
return sys_plist[0]["_items"][0]["boot_mode"]
|
||||||
except (KeyError, TypeError, plistlib.InvalidFileException):
|
except (KeyError, TypeError, plistlib.InvalidFileException):
|
||||||
return None
|
return None
|
||||||
@@ -550,7 +550,7 @@ def elevated(*args, **kwargs) -> subprocess.CompletedProcess:
|
|||||||
if os.getuid() == 0 or check_cli_args() is not None:
|
if os.getuid() == 0 or check_cli_args() is not None:
|
||||||
return subprocess.run(*args, **kwargs)
|
return subprocess.run(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return subprocess.run(["sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
return subprocess.run(["/usr/bin/sudo"] + [args[0][0]] + args[0][1:], **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def fetch_staged_update(variant: str = "Update") -> (str, str):
|
def fetch_staged_update(variant: str = "Update") -> (str, str):
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class PatcherValidation:
|
|||||||
logging.info("Validating Root Patch File integrity")
|
logging.info("Validating Root Patch File integrity")
|
||||||
output = subprocess.run(
|
output = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "attach", "-noverify", f"{self.constants.payload_local_binaries_root_path_dmg}",
|
"/usr/bin/hdiutil", "attach", "-noverify", f"{self.constants.payload_local_binaries_root_path_dmg}",
|
||||||
"-mountpoint", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
"-mountpoint", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
||||||
"-nobrowse",
|
"-nobrowse",
|
||||||
"-shadow", Path(self.constants.payload_path / Path("Universal-Binaries_overlay")),
|
"-shadow", Path(self.constants.payload_path / Path("Universal-Binaries_overlay")),
|
||||||
@@ -172,7 +172,7 @@ class PatcherValidation:
|
|||||||
# unmount the dmg
|
# unmount the dmg
|
||||||
output = subprocess.run(
|
output = subprocess.run(
|
||||||
[
|
[
|
||||||
"hdiutil", "detach", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
"/usr/bin/hdiutil", "detach", Path(self.constants.payload_path / Path("Universal-Binaries")),
|
||||||
"-force"
|
"-force"
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
@@ -187,7 +187,7 @@ class PatcherValidation:
|
|||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"rm", "-f", Path(self.constants.payload_path / Path("Universal-Binaries_overlay"))
|
"/bin/rm", "-f", Path(self.constants.payload_path / Path("Universal-Binaries_overlay"))
|
||||||
],
|
],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
@@ -222,4 +222,4 @@ class PatcherValidation:
|
|||||||
self._build_prebuilt()
|
self._build_prebuilt()
|
||||||
self._build_dumps()
|
self._build_dumps()
|
||||||
|
|
||||||
subprocess.run(["rm", "-rf", self.constants.build_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
subprocess.run(["/bin/rm", "-rf", self.constants.build_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
@@ -428,8 +428,8 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
if not str(path).endswith(".zip"):
|
if not str(path).endswith(".zip"):
|
||||||
return
|
return
|
||||||
if Path(self.constants.installer_pkg_path).exists():
|
if Path(self.constants.installer_pkg_path).exists():
|
||||||
subprocess.run(["rm", self.constants.installer_pkg_path])
|
subprocess.run(["/bin/rm", self.constants.installer_pkg_path])
|
||||||
subprocess.run(["ditto", "-V", "-x", "-k", "--sequesterRsrc", "--rsrc", self.constants.installer_pkg_zip_path, self.constants.payload_path])
|
subprocess.run(["/usr/bin/ditto", "-V", "-x", "-k", "--sequesterRsrc", "--rsrc", self.constants.installer_pkg_zip_path, self.constants.payload_path])
|
||||||
|
|
||||||
|
|
||||||
def _install_installer_pkg(self, disk):
|
def _install_installer_pkg(self, disk):
|
||||||
@@ -448,8 +448,8 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
logging.info("Installer unsupported, requires Big Sur or newer")
|
logging.info("Installer unsupported, requires Big Sur or newer")
|
||||||
return
|
return
|
||||||
|
|
||||||
subprocess.run(["mkdir", "-p", f"{path}/Library/Packages/"])
|
subprocess.run(["/bin/mkdir", "-p", f"{path}/Library/Packages/"])
|
||||||
subprocess.run(["cp", "-r", self.constants.installer_pkg_path, f"{path}/Library/Packages/"])
|
subprocess.run(["/bin/cp", "-r", self.constants.installer_pkg_path, f"{path}/Library/Packages/"])
|
||||||
|
|
||||||
self._kdk_chainload(os_version["ProductBuildVersion"], os_version["ProductVersion"], Path(path + "/Library/Packages/"))
|
self._kdk_chainload(os_version["ProductBuildVersion"], os_version["ProductVersion"], Path(path + "/Library/Packages/"))
|
||||||
|
|
||||||
@@ -512,17 +512,17 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
# Now that we have a KDK, extract it to get the pkg
|
# Now that we have a KDK, extract it to get the pkg
|
||||||
with tempfile.TemporaryDirectory() as mount_point:
|
with tempfile.TemporaryDirectory() as mount_point:
|
||||||
logging.info("Mounting KDK")
|
logging.info("Mounting KDK")
|
||||||
result = subprocess.run(["hdiutil", "attach", kdk_dmg_path, "-mountpoint", mount_point, "-nobrowse"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = subprocess.run(["/usr/bin/hdiutil", "attach", kdk_dmg_path, "-mountpoint", mount_point, "-nobrowse"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to mount KDK")
|
logging.info("Failed to mount KDK")
|
||||||
logging.info(result.stdout.decode("utf-8"))
|
logging.info(result.stdout.decode("utf-8"))
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.info("Copying KDK")
|
logging.info("Copying KDK")
|
||||||
subprocess.run(["cp", "-r", f"{mount_point}/KernelDebugKit.pkg", kdk_pkg_path])
|
subprocess.run(["/bin/cp", "-r", f"{mount_point}/KernelDebugKit.pkg", kdk_pkg_path])
|
||||||
|
|
||||||
logging.info("Unmounting KDK")
|
logging.info("Unmounting KDK")
|
||||||
result = subprocess.run(["hdiutil", "detach", mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = subprocess.run(["/usr/bin/hdiutil", "detach", mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to unmount KDK")
|
logging.info("Failed to unmount KDK")
|
||||||
logging.info(result.stdout.decode("utf-8"))
|
logging.info(result.stdout.decode("utf-8"))
|
||||||
@@ -545,7 +545,7 @@ class macOSInstallerFlashFrame(wx.Frame):
|
|||||||
logging.error(f"Failed to find {dmg_path}")
|
logging.error(f"Failed to find {dmg_path}")
|
||||||
error_message = f"Failed to find {dmg_path}"
|
error_message = f"Failed to find {dmg_path}"
|
||||||
return error_message
|
return error_message
|
||||||
result = subprocess.run(["hdiutil", "verify", dmg_path],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
result = subprocess.run(["/usr/bin/hdiutil", "verify", dmg_path],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
if result.stdout:
|
if result.stdout:
|
||||||
logging.error(result.stdout.decode("utf-8"))
|
logging.error(result.stdout.decode("utf-8"))
|
||||||
|
|||||||
@@ -261,13 +261,13 @@ class MainFrame(wx.Frame):
|
|||||||
if Path("/Applications/OpenCore-Patcher.app").exists() and Path("/Applications/OpenCore-Patcher.app").is_symlink() is False:
|
if Path("/Applications/OpenCore-Patcher.app").exists() and Path("/Applications/OpenCore-Patcher.app").is_symlink() is False:
|
||||||
logging.info("Found user-installed app in /Applications, replacing with symlink")
|
logging.info("Found user-installed app in /Applications, replacing with symlink")
|
||||||
# Delete app
|
# Delete app
|
||||||
result = subprocess.run(["rm", "-rf", "/Applications/OpenCore-Patcher.app"], capture_output=True)
|
result = subprocess.run(["/bin/rm", "-rf", "/Applications/OpenCore-Patcher.app"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to delete app from /Applications")
|
logging.info("Failed to delete app from /Applications")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create symlink
|
# Create symlink
|
||||||
result = subprocess.run(["ln", "-s", "/Library/Application Support/Dortania/OpenCore-Patcher.app", "/Applications/OpenCore-Patcher.app"], capture_output=True)
|
result = subprocess.run(["/bin/ln", "-s", "/Library/Application Support/Dortania/OpenCore-Patcher.app", "/Applications/OpenCore-Patcher.app"], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.info("Failed to create symlink to /Applications")
|
logging.info("Failed to create symlink to /Applications")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ Hardware Information:
|
|||||||
value_type = "-bool"
|
value_type = "-bool"
|
||||||
|
|
||||||
logging.info(f"Updating System Defaults: {variable} = {value} ({value_type})")
|
logging.info(f"Updating System Defaults: {variable} = {value} ({value_type})")
|
||||||
subprocess.run(["defaults", "write", "-g", variable, value_type, str(value)])
|
subprocess.run(["/usr/bin/defaults", "write", "-globalDomain", variable, value_type, str(value)])
|
||||||
|
|
||||||
|
|
||||||
def _find_parent_for_key(self, key: str) -> str:
|
def _find_parent_for_key(self, key: str) -> str:
|
||||||
@@ -1152,7 +1152,7 @@ Hardware Information:
|
|||||||
if dlg.ShowModal() != wx.ID_YES:
|
if dlg.ShowModal() != wx.ID_YES:
|
||||||
return
|
return
|
||||||
|
|
||||||
macserial_output = subprocess.run([self.constants.macserial_path] + f"-g -m {self.constants.custom_model or self.constants.computer.real_model} -n 1".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
macserial_output = subprocess.run([self.constants.macserial_path, "--generate", "--model", self.constants.custom_model or self.constants.computer.real_model, "--num", "1"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
macserial_output = macserial_output.stdout.decode().strip().split(" | ")
|
||||||
if len(macserial_output) == 2:
|
if len(macserial_output) == 2:
|
||||||
self.custom_serial_number_textbox.SetValue(macserial_output[0])
|
self.custom_serial_number_textbox.SetValue(macserial_output[0])
|
||||||
@@ -1256,7 +1256,7 @@ Hardware Information:
|
|||||||
|
|
||||||
|
|
||||||
def _get_system_settings(self, variable) -> bool:
|
def _get_system_settings(self, variable) -> bool:
|
||||||
result = subprocess.run(["defaults", "read", "-g", variable], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
result = subprocess.run(["/usr/bin/defaults", "read", "-globalDomain", variable], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
try:
|
try:
|
||||||
return bool(int(result.stdout.decode().strip()))
|
return bool(int(result.stdout.decode().strip()))
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class GenerateMenubar:
|
|||||||
|
|
||||||
self.frame.Bind(wx.EVT_MENU, lambda event: gui_about.AboutFrame(self.constants), aboutItem)
|
self.frame.Bind(wx.EVT_MENU, lambda event: gui_about.AboutFrame(self.constants), aboutItem)
|
||||||
self.frame.Bind(wx.EVT_MENU, lambda event: RelaunchApplicationAsRoot(self.frame, self.constants).relaunch(None), relaunchItem)
|
self.frame.Bind(wx.EVT_MENU, lambda event: RelaunchApplicationAsRoot(self.frame, self.constants).relaunch(None), relaunchItem)
|
||||||
self.frame.Bind(wx.EVT_MENU, lambda event: subprocess.run(["open", "-R", self.constants.log_filepath]), revealLogItem)
|
self.frame.Bind(wx.EVT_MENU, lambda event: subprocess.run(["/usr/bin/open", "--reveal", self.constants.log_filepath]), revealLogItem)
|
||||||
|
|
||||||
if os.geteuid() == 0:
|
if os.geteuid() == 0:
|
||||||
relaunchItem.Enable(False)
|
relaunchItem.Enable(False)
|
||||||
@@ -329,7 +329,7 @@ class RelaunchApplicationAsRoot:
|
|||||||
|
|
||||||
# Relaunch as root
|
# Relaunch as root
|
||||||
args = [
|
args = [
|
||||||
"osascript",
|
"/usr/bin/osascript",
|
||||||
"-e",
|
"-e",
|
||||||
f'''do shell script "{program_arguments}"'''
|
f'''do shell script "{program_arguments}"'''
|
||||||
' with prompt "OpenCore Legacy Patcher needs administrator privileges to relaunch as admin."'
|
' with prompt "OpenCore Legacy Patcher needs administrator privileges to relaunch as admin."'
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ class SysPatchStartFrame(wx.Frame):
|
|||||||
if answer == wx.ID_YES:
|
if answer == wx.ID_YES:
|
||||||
output =subprocess.run(
|
output =subprocess.run(
|
||||||
[
|
[
|
||||||
"osascript", "-e",
|
"/usr/bin/osascript", "-e",
|
||||||
'tell app "System Preferences" to activate',
|
'tell app "System Preferences" to activate',
|
||||||
"-e", 'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"',
|
"-e", 'tell app "System Preferences" to reveal anchor "General" of pane id "com.apple.preference.security"',
|
||||||
],
|
],
|
||||||
@@ -327,7 +327,7 @@ class SysPatchStartFrame(wx.Frame):
|
|||||||
)
|
)
|
||||||
if output.returncode != 0:
|
if output.returncode != 0:
|
||||||
# Some form of fallback if unaccelerated state errors out
|
# Some form of fallback if unaccelerated state errors out
|
||||||
subprocess.run(["open", "-a", "System Preferences"])
|
subprocess.run(["/usr/bin/open", "-a", "System Preferences"])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|||||||
@@ -184,13 +184,13 @@ class UpdateFrame(wx.Frame):
|
|||||||
"""
|
"""
|
||||||
logging.info("Extracting update")
|
logging.info("Extracting update")
|
||||||
if Path(self.application_path).exists():
|
if Path(self.application_path).exists():
|
||||||
subprocess.run(["rm", "-rf", str(self.application_path)])
|
subprocess.run(["/bin/rm", "-rf", str(self.application_path)])
|
||||||
|
|
||||||
# Some hell spawn at Github decided to double zip our Github Actions artifacts
|
# Some hell spawn at Github decided to double zip our Github Actions artifacts
|
||||||
# So we need to unzip it twice
|
# So we need to unzip it twice
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["ditto", "-xk", str(self.constants.payload_path / "OpenCore-Patcher-GUI.app.zip"), str(self.constants.payload_path)], capture_output=True
|
["/usr/bin/ditto", "-xk", str(self.constants.payload_path / "OpenCore-Patcher-GUI.app.zip"), str(self.constants.payload_path)], capture_output=True
|
||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logging.error(f"Failed to extract update. Error: {result.stderr.decode('utf-8')}")
|
logging.error(f"Failed to extract update. Error: {result.stderr.decode('utf-8')}")
|
||||||
|
|||||||
Reference in New Issue
Block a user