From fa57610b0714f5e84d004242c84270f2ba7fdbcf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 8 Mar 2025 15:49:38 -0800 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/setup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plinth/setup.py b/plinth/setup.py index 3ae80ea67..faafc14f9 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -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):