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 <jvalleroy@mailbox.org>
Reviewed-by: Nektarios Katakis <iam@nektarioskatakis.xyz>
This commit is contained in:
James Valleroy 2020-04-01 18:31:49 -04:00 committed by Nektarios Katakis
parent 24129482a6
commit 2472b59484
No known key found for this signature in database
GPG Key ID: 9CA475E691EBCF76

View File

@ -17,7 +17,7 @@ from plinth import cfg, frontpage, menu
from plinth.daemon import Daemon from plinth.daemon import Daemon
from plinth.modules.apache.components import Uwsgi, Webserver from plinth.modules.apache.components import Uwsgi, Webserver
from plinth.modules.firewall.components import Firewall 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 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) 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(): def get_package_version():
try: try:
proc = subprocess.run(['radicale', '--version'], proc = subprocess.run(['radicale', '--version'],