mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
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:
parent
343dc98025
commit
7ad966b1fa
@ -124,7 +124,10 @@ def latest_version(*names, **kwargs):
|
|||||||
salt '*' pkg.latest_version <package name>
|
salt '*' pkg.latest_version <package name>
|
||||||
salt '*' pkg.latest_version <package1> <package2> <package3>
|
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:
|
if len(names) <= 1:
|
||||||
return ''
|
return ''
|
||||||
@ -179,6 +182,28 @@ def remove(name=None, pkgs=None, **kwargs):
|
|||||||
return salt.utils.compare_dicts(old, new)
|
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):
|
def install(name=None, pkgs=None, taps=None, options=None, **kwargs):
|
||||||
'''
|
'''
|
||||||
Install the passed package(s) with ``brew install``
|
Install the passed package(s) with ``brew install``
|
||||||
|
Loading…
Reference in New Issue
Block a user