mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #31660 from terminalmage/issue31619
Remove epoch from version string if present when installing with yum
This commit is contained in:
commit
bd4d12a155
2 changed files with 51 additions and 15 deletions
|
@ -1248,6 +1248,13 @@ def install(name=None,
|
|||
# not None, since the only way version_num is not None is if RPM
|
||||
# metadata parsing was successful.
|
||||
if pkg_type == 'repository':
|
||||
if _yum() == 'yum':
|
||||
# yum install does not support epoch without the arch, and
|
||||
# we won't know what the arch will be when it's not
|
||||
# provided. It could either be the OS architecture, or
|
||||
# 'noarch', and we don't make that distinction in the
|
||||
# pkg.list_pkgs return data.
|
||||
version_num = version_num.split(':', 1)[-1]
|
||||
arch = ''
|
||||
try:
|
||||
namepart, archpart = pkgname.rsplit('.', 1)
|
||||
|
|
|
@ -42,14 +42,20 @@ _PKG_TARGETS_DOT = {
|
|||
'7': 'tomcat-el-2.2-api'}
|
||||
}
|
||||
|
||||
# Test packages with epoch in version
|
||||
# (https://github.com/saltstack/salt/issues/31619)
|
||||
_PKG_TARGETS_EPOCH = {
|
||||
'RedHat': {'7': 'comps-extras'},
|
||||
}
|
||||
|
||||
|
||||
@destructiveTest
|
||||
@requires_salt_modules('pkg.version', 'pkg.latest_version')
|
||||
class PkgTest(integration.ModuleCase,
|
||||
integration.SaltReturnAssertsMixIn):
|
||||
'''
|
||||
pkg.installed state tests
|
||||
'''
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_001_installed(self, grains=None):
|
||||
|
@ -77,7 +83,6 @@ class PkgTest(integration.ModuleCase,
|
|||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_002_installed_with_version(self, grains=None):
|
||||
|
@ -119,7 +124,6 @@ class PkgTest(integration.ModuleCase,
|
|||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_003_installed_multipkg(self, grains=None):
|
||||
|
@ -146,7 +150,6 @@ class PkgTest(integration.ModuleCase,
|
|||
ret = self.run_state('pkg.removed', name=None, pkgs=pkg_targets)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_004_installed_multipkg_with_version(self, grains=None):
|
||||
|
@ -164,7 +167,7 @@ class PkgTest(integration.ModuleCase,
|
|||
# Make sure that we have targets that match the os_family. If this
|
||||
# fails then the _PKG_TARGETS dict above needs to have an entry added,
|
||||
# with two packages that are not installed before these tests are run
|
||||
self.assertTrue(pkg_targets)
|
||||
self.assertTrue(bool(pkg_targets))
|
||||
|
||||
if os_family == 'Arch':
|
||||
for idx in xrange(13):
|
||||
|
@ -180,7 +183,7 @@ class PkgTest(integration.ModuleCase,
|
|||
# If this assert fails, we need to find new targets, this test needs to
|
||||
# be able to test successful installation of packages, so these
|
||||
# packages need to not be installed before we run the states below
|
||||
self.assertTrue(version)
|
||||
self.assertTrue(bool(version))
|
||||
|
||||
pkgs = [{pkg_targets[0]: version}, pkg_targets[1]]
|
||||
|
||||
|
@ -189,7 +192,6 @@ class PkgTest(integration.ModuleCase,
|
|||
ret = self.run_state('pkg.removed', name=None, pkgs=pkg_targets)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_005_installed_32bit(self, grains=None):
|
||||
|
@ -214,14 +216,13 @@ class PkgTest(integration.ModuleCase,
|
|||
# needs to be able to test successful installation of packages, so
|
||||
# the target needs to not be installed before we run the states
|
||||
# below
|
||||
self.assertFalse(version)
|
||||
self.assertFalse(bool(version))
|
||||
|
||||
ret = self.run_state('pkg.installed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_006_installed_32bit_with_version(self, grains=None):
|
||||
|
@ -255,14 +256,13 @@ class PkgTest(integration.ModuleCase,
|
|||
# needs to be able to test successful installation of the package, so
|
||||
# the target needs to not be installed before we run the states
|
||||
# below
|
||||
self.assertTrue(version)
|
||||
self.assertTrue(bool(version))
|
||||
|
||||
ret = self.run_state('pkg.installed', name=target, version=version)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_with_dot_in_pkgname(self, grains=None):
|
||||
|
@ -274,13 +274,42 @@ class PkgTest(integration.ModuleCase,
|
|||
'''
|
||||
os_family = grains.get('os_family', '')
|
||||
os_version = grains.get('osmajorrelease', [''])[0]
|
||||
if os_family in _PKG_TARGETS_DOT:
|
||||
target = _PKG_TARGETS_DOT.get(os_family, '').get(os_version, '')
|
||||
else:
|
||||
target = None
|
||||
target = _PKG_TARGETS_DOT.get(os_family, {}).get(os_version)
|
||||
if target:
|
||||
version = self.run_function('pkg.latest_version', [target])
|
||||
# If this assert fails, we need to find a new target. This test
|
||||
# needs to be able to test successful installation of the package, so
|
||||
# the target needs to not be installed before we run the
|
||||
# pkg.installed state below
|
||||
self.assertTrue(bool(version))
|
||||
ret = self.run_state('pkg.installed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@requires_system_grains
|
||||
def test_pkg_with_epoch_in_version(self, grains=None):
|
||||
'''
|
||||
This tests for the regression found in the following issue:
|
||||
https://github.com/saltstack/salt/issues/8614
|
||||
|
||||
This is a destructive test as it installs a package
|
||||
'''
|
||||
os_family = grains.get('os_family', '')
|
||||
os_version = grains.get('osmajorrelease', [''])[0]
|
||||
target = _PKG_TARGETS_EPOCH.get(os_family, {}).get(os_version)
|
||||
if target:
|
||||
version = self.run_function('pkg.latest_version', [target])
|
||||
# If this assert fails, we need to find a new target. This test
|
||||
# needs to be able to test successful installation of the package, so
|
||||
# the target needs to not be installed before we run the
|
||||
# pkg.installed state below
|
||||
self.assertTrue(bool(version))
|
||||
ret = self.run_state('pkg.installed', name=target, version=version)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('pkg.removed', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue