From 2472b594845d348378cb6dba36fa0c924378b96a Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 1 Apr 2020 18:31:49 -0400 Subject: [PATCH] radicale: Support upgrade to any 2.x version Closes #1429 Test: - Install latest radicale (2.1.11-8). Downgrade python3-radicale and radicale to 2.1.11-6. Change access rights setting to something other than the default. Run `unattended-upgrades -v` and confirm that there is a conffile prompt. Run `apt update` and check that log show radicale is upgraded. Confirm that access rights are still set as selected. Signed-off-by: James Valleroy Reviewed-by: Nektarios Katakis --- plinth/modules/radicale/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/plinth/modules/radicale/__init__.py b/plinth/modules/radicale/__init__.py index 8c3e26ba6..3ab67c2b3 100644 --- a/plinth/modules/radicale/__init__.py +++ b/plinth/modules/radicale/__init__.py @@ -17,7 +17,7 @@ from plinth import cfg, frontpage, menu from plinth.daemon import Daemon from plinth.modules.apache.components import Uwsgi, Webserver from plinth.modules.firewall.components import Firewall -from plinth.utils import format_lazy +from plinth.utils import format_lazy, Version from .manifest import backup, clients # noqa, pylint: disable=unused-import @@ -206,6 +206,27 @@ def setup(helper, old_version=None): helper.call('post', app.enable) +def force_upgrade(helper, packages): + """Force upgrade radicale to resolve conffile prompt.""" + if 'radicale' not in packages: + return False + + # Allow upgrade from 2.* to newer 2.* + current_version = get_package_version() + if not current_version or current_version < VERSION_2: + return False + + package = packages['radicale'] + if Version(package['new_version']) > Version('3~'): + return False + + rights = get_rights_value() + helper.install(['radicale'], force_configuration='new') + actions.superuser_run('radicale', ['configure', '--rights_type', rights]) + + return True + + def get_package_version(): try: proc = subprocess.run(['radicale', '--version'],