From e26a4b71eb28e08e3e28de4732b591affaf25f5b Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 6 Aug 2025 11:16:15 -0700 Subject: [PATCH] package: Uninstall packages even if they are not in apt cache Tests: - Install matrix-synapse app by adding 'unstable' in apt sources.list. Then remove 'unstable' from apt sources.list. Then matrix-synapse package will no longer be found in the apt's cache. - Try to uninstall the package. Without patch, the process errors out. With patch, uninstall completes successfully. - While matrix-synapse app is installed and apt cache does not contain matrix-synapse package, install and uninstall bepasty app. Without patch, uninstall fails. With patch, uninstall succeeds. - Install and uninstall minetest app. 3d armor mod package is successfully installed. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Joseph Nuthalapati --- plinth/package.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plinth/package.py b/plinth/package.py index 0550cfe7c..e189e84a1 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -194,8 +194,11 @@ class Packages(app_module.FollowerComponent): # Ensure package list is update-to-date before looking at dependencies. refresh_package_lists() - # List of packages to purge from the system - packages = self.get_actual_packages() + # List of packages to purge from the system. Be resilient to a package + # not being found in apt's cache by not using get_actual_packages(). If + # a package expression is listed as (package1 | package2) then try to + # remove both packages. + packages = self.possible_packages logger.info('App\'s list of packages to remove: %s', packages) packages = self._filter_packages_to_keep(packages) @@ -304,7 +307,7 @@ class Packages(app_module.FollowerComponent): # Remove packages used by other installed apps for component in app.get_components_of_type(Packages): - keep_packages |= set(component.get_actual_packages()) + keep_packages |= set(component.possible_packages) # Get list of all the dependencies of packages to keep. keep_packages_with_deps: set[str] = set()