mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Logic for handling version: latest
This commit is contained in:
parent
b7dadd3b9b
commit
40a66a2501
@ -546,6 +546,7 @@ def install(name=None, refresh=False, pkgs=None, saltenv='base', **kwargs):
|
|||||||
|
|
||||||
# Loop through each package
|
# Loop through each package
|
||||||
changed = []
|
changed = []
|
||||||
|
latest = []
|
||||||
for pkg_name, options in six.iteritems(pkg_params):
|
for pkg_name, options in six.iteritems(pkg_params):
|
||||||
|
|
||||||
# Load package information for the package
|
# Load package information for the package
|
||||||
@ -579,6 +580,9 @@ def install(name=None, refresh=False, pkgs=None, saltenv='base', **kwargs):
|
|||||||
ret[pkg_name] = {'not found': version_num}
|
ret[pkg_name] = {'not found': version_num}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if 'latest' in pkginfo:
|
||||||
|
latest.append(pkg_name)
|
||||||
|
|
||||||
# Get the installer
|
# Get the installer
|
||||||
installer = pkginfo[version_num].get('installer')
|
installer = pkginfo[version_num].get('installer')
|
||||||
|
|
||||||
@ -694,6 +698,21 @@ def install(name=None, refresh=False, pkgs=None, saltenv='base', **kwargs):
|
|||||||
|
|
||||||
# Get a new list of installed software
|
# Get a new list of installed software
|
||||||
new = list_pkgs()
|
new = list_pkgs()
|
||||||
|
|
||||||
|
# For installers that have no specific version (ie: chrome)
|
||||||
|
# The software definition file will have a version of 'latest'
|
||||||
|
# In that case there's no way to know which version has been installed
|
||||||
|
# Just return the current installed version
|
||||||
|
# This has to be done before the loop below, otherwise the installation
|
||||||
|
# will not be detected
|
||||||
|
if latest:
|
||||||
|
for pkg_name in latest:
|
||||||
|
ret[pkg_name] = {'current': new[pkg_name],
|
||||||
|
'comment': 'Version of "latest" found in the\n'
|
||||||
|
'software definition file.'}
|
||||||
|
|
||||||
|
# Sometimes the installer takes awhile to update the registry
|
||||||
|
# This checks 10 times, 3 seconds between each for a registry change
|
||||||
tries = 0
|
tries = 0
|
||||||
difference = salt.utils.compare_dicts(old, new)
|
difference = salt.utils.compare_dicts(old, new)
|
||||||
while not all(name in difference for name in changed) and tries < 10:
|
while not all(name in difference for name in changed) and tries < 10:
|
||||||
@ -704,10 +723,12 @@ def install(name=None, refresh=False, pkgs=None, saltenv='base', **kwargs):
|
|||||||
tries += 1
|
tries += 1
|
||||||
log.debug("Try {0}".format(tries))
|
log.debug("Try {0}".format(tries))
|
||||||
if tries == 10:
|
if tries == 10:
|
||||||
|
if not latest:
|
||||||
ret['_comment'] = 'Software not found in the registry.\n' \
|
ret['_comment'] = 'Software not found in the registry.\n' \
|
||||||
'Could be a problem with the Software\n' \
|
'Could be a problem with the Software\n' \
|
||||||
'definition file. Verify the full_name\n' \
|
'definition file. Verify the full_name\n' \
|
||||||
'and the version match the registry exactly.\n' \
|
'and the version match the registry ' \
|
||||||
|
'exactly.\n' \
|
||||||
'Failed after {0} tries.'.format(tries)
|
'Failed after {0} tries.'.format(tries)
|
||||||
|
|
||||||
# Compare the software list before and after
|
# Compare the software list before and after
|
||||||
|
Loading…
Reference in New Issue
Block a user