From 52d03d4be18f6a82d44168496ad06157439ef5b2 Mon Sep 17 00:00:00 2001 From: CorpNewt Date: Wed, 12 Jun 2019 11:17:59 -0500 Subject: [PATCH] Display build number for products if found --- gibMacOS.command | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/gibMacOS.command b/gibMacOS.command index ad07546..4608bc8 100755 --- a/gibMacOS.command +++ b/gibMacOS.command @@ -141,11 +141,29 @@ class gibMacOS: if plist_dict.get("Products",{}).get(p,{}).get("ExtendedMetaInfo",{}).get("InstallAssistantPackageIdentifiers",{}).get("OSInstall",{}) == "com.apple.mpkg.OSInstall": mac_prods.append(p) else: - # Find out if we have any of the recovert_suffixes + # Find out if we have any of the recovery_suffixes if any(x for x in plist_dict.get("Products",{}).get(p,{}).get("Packages",[]) if x["URL"].endswith(self.recovery_suffixes)): mac_prods.append(p) return mac_prods + def get_build_version(self, dist_dict): + build = version = "Unknown" + try: + dist_url = dist_dict.get("English","") if dist_dict.get("English",None) else dist_dict.get("en","") + dist_file = self.d.get_bytes(dist_url, False).decode("utf-8") + except: + dist_file = "" + pass + try: + build = dist_file.split("BUILD")[1].split("")[1].split("")[0] + except: + pass + try: + version = dist_file.split("VERSION")[1].split("")[1].split("")[0] + except: + pass + return (build,version) + def get_dict_for_prods(self, prods, plist_dict = None): if plist_dict==self.catalog_data==None: plist_dict = {} @@ -185,6 +203,11 @@ class gibMacOS: else: # Add them all! prodd["packages"] = plist_dict.get("Products",{}).get(prod,{}).get("Packages",[]) + # Attempt to get the build/version info from the dist + b,v = self.get_build_version(plist_dict.get("Products",{}).get(prod,{}).get("Distributions",{})) + prodd["build"] = b + if not v.lower() == "unknown": + prodd["version"] = v prod_list.append(prodd) # Sort by newest prod_list = sorted(prod_list, key=lambda x:x["time"], reverse=True) @@ -360,6 +383,8 @@ class gibMacOS: for p in self.mac_prods: num += 1 var1 = "{}. {} {}".format(num, p["title"], p["version"]) + if p["build"].lower() != "unknown": + var1 += " ({})".format(p["build"]) var2 = " - {} - Added {}".format(p["product"], p["date"]) if self.find_recovery and p["installer"]: # Show that it's a full installer