Pacman: Add support for install reason (#4956)

* Pacman: Add support for setting install reason

* Improved description

* Fix documentation

* Add changelog fragment

* Use source for installation

* Get all reasons at once

* Removed default for reason

* Added version info to documentation

* Fix NameError

* Moved determination of reason to _build_inventory

* Fix duplication and sanity errors

* adjust tests for changed inventory

* Documentation: remove empty default for reason

* mention packages with changed reason in exit params/info

* Added integration tests for reason and reason_for

Inspired by the integration tests for url packages

* Correct indentation

* Fix indentation

* Also sort changed packages in normal mode

* Also sort result in unit test

* Apply suggestions from code review

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

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Minei3oat 2022-07-31 22:10:49 +02:00 committed by GitHub
commit 9f3841703f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 230 additions and 9 deletions

View file

@ -100,6 +100,19 @@ valid_inventory = {
"upgradable_pkgs": {
"sqlite": VersionTuple(current="3.36.0-1", latest="3.37.0-1"),
},
"pkg_reasons": {
"file": "explicit",
"filesystem": "explicit",
"findutils": "explicit",
"gawk": "explicit",
"gettext": "explicit",
"grep": "explicit",
"gzip": "explicit",
"pacman": "explicit",
"pacman-mirrorlist": "dependency",
"sed": "explicit",
"sqlite": "explicit",
},
}
empty_inventory = {
@ -108,6 +121,7 @@ empty_inventory = {
"installed_groups": {},
"available_groups": {},
"upgradable_pkgs": {},
"pkg_reasons": {},
}
@ -255,6 +269,27 @@ class TestPacman:
""",
"",
),
( # pacman --query --explicit
0,
"""file 5.41-1
filesystem 2021.11.11-1
findutils 4.8.0-1
gawk 5.1.1-1
gettext 0.21-1
grep 3.7-1
gzip 1.11-1
pacman 6.0.1-2
sed 4.8-1
sqlite 3.36.0-1
""",
"",
),
( # pacman --query --deps
0,
"""pacman-mirrorlist 20211114-1
""",
"",
),
],
None,
),
@ -272,6 +307,8 @@ class TestPacman:
"",
"warning: config file /etc/pacman.conf, line 34: directive 'TotalDownload' in section 'options' not recognized.",
),
(0, "", ""),
(0, "", ""),
],
None,
),
@ -288,6 +325,8 @@ class TestPacman:
"partial\npkg\\nlist",
"some warning",
),
(0, "", ""),
(0, "", ""),
],
AnsibleFailJson,
),
@ -375,6 +414,8 @@ class TestPacman:
(["pacman", "--query", "--groups"], {'check_rc': True}, 0, '', ''),
(["pacman", "--sync", "--groups", "--groups"], {'check_rc': True}, 0, '', ''),
(["pacman", "--query", "--upgrades"], {'check_rc': False}, 0, '', ''),
(["pacman", "--query", "--explicit"], {'check_rc': True}, 0, 'foo 1.0.0-1', ''),
(["pacman", "--query", "--deps"], {'check_rc': True}, 0, '', ''),
],
False,
),
@ -843,7 +884,7 @@ class TestPacman:
],
"state": "present",
},
["sudo", "somepackage", "otherpkg"],
["otherpkg", "somepackage", "sudo"],
[
Package("sudo", "sudo"),
Package("grep", "grep"),