mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Assume two EVRs are equal if E and V are equal but one R is missing.
This commit is contained in:
parent
1f989e720a
commit
f6eb5d061f
@ -688,14 +688,29 @@ def version_cmp(ver1, ver2, ignore_epoch=False):
|
||||
'more accurate version comparisons'
|
||||
)
|
||||
else:
|
||||
cmp_result = cmp_func(salt.utils.str_version_to_evr(ver1),
|
||||
salt.utils.str_version_to_evr(ver2))
|
||||
if cmp_result not in (-1, 0, 1):
|
||||
raise CommandExecutionError(
|
||||
'Comparison result \'{0}\' is invalid'.format(cmp_result)
|
||||
)
|
||||
else:
|
||||
# If one EVR is missing a release but not the other and they
|
||||
# otherwise would be equal, assume they are equal. This can
|
||||
# happen if e.g. you are checking if a package version 3.2 is
|
||||
# satisfied by a 3.2-1.
|
||||
(ver1_e, ver1_v, ver1_r) = salt.utils.str_version_to_evr(ver1)
|
||||
(ver2_e, ver2_v, ver2_r) = salt.utils.str_version_to_evr(ver2)
|
||||
if not ver1_r or not ver2_r:
|
||||
tmp_cmp = cmp_func((ver1_e, ver1_v, ''), (ver2_e, ver2_v, ''))
|
||||
if tmp_cmp not in (-1, 0, 1):
|
||||
raise CommandExecutionError(
|
||||
'Comparison result \'{0}\' is invalid'.format(tmp_cmp)
|
||||
)
|
||||
if tmp_cmp == 0:
|
||||
return 0
|
||||
|
||||
return cmp_result
|
||||
cmp_result = cmp_func((ver1_e, ver1_v, ver1_r),
|
||||
(ver2_e, ver2_v, ver2_r))
|
||||
if cmp_result not in (-1, 0, 1):
|
||||
raise CommandExecutionError(
|
||||
'Comparison result \'{0}\' is invalid'.format(cmp_result)
|
||||
)
|
||||
return cmp_result
|
||||
|
||||
except Exception as exc:
|
||||
log.warning(
|
||||
|
Loading…
Reference in New Issue
Block a user