Skip to content

Commit

Permalink
Add info about obsolete templates to qubes-updater-gui
Browse files Browse the repository at this point in the history
This is not perfect - just gives the user information, not
immediately actionable button - but should at least
help significantly.

fixes QubesOS/qubes-issues#6905
  • Loading branch information
marmarta committed Oct 13, 2023
1 parent e6c5a14 commit 465e74b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
8 changes: 5 additions & 3 deletions qui/updater.glade
Expand Up @@ -63,8 +63,8 @@
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">False</property>
<property name="window-position">center</property>
<property name="title" translatable="yes">Qubes OS Update</property>
<property name="window-position">center</property>
<child>
<!-- n-columns=1 n-rows=3 -->
<object class="GtkGrid">
Expand Down Expand Up @@ -224,7 +224,9 @@
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-top">20</property>
<property name="label" translatable="yes">Qubes OS checks for updates for running and networked qubes and their templates. Updates may also be available in other qubes, marked as {MAYBE} above.</property>
<property name="label" translatable="yes">Qubes OS checks for updates for running and networked qubes and their templates. Updates may also be available in other qubes, marked as {MAYBE} above.

{OBSOLETE} qubes are based on templates that are no longer supported and no longer receive updates. Please install new templates using the Qubes Template Manager.</property>
<property name="use-markup">True</property>
<property name="wrap">True</property>
<style>
Expand Down Expand Up @@ -454,10 +456,10 @@ CAUTION: this may cause data loss if you are currently running programs in those
<property name="editable">False</property>
<property name="wrap-mode">word</property>
<property name="justification">fill</property>
<property name="left-margin">18</property>
<property name="cursor-visible">False</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
<property name="left-margin">18</property>
<style>
<class name="text_container"/>
</style>
Expand Down
37 changes: 30 additions & 7 deletions qui/updater/intro_page.py
Expand Up @@ -32,6 +32,7 @@
from qubes_config.widgets.gtk_utils import load_icon
from qubesadmin import exc

from qui.utils import check_support
from qui.updater.utils import disable_checkboxes, HeaderCheckbox, \
pass_through_event_window, \
QubeName, label_color_theme, UpdateStatus, RowWrapper, \
Expand Down Expand Up @@ -79,7 +80,10 @@ def __init__(self, builder, log, next_button):
self.info_how_it_works.set_label(
self.info_how_it_works.get_label().format(
MAYBE=f'<span foreground="{label_color_theme("orange")}">'
'<b>MAYBE</b></span>'))
'<b>MAYBE</b></span>',
OBSOLETE=f'<span foreground="{label_color_theme("red")}">'
'<b>OBSOLETE</b></span>'
))

self.restart_button: Gtk.CheckButton = self.builder.get_object(
"restart_button")
Expand Down Expand Up @@ -234,6 +238,7 @@ def __init__(self, list_store, vm, to_update: bool):
if to_update and not updates_available:
updates_available = None
selected = updates_available is True
supported = check_support(vm)

last_updates_check = vm.features.get('last-updates-check', None)
last_update = vm.features.get('last-update', None)
Expand All @@ -245,7 +250,7 @@ def __init__(self, list_store, vm, to_update: bool):
selected,
icon,
name,
UpdatesAvailable.from_bool(updates_available),
UpdatesAvailable.from_features(updates_available, supported),
Date(last_updates_check),
Date(last_update),
0,
Expand Down Expand Up @@ -287,10 +292,12 @@ def updates_available(self):
def updates_available(self, value):
updates_available = bool(
self.vm.features.get('updates-available', False))
supported = check_support(self.vm)

if value and not updates_available:
updates_available = None
self.raw_row[self._UPDATES_AVAILABLE] = \
UpdatesAvailable.from_bool(updates_available)
UpdatesAvailable.from_features(updates_available, supported)

@property
def last_updates_check(self):
Expand Down Expand Up @@ -387,12 +394,16 @@ class UpdatesAvailable(Enum):
YES = 0
MAYBE = 1
NO = 2
EOL = 3

@staticmethod
def from_bool(value: Optional[bool]) -> "UpdatesAvailable":
if value:
def from_features(updates_available: Optional[bool],
supported: Optional[str]=None) -> "UpdatesAvailable":
if not supported:
return UpdatesAvailable.EOL
if updates_available:
return UpdatesAvailable.YES
if value is None:
if updates_available is None:
return UpdatesAvailable.MAYBE
return UpdatesAvailable.NO

Expand All @@ -404,10 +415,22 @@ def color(self):
return label_color_theme("orange")
if self is UpdatesAvailable.NO:
return label_color_theme("black")
if self is UpdatesAvailable.EOL:
return label_color_theme('red')

def __str__(self):
if self is UpdatesAvailable.YES:
name = "YES"
elif self is UpdatesAvailable.MAYBE:
name = "MAYBE"
elif self is UpdatesAvailable.NO:
name = "NO"
elif self is UpdatesAvailable.EOL:
name = "OBSOLETE"
else:
name = "ERROR"
return f'<span foreground="{self.color}"><b>' \
+ self.name + '</b></span>'
+ name + '</b></span>'

def __eq__(self, other: "UpdatesAvailable"):
return self.value == other.value
Expand Down

0 comments on commit 465e74b

Please sign in to comment.