pacman: Fix removing locally installed packages (#4464)

* pacman: Fix removing locally installed packages

Without this, using `absent` state for a locally installed package (for example from AUR, or from a package that was dropped from repositories) would return that package is already removed, despite remaining installed

* Undo unwanted whitespace removal

* Add changelog fragment

* Update changelogs/fragments/4464-pacman-fix-local-remove.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Add test.

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Martin 2022-04-13 13:34:33 +02:00 committed by GitHub
commit 3c515dd221
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 2 deletions

View file

@ -610,8 +610,9 @@ class Pacman(object):
# Expand group members
for group_member in self.inventory["available_groups"][pkg]:
pkg_list.append(Package(name=group_member, source=group_member))
elif pkg in self.inventory["available_pkgs"]:
# just a regular pkg
elif pkg in self.inventory["available_pkgs"] or pkg in self.inventory["installed_pkgs"]:
# Just a regular pkg, either available in the repositories,
# or locally installed, which we need to know for absent state
pkg_list.append(Package(name=pkg, source=pkg))
else:
# Last resort, call out to pacman to extract the info,