mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
upgrades: Add diagnostic for held packages
- Add a new diagnostic check result for skipped tests. Tests: - Put a hold on a package. The diagnostic is failed. - Remove the hold from the package. The diagnostic is passed. - Start installing an app, then immediately run the upgrades diagnostics. The diagnostic is skipped. Helps: #2347 Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Allow i18n for new state 'skipped'] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
0e8597a034
commit
f08211d228
4 files changed
+28
-1
No files matched your search
@@ -96,6 +96,7 @@ def _run_on_all_enabled_modules():
|
||||
|
||||
# Four result strings returned by tests, mark for translation and
|
||||
# translate later.
|
||||
gettext_noop('skipped')
|
||||
gettext_noop('passed')
|
||||
gettext_noop('failed')
|
||||
gettext_noop('error')
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
<span class="badge badge-danger">{% trans result.result %}</span>
|
||||
{% elif result.result == 'error' or result.result == 'warning' %}
|
||||
<span class="badge badge-warning">{% trans result.result %}</span>
|
||||
{% elif result.result == 'skipped' %}
|
||||
<span class="badge badge-secondary">{% trans result.result %}</span>
|
||||
{% else %}
|
||||
{{ result.result }}
|
||||
{% endif %}
|
||||
|
||||
@@ -11,9 +11,10 @@ from django.utils.translation import gettext_noop
|
||||
|
||||
import plinth
|
||||
from plinth import app as app_module
|
||||
from plinth import cfg, glib, kvstore, menu
|
||||
from plinth import action_utils, cfg, glib, kvstore, menu, package
|
||||
from plinth.config import DropinConfigs
|
||||
from plinth.daemon import RelatedDaemon
|
||||
from plinth.diagnostic_check import DiagnosticCheck, Result
|
||||
from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.package import Packages
|
||||
|
||||
@@ -159,6 +160,12 @@ class UpgradesApp(app_module.App):
|
||||
# install and on version increment.
|
||||
setup_repositories(None)
|
||||
|
||||
def diagnose(self) -> list[DiagnosticCheck]:
|
||||
"""Run diagnostics and return the results."""
|
||||
results = super().diagnose()
|
||||
results.append(_diagnose_held_packages())
|
||||
return results
|
||||
|
||||
|
||||
def setup_repositories(_):
|
||||
"""Setup apt repositories for backports."""
|
||||
@@ -296,3 +303,19 @@ def test_dist_upgrade():
|
||||
"""Test dist-upgrade from stable to testing."""
|
||||
if can_test_dist_upgrade():
|
||||
try_start_dist_upgrade(test=True)
|
||||
|
||||
|
||||
def _diagnose_held_packages():
|
||||
"""Check if any packages have holds."""
|
||||
check = DiagnosticCheck('upgrades-package-holds',
|
||||
gettext_noop('Check for package holds'),
|
||||
Result.NOT_DONE)
|
||||
if (package.is_package_manager_busy()
|
||||
or action_utils.service_is_running('freedombox-dist-upgrade')):
|
||||
check.result = Result.SKIPPED
|
||||
return check
|
||||
|
||||
output = subprocess.check_output(['apt-mark', 'showhold']).decode().strip()
|
||||
held_packages = output.split()
|
||||
check.result = Result.FAILED if held_packages else Result.PASSED
|
||||
return check
|
||||
Reference in new issue
Block a user