From 4700c2f1894732460d0fbe366580f32c19bf568e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 5 Mar 2014 16:05:08 -0600 Subject: [PATCH] Add lowpkg.unpurge for dpkg --- salt/modules/dpkg.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/salt/modules/dpkg.py b/salt/modules/dpkg.py index 2e4106ed40..747277dcda 100644 --- a/salt/modules/dpkg.py +++ b/salt/modules/dpkg.py @@ -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::