mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-08-25 14:53:06 +00:00
Add Linux support
This commit is contained in:
+26
-14
@@ -7,6 +7,9 @@ from Scripts import utils
|
|||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import random
|
import random
|
||||||
|
import platform
|
||||||
|
|
||||||
|
os_name = platform.system()
|
||||||
|
|
||||||
class SMBIOS:
|
class SMBIOS:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -17,26 +20,35 @@ class SMBIOS:
|
|||||||
|
|
||||||
def check_macserial(self, retry_count=0):
|
def check_macserial(self, retry_count=0):
|
||||||
max_retries = 3
|
max_retries = 3
|
||||||
macserial_name = "macserial.exe" if os.name == "nt" else "macserial"
|
|
||||||
macserial_path = os.path.join(self.script_dir, macserial_name)
|
|
||||||
|
|
||||||
if not os.path.exists(macserial_path):
|
if os_name == "Windows":
|
||||||
if retry_count >= max_retries:
|
macserial_binary = ["macserial.exe"]
|
||||||
raise FileNotFoundError("Failed to download macserial after {} attempts".format(max_retries))
|
elif os_name == "Linux":
|
||||||
|
macserial_binary = ["macserial.linux", "macserial"]
|
||||||
|
elif os_name == "Darwin":
|
||||||
|
macserial_binary = ["macserial"]
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown OS for macserial")
|
||||||
|
|
||||||
download_history = self.utils.read_file(self.g.download_history_file)
|
for binary in macserial_binary:
|
||||||
|
macserial_path = os.path.join(self.script_dir, binary)
|
||||||
|
if os.path.exists(macserial_path):
|
||||||
|
return macserial_path
|
||||||
|
|
||||||
if download_history:
|
if retry_count >= max_retries:
|
||||||
product_index = self.g.get_product_index(download_history, "OpenCorePkg")
|
raise Exception("Failed to find macserial after {} attempts".format(max_retries))
|
||||||
|
|
||||||
if product_index is not None:
|
download_history = self.utils.read_file(self.g.download_history_file)
|
||||||
download_history.pop(product_index)
|
|
||||||
self.utils.write_file(self.g.download_history_file, download_history)
|
|
||||||
|
|
||||||
self.g.gather_bootloader_kexts([], "")
|
if download_history:
|
||||||
return self.check_macserial(retry_count + 1)
|
product_index = self.g.get_product_index(download_history, "OpenCorePkg")
|
||||||
|
|
||||||
return macserial_path
|
if product_index is not None:
|
||||||
|
download_history.pop(product_index)
|
||||||
|
self.utils.write_file(self.g.download_history_file, download_history)
|
||||||
|
|
||||||
|
self.g.gather_bootloader_kexts([], "")
|
||||||
|
return self.check_macserial(retry_count + 1)
|
||||||
|
|
||||||
def generate_random_mac(self):
|
def generate_random_mac(self):
|
||||||
random_mac = ''.join([format(random.randint(0, 255), '02X') for _ in range(6)])
|
random_mac = ''.join([format(random.randint(0, 255), '02X') for _ in range(6)])
|
||||||
|
|||||||
Reference in New Issue
Block a user