mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
upgrades: Trigger special package operations in a simpler way
Closes: #2498. - Now, as soon as service starts, it will perform force upgrade operations and post-installation app setup operations. So, it is no loner necessary to wait for 10 minutes and trigger the one of the operations with 'apt-get update'. - In addition, the post-installation operations are triggered more explicitly and sooner. Tests: - Install MediaWiki on Bookworm. Run distribution upgrade to Trixie and it works. Log shows that post install operations were performed and mediawiki setup was rerun. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
bc116e028a
commit
42586feee8
@ -72,10 +72,9 @@ distribution_info: dict = {
|
||||
}
|
||||
|
||||
|
||||
def _apt_run(arguments: list[str], enable_triggers: bool = False):
|
||||
def _apt_run(arguments: list[str]):
|
||||
"""Run an apt command and ensure that output is written to stdout."""
|
||||
returncode = action_utils.run_apt_command(arguments, stdout=None,
|
||||
enable_triggers=enable_triggers)
|
||||
returncode = action_utils.run_apt_command(arguments, stdout=None)
|
||||
if returncode:
|
||||
raise RuntimeError(
|
||||
f'Apt command failed with return code: {returncode}')
|
||||
@ -318,10 +317,10 @@ def _packages_remove_obsolete() -> None:
|
||||
_apt_run(['remove'] + OBSOLETE_PACKAGES)
|
||||
|
||||
|
||||
def _apt_update(enable_triggers: bool = False):
|
||||
def _apt_update():
|
||||
"""Run 'apt update'."""
|
||||
logger.info('Updating Apt cache...')
|
||||
_apt_run(['update'], enable_triggers=enable_triggers)
|
||||
_apt_run(['update'])
|
||||
|
||||
|
||||
def _apt_fix():
|
||||
@ -365,12 +364,6 @@ def _freedombox_restart():
|
||||
action_utils.service_restart('plinth')
|
||||
|
||||
|
||||
def _wait():
|
||||
"""Wait for 10 minutes before performing remaining actions."""
|
||||
logger.info('Waiting for 10 minutes...')
|
||||
time.sleep(10 * 60)
|
||||
|
||||
|
||||
def _trigger_on_complete():
|
||||
"""Trigger the on complete step in a separate service."""
|
||||
# The dist-upgrade process will be run /etc/apt/sources.list file bind
|
||||
@ -414,8 +407,6 @@ def perform():
|
||||
|
||||
_unattended_upgrades_run()
|
||||
_freedombox_restart()
|
||||
_wait()
|
||||
_apt_update(enable_triggers=True)
|
||||
_trigger_on_complete()
|
||||
|
||||
|
||||
|
||||
@ -368,11 +368,7 @@ def test_packages_remove_obsolete(apt_run):
|
||||
def test_apt_update(apt_run):
|
||||
"""Test that apt update works."""
|
||||
distupgrade._apt_update()
|
||||
apt_run.assert_called_with(['update'], enable_triggers=False)
|
||||
|
||||
apt_run.reset_mock()
|
||||
distupgrade._apt_update(enable_triggers=True)
|
||||
apt_run.assert_called_with(['update'], enable_triggers=True)
|
||||
apt_run.assert_called_with(['update'])
|
||||
|
||||
|
||||
@patch('plinth.modules.upgrades.distupgrade._apt_run')
|
||||
@ -419,13 +415,6 @@ def test_freedombox_restart(service_restart):
|
||||
service_restart.assert_called_with('plinth')
|
||||
|
||||
|
||||
@patch('time.sleep')
|
||||
def test_wait(sleep):
|
||||
"""Test that sleeping works."""
|
||||
distupgrade._wait()
|
||||
sleep.assert_called_with(600)
|
||||
|
||||
|
||||
@patch('subprocess.run')
|
||||
def test_trigger_on_complete(run):
|
||||
"""Test triggering post completion process."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user