mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Handle masked, pinned, and EOL packages
This commit is contained in:
@@ -88,7 +88,18 @@ class Flatpak:
|
||||
else:
|
||||
self.info["installation"] = installation
|
||||
|
||||
self.is_masked = self.info["id"] in HostInfo.masks[self.info["installation"]]
|
||||
self.is_eol = "eol=" in self.info["options"]
|
||||
self.dependant_runtime = None
|
||||
|
||||
try:
|
||||
self.is_masked = self.info["id"] in HostInfo.masks[self.info["installation"]]
|
||||
except KeyError:
|
||||
self.is_masked = False
|
||||
|
||||
try:
|
||||
self.is_pinned = f"runtime/{self.info['ref']}" in HostInfo.pins[self.info["installation"]]
|
||||
except KeyError:
|
||||
self.is_pinned = False
|
||||
|
||||
try:
|
||||
self.icon_path = (
|
||||
@@ -123,6 +134,7 @@ class HostInfo:
|
||||
icon_theme.add_search_path(f"{i}/exports/share/icons")
|
||||
|
||||
flatpaks = []
|
||||
ref_to_flatpak = {}
|
||||
remotes = []
|
||||
installations = []
|
||||
masks = {}
|
||||
@@ -131,6 +143,7 @@ class HostInfo:
|
||||
def get_flatpaks(this, callback=None):
|
||||
# Callback is a function to run after the host flatpaks are found
|
||||
this.flatpaks.clear()
|
||||
this.ref_to_flatpak.clear()
|
||||
this.remotes.clear()
|
||||
this.installations.clear()
|
||||
this.masks.clear()
|
||||
@@ -212,7 +225,24 @@ class HostInfo:
|
||||
).stdout
|
||||
lines = output.strip().split("\n")
|
||||
for i in lines:
|
||||
this.flatpaks.append(Flatpak(i.split("\t")))
|
||||
package = Flatpak(i.split("\t"))
|
||||
this.flatpaks.append(package)
|
||||
this.ref_to_flatpak[package.info["ref"]] = package
|
||||
|
||||
# Dependant Runtimes
|
||||
output = subprocess.run(
|
||||
['flatpak-spawn', '--host',
|
||||
'flatpak', 'list', '--columns=runtime'],
|
||||
text=True,
|
||||
capture_output=True,
|
||||
).stdout
|
||||
lines = output.strip().split("\n")
|
||||
for index, runtime in enumerate(lines):
|
||||
package = this.flatpaks[index]
|
||||
if package.is_runtime:
|
||||
continue
|
||||
package.dependant_runtime = this.ref_to_flatpak[runtime]
|
||||
|
||||
this.flatpaks = sorted(this.flatpaks, key=lambda flatpak: flatpak.info["name"].lower())
|
||||
|
||||
Gio.Task.new(None, None, callback).run_in_thread(thread)
|
||||
@@ -27,11 +27,16 @@ class PackagesPage(Adw.BreakpointBin):
|
||||
self.packages_list_box.remove_all()
|
||||
for package in HostInfo.flatpaks:
|
||||
row = AppRow(package)
|
||||
app_id = package.info["id"]
|
||||
installation = package.info["installation"]
|
||||
if package.is_masked:
|
||||
row.add_css_class("warning")
|
||||
row.masked_status_icon.set_visible(package.is_masked)
|
||||
row.pinned_status_icon.set_visible(package.is_pinned)
|
||||
row.eol_package_package_status_icon.set_visible(package.is_eol)
|
||||
try:
|
||||
if not package.is_runtime:
|
||||
row.eol_runtime_status_icon.set_visible(package.dependant_runtime.is_eol)
|
||||
except Exception as e:
|
||||
self.packages_toast_overlay.add_toast(ErrorToast(_("Error getting Flatpak '{}'").format(package.info["name"]), str(e)).toast)
|
||||
self.packages_list_box.append(row)
|
||||
|
||||
first_row = self.packages_list_box.get_row_at_index(0)
|
||||
self.packages_list_box.select_row(first_row)
|
||||
self.properties_page.set_properties(first_row.package)
|
||||
|
||||
@@ -9,26 +9,30 @@ template $AppRow : Adw.ActionRow {
|
||||
icon-name: "application-x-executable-symbolic";
|
||||
}
|
||||
[suffix]
|
||||
Image eol_package_label {
|
||||
icon-name: "error-small-symbolic";
|
||||
Image eol_package_package_status_icon {
|
||||
icon-name: "error-symbolic";
|
||||
tooltip-text: _("This package is End Of Life, and will not recieve any security updates");
|
||||
visible: false;
|
||||
styles["error"]
|
||||
}
|
||||
[suffix]
|
||||
Image eol_runtime_label {
|
||||
icon-name: "error-small-symbolic";
|
||||
Image eol_runtime_status_icon {
|
||||
icon-name: "error-symbolic";
|
||||
tooltip-text: _("This app's runtime is End Of Life, and will not recieve any security updates");
|
||||
visible: false;
|
||||
styles["error"]
|
||||
}
|
||||
[suffix]
|
||||
Image pinned_status_icon {
|
||||
icon-name: "pin-small-symbolic";
|
||||
icon-name: "pin-symbolic";
|
||||
tooltip-text: _("This runtime will never be automatically removed");
|
||||
visible: false;
|
||||
}
|
||||
[suffix]
|
||||
Image masked_status_icon {
|
||||
icon-name: "software-update-urgent-symbolic";
|
||||
tooltip-text: _("Updates are disabled for this package");
|
||||
visible: false;
|
||||
}
|
||||
[suffix]
|
||||
CheckButton check_button {
|
||||
|
||||
@@ -6,6 +6,10 @@ class AppRow(Adw.ActionRow):
|
||||
__gtype_name__ = 'AppRow'
|
||||
gtc = Gtk.Template.Child
|
||||
image = gtc()
|
||||
eol_package_package_status_icon = gtc()
|
||||
eol_runtime_status_icon = gtc()
|
||||
pinned_status_icon = gtc()
|
||||
masked_status_icon = gtc()
|
||||
check_button = gtc()
|
||||
|
||||
def __init__(self, package, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user