Add support for refresh_db in brew

It appears that refresh_db became a feature that package managers are require to support as `KeyError: 'pkg.refresh_db'` was the error I was getting before this commit. I've not had a chance to fully test this fix, so I'd appreciate anyone else taking a look at this.
This commit is contained in:
Jason R. McNeil 2013-12-01 22:44:39 -07:00
parent 343dc98025
commit 7ad966b1fa

View File

@ -124,7 +124,10 @@ def latest_version(*names, **kwargs):
salt '*' pkg.latest_version <package name>
salt '*' pkg.latest_version <package1> <package2> <package3>
'''
kwargs.pop('refresh', True)
refresh = salt.utils.is_true(kwargs.pop('refresh', True))
if refresh:
refresh_db()
if len(names) <= 1:
return ''
@ -179,6 +182,28 @@ def remove(name=None, pkgs=None, **kwargs):
return salt.utils.compare_dicts(old, new)
def refresh_db():
'''
Update the homebrew package repository.
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
'''
cmd = 'brew update'
homebrew_binary = __salt__['cmd.run']('brew --prefix') + "/bin/brew"
user = __salt__['file.get_user'](homebrew_binary)
if __salt__['cmd.retcode'](cmd, runas=user):
log.error('Failed to update')
return False
return True
def install(name=None, pkgs=None, taps=None, options=None, **kwargs):
'''
Install the passed package(s) with ``brew install``