mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +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.config import get_domainname
|
||||||
from plinth.modules.firewall.components import Firewall
|
from plinth.modules.firewall.components import Firewall
|
||||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
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
|
from . import audit, manifest
|
||||||
|
|
||||||
version = 1
|
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_packages = ['clamav', 'clamav-daemon']
|
||||||
clamav_daemons = ['clamav-daemon', 'clamav-freshclam']
|
clamav_daemons = ['clamav-daemon', 'clamav-freshclam']
|
||||||
|
|
||||||
@ -56,10 +49,17 @@ class EmailServerApp(plinth.app.App):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self._add_ui_components()
|
self._add_ui_components()
|
||||||
|
|
||||||
packages = Packages('packages-email-server', [
|
# Other likely install conflicts have been discarded:
|
||||||
'postfix-ldap', 'postfix-sqlite', 'dovecot-pop3d', 'dovecot-imapd',
|
# - msmtp, nullmailer, sendmail don't cause install faults.
|
||||||
'dovecot-ldap', 'dovecot-lmtpd', 'dovecot-managesieved'
|
# - 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)
|
self.add(packages)
|
||||||
|
|
||||||
packages = Packages('packages-email-server-skip-rec', ['rspamd'],
|
packages = Packages('packages-email-server-skip-rec', ['rspamd'],
|
||||||
@ -147,7 +147,8 @@ def setup(helper, old_version=None):
|
|||||||
"""Installs and configures module"""
|
"""Installs and configures module"""
|
||||||
|
|
||||||
def _clear_conflicts():
|
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:
|
if packages_to_remove:
|
||||||
logger.info('Removing conflicting packages: %s',
|
logger.info('Removing conflicting packages: %s',
|
||||||
packages_to_remove)
|
packages_to_remove)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from collections import defaultdict
|
|||||||
import apt
|
import apt
|
||||||
|
|
||||||
import plinth
|
import plinth
|
||||||
from plinth.package import Packages, packages_installed
|
from plinth.package import Packages
|
||||||
from plinth.signals import post_setup
|
from plinth.signals import post_setup
|
||||||
|
|
||||||
from . import package
|
from . import package
|
||||||
@ -187,15 +187,6 @@ 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."""
|
||||||
@ -317,12 +308,6 @@ 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 _module_state_matches(module, state):
|
def _module_state_matches(module, state):
|
||||||
"""Return if the current setup state of a module matches given state."""
|
"""Return if the current setup state of a module matches given state."""
|
||||||
return module.setup_helper.get_state() == state
|
return module.setup_helper.get_state() == state
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
<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' %}
|
{% elif package_conflicts and package_conflicts_action.value != 'ignore' %}
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning" role="alert">
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
<strong>Conflicting Packages:</strong> Some packages installed on
|
<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.daemon import app_is_running
|
||||||
from plinth.modules.config import get_advanced_mode
|
from plinth.modules.config import get_advanced_mode
|
||||||
from plinth.modules.firewall.components import get_port_forwarding_info
|
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 plinth.translation import get_language_from_request, set_language
|
||||||
|
|
||||||
from . import forms, frontpage
|
from . import forms, frontpage
|
||||||
@ -275,7 +276,7 @@ class SetupView(TemplateView):
|
|||||||
|
|
||||||
# Report any installed conflicting packages that will be removed.
|
# Report any installed conflicting packages that will be removed.
|
||||||
package_conflicts, package_conflicts_action = \
|
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'] = package_conflicts
|
||||||
context['package_conflicts_action'] = package_conflicts_action
|
context['package_conflicts_action'] = package_conflicts_action
|
||||||
|
|
||||||
@ -319,6 +320,21 @@ class SetupView(TemplateView):
|
|||||||
|
|
||||||
return super(SetupView, self).dispatch(request, *args, **kwargs)
|
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):
|
def notification_dismiss(request, id):
|
||||||
"""Dismiss a notification."""
|
"""Dismiss a notification."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user