From 4b2162f3fdf648735fa74cd60308ec91fd16c2c9 Mon Sep 17 00:00:00 2001 From: Fioddor Superconcentrado Date: Tue, 31 Aug 2021 00:10:48 +0200 Subject: [PATCH] setup: Show and remove conflicts before installation Warn of installed conflicting packages before installing apps. [sunil: Rename 'advice' to 'action'] [sunil: Action will be string constant, for better API and i18n] [sunil: Don't show conflict warning if action is 'ignore'] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/setup.py | 16 ++++++++++++++++ plinth/templates/setup.html | 11 +++++++++++ plinth/views.py | 8 +++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plinth/setup.py b/plinth/setup.py index d1f651a0e..8189f6199 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -13,6 +13,7 @@ from collections import defaultdict import apt import plinth +from plinth.package import packages_installed from plinth.signals import post_setup from . import package @@ -178,6 +179,15 @@ class Helper(object): if pkg_name not in cache) return any(unavailable_pkgs) + def get_package_conflicts(self): + """Report list of conflicting packages for the user.""" + package_conflicts, package_conflicts_action = \ + _get_module_package_conflicts(self.module) + if package_conflicts: + package_conflicts = packages_installed(package_conflicts) + + return package_conflicts, package_conflicts_action + def init(module_name, module): """Create a setup helper for a module for later use.""" @@ -298,6 +308,12 @@ def _is_module_essential(module): return getattr(module, 'is_essential', False) +def _get_module_package_conflicts(module): + """Return list of packages that conflict with packages of a module.""" + return (getattr(module, 'package_conflicts', + None), getattr(module, 'package_conflicts_action', None)) + + def _get_module_managed_packages(module): """Return list of packages managed by a module.""" return getattr(module, 'managed_packages', []) diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html index 2846a0145..3d9d78bbf 100644 --- a/plinth/templates/setup.html +++ b/plinth/templates/setup.html @@ -50,6 +50,17 @@ {% trans "Check again" %} + {% elif package_conflicts and package_conflicts_action != 'ignore' %} + {% endif %}