mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fixes saltstack/salt#66260 aptpkg.remove unable to locate package for non-existent package
This commit is contained in:
parent
35bc5fc46b
commit
4a6fac0934
3 changed files with 17 additions and 2 deletions
1
changelog/66260.fixed.md
Normal file
1
changelog/66260.fixed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Fixed `aptpkg.remove` "unable to locate package" error for non-existent package
|
|
@ -1067,9 +1067,17 @@ def _uninstall(action="remove", name=None, pkgs=None, **kwargs):
|
|||
|
||||
old = list_pkgs()
|
||||
old_removed = list_pkgs(removed=True)
|
||||
targets = salt.utils.pkg.match_wildcard(old, pkg_params)
|
||||
targets = [
|
||||
_pkg for _pkg in salt.utils.pkg.match_wildcard(old, pkg_params) if _pkg in old
|
||||
]
|
||||
if action == "purge":
|
||||
targets.update(salt.utils.pkg.match_wildcard(old_removed, pkg_params))
|
||||
targets.extend(
|
||||
[
|
||||
_pkg
|
||||
for _pkg in salt.utils.pkg.match_wildcard(old_removed, pkg_params)
|
||||
if _pkg in old_removed
|
||||
]
|
||||
)
|
||||
if not targets:
|
||||
return {}
|
||||
cmd = ["apt-get", "-q", "-y", action]
|
||||
|
|
|
@ -398,3 +398,9 @@ def test_aptpkg_remove_wildcard():
|
|||
assert ret["nginx-light"]["old"]
|
||||
assert not ret["nginx-doc"]["new"]
|
||||
assert ret["nginx-doc"]["old"]
|
||||
|
||||
|
||||
@pytest.mark.skip_if_not_root
|
||||
def test_aptpkg_remove_unknown_package():
|
||||
ret = aptpkg.remove(name="thispackageistotallynotthere")
|
||||
assert not ret
|
||||
|
|
Loading…
Add table
Reference in a new issue