diff --git a/usr/lib/linuxmint/mintUpdate/Classes.py b/usr/lib/linuxmint/mintUpdate/Classes.py index 411f6943..7ae99781 100644 --- a/usr/lib/linuxmint/mintUpdate/Classes.py +++ b/usr/lib/linuxmint/mintUpdate/Classes.py @@ -9,6 +9,7 @@ import json import os import subprocess +import sys import time import re import threading @@ -387,6 +388,7 @@ def __init__(self, op=None, installer=None, ref=None, installed_ref=None, remote # nullable self.installed_ref = installed_ref + self.installing = self.installed_ref is None self.remote_ref = remote_ref self.pkginfo = pkginfo # @@ -420,7 +422,7 @@ def __init__(self, op=None, installer=None, ref=None, installed_ref=None, remote old_commit = installed_ref.get_commit()[:10] else: iref_version = "" - old_commit = "" + old_commit = _("Installing") appstream_version = "" # new version @@ -441,23 +443,31 @@ def __init__(self, op=None, installer=None, ref=None, installed_ref=None, remote self.new_version = new_commit if pkginfo: - self.name = installer.get_display_name(pkginfo) + self.name = pkginfo.get_display_name() or self.ref_name elif installed_ref and self.flatpak_type != "runtime": self.name = installed_ref.get_appdata_name() else: self.name = ref.get_name() + # gnome has the branch as part of its name, the rest add it to the name if it's not a Locale + if self.flatpak_type == "runtime": + if ref.get_name() not in ("org.gnome.Platform", "org.gnome.Sdk") and (not ref.get_name().endswith(".Locale")): + self.name = "%s (%s)" % (self.name, ref.get_branch()) + if pkginfo: - self.summary = installer.get_summary(pkginfo) + self.summary = pkginfo.get_summary() + if self.summary is None: + if installed_ref: + self.summary = installed_ref.get_appdata_summary() + self.description = installer.get_description(pkginfo) - elif installed_ref: - self.summary = installed_ref.get_appdata_summary() - self.description = "" + if self.description is None: + self.description = self.summary else: self.summary = "" self.description = "" - if self.description == "" and self.flatpak_type == "runtime": + if self.summary == "" and self.flatpak_type == "runtime": self.summary = self.description = _("A Flatpak runtime package") self.real_source_name = self.ref_name @@ -474,9 +484,8 @@ def __init__(self, op=None, installer=None, ref=None, installed_ref=None, remote def add_package(self, update): self.sub_updates.append(update) - self.package_names.append(update.ref_name) + self.package_names.append(update.name) self.size += update.size - # self.source_packages.append("%s=%s" % (update.ref_name, update.new_version)) def to_json(self): trimmed_dict = {} @@ -493,7 +502,8 @@ def to_json(self): "source_packages", "package_names", "sub_updates", - "link"): + "link", + "installing"): trimmed_dict[key] = self.__dict__[key] trimmed_dict["metadata"] = self.metadata.to_data()[0] trimmed_dict["ref"] = self.ref.format_ref() @@ -518,13 +528,13 @@ def from_json(cls, json_data:dict): inst.package_names = json_data["package_names"] inst.sub_updates = json_data["sub_updates"] inst.link = json_data["link"] + inst.installing = json_data["installing"] inst.metadata = GLib.KeyFile() try: b = GLib.Bytes.new(json_data["metadata"].encode()) inst.metadata.load_from_bytes(b, GLib.KeyFileFlags.NONE) except GLib.Error as e: - print("unable to decode op metadata: %s" % e.message) - pass + print("flatpaks: unable to decode op metadata: %s" % e.message, file=sys.stderr, flush=True) return inst diff --git a/usr/lib/linuxmint/mintUpdate/flatpak-update-worker.py b/usr/lib/linuxmint/mintUpdate/flatpak-update-worker.py index e1ee1632..779565ff 100755 --- a/usr/lib/linuxmint/mintUpdate/flatpak-update-worker.py +++ b/usr/lib/linuxmint/mintUpdate/flatpak-update-worker.py @@ -102,17 +102,15 @@ def fetch_updates(self): if self.cancellable.is_cancelled(): return + self.installer.connect("appstream-changed", self.on_appstream_loaded) + if not self.installer.init_sync(): warn("cache not valid, refreshing") self.refresh(False) else: debug("cache valid") - self.installer.generate_uncached_pkginfos() - - debug("generating updates") - _flatpak._initialize_appstream_thread() - + def on_appstream_loaded(self, installer): self.updates = [] self.installer.select_flatpak_updates(None, self._fetch_task_ready, self._fetch_updates_error, @@ -157,7 +155,7 @@ def cmp_ref_name(a, b): for op in ops: if op.get_operation_type() == Flatpak.TransactionOperationType.UPDATE: ref = Flatpak.Ref.parse(op.get_ref()) - debug("Update: ", op.get_ref()) + debug("Update: ", op.get_ref(), ref.get_branch()) try: installed_ref = self.fp_sys.get_installed_ref(ref.get_kind(), ref.get_name(), @@ -169,7 +167,7 @@ def cmp_ref_name(a, b): if e.code == Flatpak.Error.NOT_INSTALLED: installed_ref = None - pkginfo = self.installer.find_pkginfo(ref.get_name(), installer.PKG_TYPE_FLATPAK, remote=op.get_remote()) + pkginfo = self.installer.find_pkginfo(ref.format_ref(), installer.PKG_TYPE_FLATPAK, remote=op.get_remote()) try: update = FlatpakUpdate(op, self.installer, ref, installed_ref, None, pkginfo) @@ -192,7 +190,7 @@ def cmp_ref_name(a, b): debug("Can't add ref to install: %s" % e.message) remote_ref = None - pkginfo = self.installer.find_pkginfo(ref.get_name(), installer.PKG_TYPE_FLATPAK, remote=op.get_remote()) + pkginfo = self.installer.find_pkginfo(ref.format_ref(), installer.PKG_TYPE_FLATPAK, remote=op.get_remote()) try: update = FlatpakUpdate(op, self.installer, ref, None, remote_ref, pkginfo) @@ -204,39 +202,37 @@ def cmp_ref_name(a, b): def add_to_parent_update(self, update): for maybe_parent in self.updates: - if update.ref_name.startswith(maybe_parent.ref_name): - maybe_parent.add_package(update) - return True - # if not self.is_base_package(maybe_parent): - # continue - built_extensions = [] + if not update.ref_name.startswith(maybe_parent.ref_name): + continue + + kf = update.metadata + try: - kf = maybe_parent.metadata - try: - built_extensions = kf.get_string_list("Build", "built-extensions") - except: - # runtimes, sdks don't have built-extensions, so we must parse the group names... - groups, n_groups = kf.get_groups() - - for group in groups: - ref_name = group.replace("Extension ", "") - built_extensions.append(ref_name) - except Exception: - return False - for extension in built_extensions: - if update.ref_name.startswith(extension): + extension_of = kf.get_string("ExtensionOf", "ref") + if extension_of == maybe_parent.ref.format_ref(): + maybe_parent.add_package(update) + return True + except: + pass + + try: + runtime_ref_id = "runtime/%s" % kf.get_string("Runtime", "runtime") + + parent_ref = maybe_parent.ref.format_ref() + if parent_ref == runtime_ref_id: maybe_parent.add_package(update) return True + except: + pass def is_base_package(self, update): - name = update.ref_name + name = update.ref.format_ref() if name.startswith("app"): return True try: kf = update.metadata runtime_ref_id = "runtime/%s" % kf.get_string("Runtime", "runtime") - runtime_ref = Flatpak.Ref.parse(runtime_ref_id) - if name == runtime_ref.get_name(): + if name == runtime_ref_id: return True except Exception: return False diff --git a/usr/lib/linuxmint/mintUpdate/mintUpdate.py b/usr/lib/linuxmint/mintUpdate/mintUpdate.py index c9ac03b9..b6d3e02a 100755 --- a/usr/lib/linuxmint/mintUpdate/mintUpdate.py +++ b/usr/lib/linuxmint/mintUpdate/mintUpdate.py @@ -891,7 +891,7 @@ def display_selected_update(self, selection): self.ui_notebook_details.get_nth_page(TAB_CHANGELOG).hide() self.ui_notebook_details.set_current_page(TAB_DESC) elif update.type == "flatpak": - if update.link is not None: + if update.link is not None and update.link != "": website_label_str = _("Website: %s") % update.link description = "%s\n\n%s" % (update.description, website_label_str) else: @@ -1182,6 +1182,9 @@ def display_package_list(self, update, is_flatpak=False): count = len(update.package_names) if is_flatpak: size_label = _("Total size: <") + if update.installing: + self.textview_packages.set_text("%s %s" % (size_label, size_to_string(update.size))) + return else: size_label = _("Total size:")