mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
upgrades: Run dpkg/apt fixes before dist upgrade
Closes: #2490 Tests: - Unit tests works. - On a fresh stable container, enable auto updates. Run 'apt install mumble-server' and kill the apt process when it is unpacking. After this any apt install command will ask for running dpkg --configure -a. At this time, run the Testing dist upgrade. Dist upgrade starts successfully and then shows the message 'Fixing any broken apt/dpkg states...'. It also shows that packages that were not setup have been setup. Dist upgrades proceeds after that. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
bbb59e16de
commit
91c5931c59
@ -223,6 +223,13 @@ def _apt_update():
|
|||||||
_apt_run(['update'])
|
_apt_run(['update'])
|
||||||
|
|
||||||
|
|
||||||
|
def _apt_fix():
|
||||||
|
"""Try to fix any problems with apt/dpkg before the upgrade."""
|
||||||
|
logger.info('Fixing any broken apt/dpkg states...')
|
||||||
|
subprocess.run(['dpkg', '--configure', '-a'], check=False)
|
||||||
|
_apt_run(['--fix-broken', 'install'])
|
||||||
|
|
||||||
|
|
||||||
def _apt_autoremove():
|
def _apt_autoremove():
|
||||||
"""Run 'apt autoremove'."""
|
"""Run 'apt autoremove'."""
|
||||||
logger.info('Running apt autoremove...')
|
logger.info('Running apt autoremove...')
|
||||||
@ -298,6 +305,7 @@ def perform():
|
|||||||
_services_disable(), \
|
_services_disable(), \
|
||||||
_apt_hold_packages():
|
_apt_hold_packages():
|
||||||
_apt_update()
|
_apt_update()
|
||||||
|
_apt_fix()
|
||||||
_debconf_set_selections()
|
_debconf_set_selections()
|
||||||
_packages_remove_obsolete()
|
_packages_remove_obsolete()
|
||||||
_apt_full_upgrade()
|
_apt_full_upgrade()
|
||||||
|
|||||||
@ -283,6 +283,17 @@ def test_apt_update(apt_run):
|
|||||||
apt_run.assert_called_with(['update'])
|
apt_run.assert_called_with(['update'])
|
||||||
|
|
||||||
|
|
||||||
|
@patch('plinth.modules.upgrades.distupgrade._apt_run')
|
||||||
|
@patch('subprocess.run')
|
||||||
|
def test_apt_fix(run, apt_run):
|
||||||
|
"""Test that apt fixes work."""
|
||||||
|
distupgrade._apt_fix()
|
||||||
|
assert run.call_args_list == [
|
||||||
|
call(['dpkg', '--configure', '-a'], check=False)
|
||||||
|
]
|
||||||
|
assert apt_run.call_args_list == [call(['--fix-broken', 'install'])]
|
||||||
|
|
||||||
|
|
||||||
@patch('plinth.modules.upgrades.distupgrade._apt_run')
|
@patch('plinth.modules.upgrades.distupgrade._apt_run')
|
||||||
def test_apt_autoremove(apt_run):
|
def test_apt_autoremove(apt_run):
|
||||||
"""Test that apt autoremove works."""
|
"""Test that apt autoremove works."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user