From af3abe6aa1f16730904e5f63ab28e7eca9c55fce Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 25 Jan 2022 09:55:21 -0700 Subject: [PATCH 1/3] installer.py: Add Permissions check --- resources/installer.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/resources/installer.py b/resources/installer.py index 71dd80668..3432de590 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -12,26 +12,29 @@ def list_local_macOS_installers(): for application in Path("/Applications").iterdir(): # Verify whether application has createinstallmedia - if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists(): - plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb")) - try: - # Doesn't reflect true OS build, but best to report SDK in the event multiple installers are found with same version - app_version = plist["DTPlatformVersion"] - clean_name = plist["CFBundleDisplayName"] + try: + if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists(): + plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb")) try: - app_sdk = plist["DTSDKBuild"] + # Doesn't reflect true OS build, but best to report SDK in the event multiple installers are found with same version + app_version = plist["DTPlatformVersion"] + clean_name = plist["CFBundleDisplayName"] + try: + app_sdk = plist["DTSDKBuild"] + except KeyError: + app_sdk = "Unknown" + application_list.update({ + application: { + "Short Name": clean_name, + "Version": app_version, + "Build": app_sdk, + "Path": application, + } + }) except KeyError: - app_sdk = "Unknown" - application_list.update({ - application: { - "Short Name": clean_name, - "Version": app_version, - "Build": app_sdk, - "Path": application, - } - }) - except KeyError: - pass + pass + except PermissionError: + pass return application_list def create_installer(installer_path, volume_name): From cd1729f74d4fa5081c1453e1c0cc5870a1632139 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 25 Jan 2022 10:01:04 -0700 Subject: [PATCH 2/3] Check Permissions erroring --- resources/installer.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/installer.py b/resources/installer.py index 3432de590..c2f624654 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -23,18 +23,22 @@ def list_local_macOS_installers(): app_sdk = plist["DTSDKBuild"] except KeyError: app_sdk = "Unknown" - application_list.update({ - application: { - "Short Name": clean_name, - "Version": app_version, - "Build": app_sdk, - "Path": application, - } - }) + # Check if App Version is Catalina or older + if not app_version.startswith("10."): + application_list.update({ + application: { + "Short Name": clean_name, + "Version": app_version, + "Build": app_sdk, + "Path": application, + } + }) except KeyError: 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 def create_installer(installer_path, volume_name): From a15261073b44ef0ab9f6b4504f52f262ad2ea8d0 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 25 Jan 2022 10:40:30 -0700 Subject: [PATCH 3/3] Clean up --- resources/installer.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/resources/installer.py b/resources/installer.py index c2f624654..d0a8e55cc 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -23,14 +23,35 @@ def list_local_macOS_installers(): app_sdk = plist["DTSDKBuild"] except KeyError: app_sdk = "Unknown" - # Check if App Version is Catalina or older - if not app_version.startswith("10."): + + # 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: { - "Short Name": clean_name, - "Version": app_version, - "Build": app_sdk, - "Path": application, + "Short Name": clean_name, + "Version": app_version, + "Build": app_sdk, + "Path": application, } }) except KeyError: