dnf module: package not installed with state=latest
dnf: name=PACKAGE state=latest is reponsible for two use cases: - to install a package if not already installed. - to update the package to the latest if already installed. The latter use cases is not handled properly as base.upgrade does not throw dnf.exceptions.MarkingError if a package is not installed. Setting base.conf.best = True ensures a package is installed or updated to the latest when calling base.install. Sign-off: jsilhan@redhat.com Sign-off: jchaloup@redhat.com
This commit is contained in:
parent
221d1b7744
commit
6e201948bc
1 changed files with 4 additions and 5 deletions
|
@ -281,11 +281,10 @@ def ensure(module, base, state, names):
|
||||||
# If not already installed, try to install.
|
# If not already installed, try to install.
|
||||||
base.group_install(group, const.GROUP_PACKAGE_TYPES)
|
base.group_install(group, const.GROUP_PACKAGE_TYPES)
|
||||||
for pkg_spec in pkg_specs:
|
for pkg_spec in pkg_specs:
|
||||||
try:
|
# best effort causes to install the latest package
|
||||||
base.upgrade(pkg_spec)
|
# even if not previously installed
|
||||||
except dnf.exceptions.MarkingError:
|
base.conf.best = True
|
||||||
# If not already installed, try to install.
|
base.install(pkg_spec)
|
||||||
_mark_package_install(module, base, pkg_spec)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# state == absent
|
# state == absent
|
||||||
|
|
Loading…
Reference in a new issue