setup: Fix issue with pending app update and force upgrade

Closes: #2490

- When app update and force upgrade are pending on an app, app.setup() is run
during initialization. During setup(), force upgrade is first run as expected.
However, force upgrade does not do it's job when an app needs version upgrade.
setup() then tries to run package install() for the app and fails because
configuration file prompt is pending.

Tests:

- On a fresh bookworm container, update all packages. Run freedombox and ensure
that first setup has been completed. Stop freedombox and increment the firewall
app version. Then change sources.list and change bookworm to testing. Run apt
update. Then start the fredombox service. Notice that firewall app setup is run.
During the setup, force upgrader is executed. It install the newer firewall
package with the newer configuration file and performs the configuration file
changes. After that setup process continues and completes successfully.
firewalld package has been upgraded from 1.3.x to 2.3.x. firewalld service is
running. In /etc/firewalld/firewalld.conf default zone is set to external and
backend is set to nftables.

- Rerun the above test without the patches and notice that force upgrader does
not recognize firewall as a package to upgrade and setup() fails when trying to
install() packages. This is run in a loop continuously.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-03-08 15:49:38 -08:00 committed by James Valleroy
parent eaed05e02b
commit fa57610b07
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -647,9 +647,13 @@ class ForceUpgrader():
# App does not implement force upgrade
continue
if (app.get_setup_state() != app_module.App.SetupState.UP_TO_DATE):
# App is not installed.
# Or needs an update, let it update first.
if (app.get_setup_state() == app_module.App.SetupState.NEEDS_SETUP
):
# If an app is not installed don't considered it. If an app
# needs an update, it may have to do a force upgrade before
# running app version update. This is because the app version
# update process will include installing packages that will
# fail due to pending configuration file updates.
continue
for component in app.get_components_of_type(Packages):