From 6c3b2e1f82a991f4e298b0392ba752830841e9f1 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 11 Nov 2025 12:39:24 -0800 Subject: [PATCH] package: Prevent freedombox's deps from removal during app uninstall - If an app declares dependency on package that is also a dependency for freedombox, then during the app's uninstall, the dependency is attempt to be removed and will fail (because freedombox package will be held state). - Add freedombox (and thus its dependencies) to the list packages that should be removed from list of packages to be removed during app uninstall. - In test case, update list of packages attempted removal as the 'freedombox' package is installed only in some environments. Tests: - Uninstall janus works. Log messages show that libjs-bootstrap5 and node-popper2 are in the list of packages originally set to removed during app uninstall but are later filtered out. - Run pytest with 'freedombox' package installed and ensure all tests pass. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/package.py | 6 +++--- plinth/tests/test_package.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plinth/package.py b/plinth/package.py index 14efcecf2..ab2edcc9b 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -308,9 +308,9 @@ class Packages(app_module.FollowerComponent): """ packages_set: set[str] = set(packages) - # Get list of packages needed by other installed apps (packages to - # keep). - keep_packages: set[str] = set() + # Get list of packages needed by other installed apps and by freedombox + # itself (packages to keep). + keep_packages: set[str] = {'freedombox'} for app in app_module.App.list(): # uninstall() will be called on Packages of this app separately # for uninstalling this app. diff --git a/plinth/tests/test_package.py b/plinth/tests/test_package.py index c5153479d..40baad205 100644 --- a/plinth/tests/test_package.py +++ b/plinth/tests/test_package.py @@ -178,11 +178,11 @@ def test_packages_uninstall(uninstall, _refresh_package_lists): """Test app""" app_id = 'test-app' - component = Packages('test-component', ['python3', 'bash']) + component = Packages('test-component', ['bash', 'dash']) app = TestApp() app.add(component) app.uninstall() - uninstall.assert_has_calls([call(['python3', 'bash'], purge=True)]) + uninstall.assert_has_calls([call(['bash', 'dash'], purge=True)]) @patch('plinth.package.refresh_package_lists')