mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Add lowpkg.unpurge for dpkg
This commit is contained in:
parent
eec7b9bff5
commit
4700c2f189
@ -6,6 +6,9 @@ Support for DEB packages
|
||||
# Import python libs
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Define the module's virtual name
|
||||
@ -19,6 +22,31 @@ def __virtual__():
|
||||
return __virtualname__ if __grains__['os_family'] == 'Debian' else False
|
||||
|
||||
|
||||
def unpurge(*packages):
|
||||
'''
|
||||
Change package selection for each package specified to 'install'
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' lowpkg.unpurge curl
|
||||
'''
|
||||
if not packages:
|
||||
return {}
|
||||
old = __salt__['pkg.list_pkgs'](purge_desired=True)
|
||||
ret = {}
|
||||
__salt__['cmd.run'](
|
||||
['dpkg', '--set-selections'],
|
||||
stdin=r'\n'.join(['{0} install'.format(x) for x in packages]),
|
||||
python_shell=False,
|
||||
output_loglevel='debug'
|
||||
)
|
||||
__context__.pop('pkg.list_pkgs', None)
|
||||
new = __salt__['pkg.list_pkgs'](purge_desired=True)
|
||||
return salt.utils.compare_dicts(old, new)
|
||||
|
||||
|
||||
def list_pkgs(*packages):
|
||||
'''
|
||||
List the packages currently installed in a dict::
|
||||
|
Loading…
Reference in New Issue
Block a user