mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #36609 from rallytime/merge-2016.3
[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
commit
e23af98d97
@ -1725,3 +1725,35 @@ def updating(name,
|
||||
output_loglevel='trace',
|
||||
python_shell=False
|
||||
)
|
||||
|
||||
|
||||
def version_cmp(pkg1, pkg2, ignore_epoch=False):
|
||||
'''
|
||||
Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
|
||||
pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
|
||||
making the comparison.
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pkg.version_cmp '2.1.11' '2.1.12'
|
||||
'''
|
||||
# Don't worry about ignore_epoch since we're shelling out to pkg.
|
||||
sym = {
|
||||
'<': -1,
|
||||
'>': 1,
|
||||
'=': 0,
|
||||
}
|
||||
try:
|
||||
cmd = ['pkg', 'version', '--test-version', pkg1, pkg2]
|
||||
ret = __salt__['cmd.run_all'](cmd,
|
||||
output_loglevel='trace',
|
||||
python_shell=False,
|
||||
ignore_retcode=True)
|
||||
except Exception as exc:
|
||||
log.error(exc)
|
||||
|
||||
if ret['stdout'] in sym:
|
||||
return sym[ret['stdout']]
|
||||
return None
|
||||
|
@ -165,6 +165,10 @@ def _fulfills_version_spec(versions, oper, desired_version,
|
||||
otherwise returns False
|
||||
'''
|
||||
cmp_func = __salt__.get('pkg.version_cmp')
|
||||
# stripping "with_origin" dict wrapper
|
||||
if salt.utils.is_freebsd():
|
||||
if isinstance(versions, dict) and 'version' in versions:
|
||||
versions = versions['version']
|
||||
for ver in versions:
|
||||
if salt.utils.compare_versions(ver1=ver,
|
||||
oper=oper,
|
||||
@ -1265,10 +1269,14 @@ def installed(
|
||||
not_modified_hold = None
|
||||
failed_hold = None
|
||||
if targets or to_reinstall:
|
||||
force = False
|
||||
if salt.utils.is_freebsd():
|
||||
force = True # Downgrades need to be forced.
|
||||
try:
|
||||
pkg_ret = __salt__['pkg.install'](name,
|
||||
refresh=refresh,
|
||||
version=version,
|
||||
force=force,
|
||||
fromrepo=fromrepo,
|
||||
skip_verify=skip_verify,
|
||||
pkgs=pkgs,
|
||||
|
Loading…
Reference in New Issue
Block a user