mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
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 <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
24f7ffe3cf
commit
4b2162f3fd
@ -13,6 +13,7 @@ from collections import defaultdict
|
|||||||
import apt
|
import apt
|
||||||
|
|
||||||
import plinth
|
import plinth
|
||||||
|
from plinth.package import packages_installed
|
||||||
from plinth.signals import post_setup
|
from plinth.signals import post_setup
|
||||||
|
|
||||||
from . import package
|
from . import package
|
||||||
@ -178,6 +179,15 @@ class Helper(object):
|
|||||||
if pkg_name not in cache)
|
if pkg_name not in cache)
|
||||||
return any(unavailable_pkgs)
|
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):
|
def init(module_name, module):
|
||||||
"""Create a setup helper for a module for later use."""
|
"""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)
|
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):
|
def _get_module_managed_packages(module):
|
||||||
"""Return list of packages managed by a module."""
|
"""Return list of packages managed by a module."""
|
||||||
return getattr(module, 'managed_packages', [])
|
return getattr(module, 'managed_packages', [])
|
||||||
|
|||||||
@ -50,6 +50,17 @@
|
|||||||
<span class="fa fa-refresh"></span> {% trans "Check again" %}
|
<span class="fa fa-refresh"></span> {% trans "Check again" %}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{% elif package_conflicts and package_conflicts_action != 'ignore' %}
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
{% blocktrans trimmed %}
|
||||||
|
<strong>Conflicting Packages:</strong> Some packages installed on
|
||||||
|
the system conflict with the installation of this app. The following
|
||||||
|
packages will be removed if you proceed:
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% for package in package_conflicts %}
|
||||||
|
{{ package }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<input type="submit" class="btn btn-md btn-primary" name="install"
|
<input type="submit" class="btn btn-md btn-primary" name="install"
|
||||||
|
|||||||
@ -275,11 +275,17 @@ class SetupView(TemplateView):
|
|||||||
context['setup_helper'] = setup_helper
|
context['setup_helper'] = setup_helper
|
||||||
context['app_info'] = setup_helper.module.app.info
|
context['app_info'] = setup_helper.module.app.info
|
||||||
|
|
||||||
|
# Report any installed conflicting packages that will be removed.
|
||||||
|
package_conflicts, package_conflicts_action = \
|
||||||
|
setup_helper.get_package_conflicts()
|
||||||
|
context['package_conflicts'] = package_conflicts
|
||||||
|
context['package_conflicts_action'] = package_conflicts_action
|
||||||
|
|
||||||
# Reuse the value of setup_state throughout the view for consistency.
|
# Reuse the value of setup_state throughout the view for consistency.
|
||||||
context['setup_state'] = setup_helper.get_state()
|
context['setup_state'] = setup_helper.get_state()
|
||||||
context['setup_current_operation'] = setup_helper.current_operation
|
context['setup_current_operation'] = setup_helper.current_operation
|
||||||
|
|
||||||
# Perform expensive operation only if needed
|
# Perform expensive operation only if needed.
|
||||||
if not context['setup_current_operation']:
|
if not context['setup_current_operation']:
|
||||||
context[
|
context[
|
||||||
'package_manager_is_busy'] = package.is_package_manager_busy()
|
'package_manager_is_busy'] = package.is_package_manager_busy()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user