Normalize the package names only once on install/remove

This commit is contained in:
Victor Zhestkov 2022-02-18 15:11:34 +03:00 committed by Victor Zhestkov
parent 427718c5ae
commit 806ebae86e
No known key found for this signature in database
GPG key ID: A3B3ECC617754182
2 changed files with 26 additions and 18 deletions

View file

@ -1458,7 +1458,12 @@ def install(
try:
pkg_params, pkg_type = __salt__["pkg_resource.parse_targets"](
name, pkgs, sources, saltenv=saltenv, normalize=normalize, **kwargs
name,
pkgs,
sources,
saltenv=saltenv,
normalize=normalize and kwargs.get("split_arch", True),
**kwargs
)
except MinionError as exc:
raise CommandExecutionError(exc)
@ -1605,14 +1610,15 @@ def install(
if ignore_epoch is True:
version_num = version_num.split(":", 1)[-1]
arch = ""
try:
namepart, archpart = pkgname.rsplit(".", 1)
except ValueError:
pass
else:
if archpart in salt.utils.pkg.rpm.ARCHES:
arch = "." + archpart
pkgname = namepart
if kwargs.get("split_arch", True):
try:
namepart, archpart = pkgname.rsplit(".", 1)
except ValueError:
pass
else:
if archpart in salt.utils.pkg.rpm.ARCHES:
arch = "." + archpart
pkgname = namepart
if "*" in version_num:
# Resolve wildcard matches
@ -2161,14 +2167,15 @@ def remove(name=None, pkgs=None, **kwargs): # pylint: disable=W0613
elif target in old and version_to_remove in old[target].split(","):
arch = ""
pkgname = target
try:
namepart, archpart = target.rsplit(".", 1)
except ValueError:
pass
else:
if archpart in salt.utils.pkg.rpm.ARCHES:
arch = "." + archpart
pkgname = namepart
if kwargs.get("split_arch", True):
try:
namepart, archpart = pkgname.rsplit(".", 1)
except ValueError:
pass
else:
if archpart in salt.utils.pkg.rpm.ARCHES:
arch = "." + archpart
pkgname = namepart
# Since we don't always have the arch info, epoch information has to parsed out. But
# a version check was already performed, so we are removing the right version.
targets.append(

View file

@ -1876,6 +1876,7 @@ def installed(
normalize=normalize,
update_holds=update_holds,
ignore_epoch=ignore_epoch,
split_arch=False,
**kwargs
)
except CommandExecutionError as exc:
@ -2943,7 +2944,7 @@ def _uninstall(
}
changes = __salt__["pkg.{}".format(action)](
name, pkgs=pkgs, version=version, **kwargs
name, pkgs=pkgs, version=version, split_arch=False, **kwargs
)
new = __salt__["pkg.list_pkgs"](versions_as_list=True, **kwargs)
failed = []