mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
*: Drop module level package_conflicts and use component API
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
82876a6e23
commit
fb40bb7f42
@ -14,19 +14,12 @@ from plinth.modules.apache.components import Webserver
|
||||
from plinth.modules.config import get_domainname
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
||||
from plinth.package import Packages, packages_installed, remove
|
||||
from plinth.package import Packages, remove
|
||||
|
||||
from . import audit, manifest
|
||||
|
||||
version = 1
|
||||
|
||||
# Other likely install conflicts have been discarded:
|
||||
# - msmtp, nullmailer, sendmail don't cause install faults.
|
||||
# - qmail and smail are missing in Bullseye (Not tested,
|
||||
# but less likely due to that).
|
||||
package_conflicts = ('exim4-base', 'exim4-config', 'exim4-daemon-light')
|
||||
package_conflicts_action = 'ignore'
|
||||
|
||||
clamav_packages = ['clamav', 'clamav-daemon']
|
||||
clamav_daemons = ['clamav-daemon', 'clamav-freshclam']
|
||||
|
||||
@ -56,10 +49,17 @@ class EmailServerApp(plinth.app.App):
|
||||
super().__init__()
|
||||
self._add_ui_components()
|
||||
|
||||
packages = Packages('packages-email-server', [
|
||||
'postfix-ldap', 'postfix-sqlite', 'dovecot-pop3d', 'dovecot-imapd',
|
||||
'dovecot-ldap', 'dovecot-lmtpd', 'dovecot-managesieved'
|
||||
])
|
||||
# Other likely install conflicts have been discarded:
|
||||
# - msmtp, nullmailer, sendmail don't cause install faults.
|
||||
# - qmail and smail are missing in Bullseye (Not tested,
|
||||
# but less likely due to that).
|
||||
packages = Packages(
|
||||
'packages-email-server', [
|
||||
'postfix-ldap', 'postfix-sqlite', 'dovecot-pop3d',
|
||||
'dovecot-imapd', 'dovecot-ldap', 'dovecot-lmtpd',
|
||||
'dovecot-managesieved'
|
||||
], conflicts=['exim4-base', 'exim4-config', 'exim4-daemon-light'],
|
||||
conflicts_action=Packages.ConflictsAction.IGNORE)
|
||||
self.add(packages)
|
||||
|
||||
packages = Packages('packages-email-server-skip-rec', ['rspamd'],
|
||||
@ -147,7 +147,8 @@ def setup(helper, old_version=None):
|
||||
"""Installs and configures module"""
|
||||
|
||||
def _clear_conflicts():
|
||||
packages_to_remove = packages_installed(package_conflicts)
|
||||
component = app.get_component('packages-email-server')
|
||||
packages_to_remove = component.find_conflicts()
|
||||
if packages_to_remove:
|
||||
logger.info('Removing conflicting packages: %s',
|
||||
packages_to_remove)
|
||||
|
||||
@ -13,7 +13,7 @@ from collections import defaultdict
|
||||
import apt
|
||||
|
||||
import plinth
|
||||
from plinth.package import Packages, packages_installed
|
||||
from plinth.package import Packages
|
||||
from plinth.signals import post_setup
|
||||
|
||||
from . import package
|
||||
@ -187,15 +187,6 @@ 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."""
|
||||
@ -317,12 +308,6 @@ 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 _module_state_matches(module, state):
|
||||
"""Return if the current setup state of a module matches given state."""
|
||||
return module.setup_helper.get_state() == state
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
<span class="fa fa-refresh"></span> {% trans "Check again" %}
|
||||
</button>
|
||||
</div>
|
||||
{% elif package_conflicts and package_conflicts_action != 'ignore' %}
|
||||
{% elif package_conflicts and package_conflicts_action.value != 'ignore' %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
{% blocktrans trimmed %}
|
||||
<strong>Conflicting Packages:</strong> Some packages installed on
|
||||
|
||||
@ -20,6 +20,7 @@ from plinth import app, package
|
||||
from plinth.daemon import app_is_running
|
||||
from plinth.modules.config import get_advanced_mode
|
||||
from plinth.modules.firewall.components import get_port_forwarding_info
|
||||
from plinth.package import Packages
|
||||
from plinth.translation import get_language_from_request, set_language
|
||||
|
||||
from . import forms, frontpage
|
||||
@ -275,7 +276,7 @@ class SetupView(TemplateView):
|
||||
|
||||
# Report any installed conflicting packages that will be removed.
|
||||
package_conflicts, package_conflicts_action = \
|
||||
setup_helper.get_package_conflicts()
|
||||
self._get_app_package_conflicts(setup_helper.module.app)
|
||||
context['package_conflicts'] = package_conflicts
|
||||
context['package_conflicts_action'] = package_conflicts_action
|
||||
|
||||
@ -319,6 +320,21 @@ class SetupView(TemplateView):
|
||||
|
||||
return super(SetupView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def _get_app_package_conflicts(app_):
|
||||
"""Return packages that may conflict with packages of an app."""
|
||||
components = app_.get_components_of_type(Packages)
|
||||
conflicts = []
|
||||
conflicts_action = None
|
||||
for component in components:
|
||||
component_conflicts = component.find_conflicts()
|
||||
if component_conflicts:
|
||||
conflicts += component_conflicts
|
||||
if conflicts_action in (None, Packages.ConflictsAction.IGNORE):
|
||||
conflicts_action = component.conflicts_action
|
||||
|
||||
return conflicts, conflicts_action
|
||||
|
||||
|
||||
def notification_dismiss(request, id):
|
||||
"""Dismiss a notification."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user