minidlna: Implement force upgrading from older version

Fixes: #2026.

Upgrade from 1.2.1+dfsg-1+b1 to 1.3.x.

Tests:

- Install version 1.2.1+dfsg-1+b1. Change the default media directory. Run
unattended upgrades it will fail to upgrade. With the new patch, run apt update.
This will force upgrade. After upgrade the earlier set media directory is
retained.

- Functional tests run.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2021-01-28 16:16:27 -08:00 committed by James Valleroy
parent 5cd1289198
commit 0b9c4c92e9
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -11,6 +11,7 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.backups.components import BackupRestore
from plinth.modules.firewall.components import Firewall
from plinth.modules.users.components import UsersAndGroups
from plinth.utils import Version
from . import manifest
@ -103,3 +104,20 @@ def get_media_dir():
def set_media_dir(media_dir):
"""Set the media directory from which files will be scanned for sharing."""
actions.superuser_run('minidlna', ['set-media-dir', '--dir', media_dir])
def force_upgrade(helper, packages):
"""Force upgrade minidlna to resolve conffile prompt."""
if 'minidlna' not in packages:
return False
# Allow upgrade from 1.2.1+dfsg-1+b1 to 1.3.x
package = packages['minidlna']
if Version(package['new_version']) > Version('1.4~'):
return False
media_dir = get_media_dir()
helper.install(['minidlna'], force_configuration='new')
set_media_dir(media_dir)
return True