Merge pull request #911 from dortania/installer-test

Resolve Local Installer Detection
This commit is contained in:
Mykola Grymalyuk
2022-01-25 12:03:12 -07:00
committed by GitHub

View File

@@ -12,6 +12,7 @@ def list_local_macOS_installers():
for application in Path("/Applications").iterdir(): for application in Path("/Applications").iterdir():
# Verify whether application has createinstallmedia # Verify whether application has createinstallmedia
try:
if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists(): if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists():
plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb")) plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb"))
try: try:
@@ -22,6 +23,29 @@ def list_local_macOS_installers():
app_sdk = plist["DTSDKBuild"] app_sdk = plist["DTSDKBuild"]
except KeyError: except KeyError:
app_sdk = "Unknown" app_sdk = "Unknown"
# app_version can sometimes report GM instead of the actual version
# This is a workaround to get the actual version
if app_version.startswith("GM"):
try:
app_version = int(app_sdk[:2])
if app_version < 20:
app_version = f"10.{app_version - 4}"
else:
app_version = f"{app_version - 9}.0"
except ValueError:
app_version = "Unknown"
# Check if App Version is High Sierra or newer
can_add = False
if app_version.startswith("10."):
app_sub_version = app_version.split(".")[1]
if int(app_sub_version) >= 13:
can_add = True
else:
can_add = False
else:
can_add = True
if can_add is True:
application_list.update({ application_list.update({
application: { application: {
"Short Name": clean_name, "Short Name": clean_name,
@@ -32,6 +56,10 @@ def list_local_macOS_installers():
}) })
except KeyError: except KeyError:
pass pass
except PermissionError:
pass
# Sort Applications by version
application_list = {k: v for k, v in sorted(application_list.items(), key=lambda item: item[1]["Version"])}
return application_list return application_list
def create_installer(installer_path, volume_name): def create_installer(installer_path, volume_name):