Merge pull request #4569 from majorleaguesoccer/Pecl-update

Properly handle pecl extension versions
This commit is contained in:
Thomas S Hatch 2013-04-22 16:58:57 -07:00
commit 29efa17820

View File

@ -11,18 +11,36 @@ A state module to manage php pecl extensions.
'''
def installed(name):
def installed(
name,
version=None):
'''
Make sure that a pecl extension is installed.
name
The pecl extension name to install
version
The pecl extension version to install. This option may be
ignored to install the latest stable version.
'''
# Check to see if we have a designated version
if not isinstance(version, basestring) and version is not None:
version = str(version)
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
if name in __salt__['pecl.list']():
ret['result'] = True
ret['comment'] = 'Pecl is already installed.'
return ret
installed_pecls = __salt__['pecl.list']()
if name in installed_pecls:
# The package is only installed if version is absent or matches
if version is None or installed_pecls[name][0] == version:
ret['result'] = True
ret['comment'] = 'Pecl is already installed.'
return ret
else:
# Modify the name to include the version and proceed.
name = '{0}-{1}'.format(name, version)
if __opts__['test']:
ret['comment'] = 'The pecl {0} would have been installed'.format(name)