Skip to content

Commit

Permalink
Normalize the package name only once on install/remove
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhestkov committed May 4, 2022
1 parent c56be52 commit 96df577
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
34 changes: 18 additions & 16 deletions salt/modules/yumpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,14 +1533,15 @@ def install(name=None,
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
Expand Down Expand Up @@ -2030,14 +2031,15 @@ def remove(name=None, pkgs=None, **kwargs): # pylint: disable=W0613
elif target in old and version_to_remove in installed_versions:
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(
Expand Down
7 changes: 5 additions & 2 deletions salt/states/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,8 @@ def installed(
pkgs=pkgs,
sources=sources,
reinstall=bool(to_reinstall),
normalize=normalize,
normalize=False,
split_arch=False,
update_holds=update_holds,
ignore_epoch=ignore_epoch,
**kwargs)
Expand Down Expand Up @@ -2743,7 +2744,9 @@ def _uninstall(
'comment': 'The following packages will be {0}d: '
'{1}.'.format(action, ', '.join(targets))}

changes = __salt__['pkg.{0}'.format(action)](name, pkgs=pkgs, version=version, **kwargs)
changes = __salt__['pkg.{0}'.format(action)](
name, pkgs=pkgs, version=version, split_arch=False, **kwargs
)
new = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
failed = []
for param in pkg_params:
Expand Down

0 comments on commit 96df577

Please sign in to comment.