From dceee56684019526c5d378b08b47c38d810b3639 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 14 Sep 2024 17:56:37 -0400 Subject: [PATCH] upgrades: Treat n/a release as testing Closes #2092 On testing and unstable systems, /etc/os-release does not contain VERSION_ID. In this case, lsb_release will report the release as "n/a". For unstable, this means that backports can be enabled in development mode. When this happens, trixie-backports will be added as an apt repository. The repository already exists, so it does not cause any problem. Tests: - In stable container, backports can be enabled. - In stable container, dist-upgrade can be disable and enabled. - In stable container, in development mode, dist-upgrade can be started. - In testing container, backports cannot be enabled. - In testing container, dist-upgrade cannot be enabled or started. - In testing container, in development mode, backports can be enabled. - In testing container, in development mode, dist-upgrade cannot be started. - In unstable container, in development mode, backports can be enabled (as trixie-backports). - In unstable container, in development mode, dist-upgrade cannot be started. Signed-off-by: James Valleroy [sunil: Merge the case of outdated unstable distributions that return 'unstable' as release and newer unstable distributions that return 'n/a'] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/upgrades/__init__.py | 14 ++++++++------ plinth/modules/upgrades/privileged.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plinth/modules/upgrades/__init__.py b/plinth/modules/upgrades/__init__.py index 22a046f84..e0e9ba80a 100644 --- a/plinth/modules/upgrades/__init__.py +++ b/plinth/modules/upgrades/__init__.py @@ -10,8 +10,9 @@ from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_noop import plinth +from plinth import action_utils from plinth import app as app_module -from plinth import action_utils, cfg, glib, kvstore, menu, package +from plinth import cfg, glib, kvstore, menu, package from plinth.config import DropinConfigs from plinth.daemon import RelatedDaemon from plinth.diagnostic_check import DiagnosticCheck, Result @@ -294,17 +295,18 @@ def is_backports_current(): def can_activate_backports(): """Return whether backports can be activated.""" - release, _ = get_current_release() - if release == 'unstable' or (release == 'testing' and not cfg.develop): - return False + if cfg.develop: + return True - return True + # Release will be 'n/a' in latest unstable and testing distributions. + release, _ = get_current_release() + return release not in ['unstable', 'testing', 'n/a'] def can_enable_dist_upgrade(): """Return whether dist upgrade can be enabled.""" release, _ = get_current_release() - return release not in ['unstable', 'testing'] + return release not in ['unstable', 'testing', 'n/a'] def can_test_dist_upgrade(): diff --git a/plinth/modules/upgrades/privileged.py b/plinth/modules/upgrades/privileged.py index 37f21a804..781aae07d 100644 --- a/plinth/modules/upgrades/privileged.py +++ b/plinth/modules/upgrades/privileged.py @@ -257,7 +257,7 @@ def _check_and_backports_sources(develop=False): return release, dist = get_current_release() - if release == 'unstable' or (release == 'testing' and not develop): + if release in ['unstable', 'testing', 'n/a'] and not develop: logging.info(f'System release is {release}. Skip enabling backports.') return @@ -326,7 +326,7 @@ def _check_dist_upgrade(test_upgrade=False) -> tuple[bool, str]: from plinth.modules.upgrades import get_current_release release, dist = get_current_release() - if release in ['unstable', 'testing']: + if release in ['unstable', 'testing', 'n/a']: return (False, f'already-{release}') check_dists = ['stable']