Skip to content

Commit

Permalink
Merge branch 'osfullname_freebsd' of github.com:asomers/salt into osf…
Browse files Browse the repository at this point in the history
…ullname_freebsd
  • Loading branch information
garethgreenaway committed Jan 6, 2020
2 parents 69752d1 + 3cc5745 commit bb1e59a
Show file tree
Hide file tree
Showing 11 changed files with 2,718 additions and 1,222 deletions.
41 changes: 41 additions & 0 deletions salt/modules/aptpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import re
import logging
import time
import fnmatch
import datetime


# Import third party libs
# pylint: disable=no-name-in-module,import-error,redefined-builtin
Expand Down Expand Up @@ -384,6 +387,7 @@ def install(name=None,
pkgs=None,
sources=None,
reinstall=False,
downloadonly=False,
ignore_epoch=False,
**kwargs):
'''
Expand Down Expand Up @@ -730,6 +734,9 @@ def install(name=None,
cmd.extend(downgrade)
cmds.append(cmd)

if downloadonly:
cmd.append("--download-only")

if to_reinstall:
all_pkgs.extend(to_reinstall)
cmd = copy.deepcopy(cmd_prefix)
Expand Down Expand Up @@ -2846,3 +2853,37 @@ def _get_http_proxy_url():
)

return http_proxy_url


def list_downloaded(root=None, **kwargs):
'''
.. versionadded:: 3000?
List prefetched packages downloaded by apt in the local disk.
root
operate on a different root directory.
CLI example:
.. code-block:: bash
salt '*' pkg.list_downloaded
'''
CACHE_DIR = '/var/cache/apt'
if root:
CACHE_DIR = os.path.join(root, os.path.relpath(CACHE_DIR, os.path.sep))

ret = {}
for root, dirnames, filenames in salt.utils.path.os_walk(CACHE_DIR):
for filename in fnmatch.filter(filenames, '*.deb'):
package_path = os.path.join(root, filename)
pkg_info = __salt__['lowpkg.bin_pkg_info'](package_path)
pkg_timestamp = int(os.path.getctime(package_path))
ret.setdefault(pkg_info['name'], {})[pkg_info['version']] = {
'path': package_path,
'size': os.path.getsize(package_path),
'creation_date_time_t': pkg_timestamp,
'creation_date_time': datetime.datetime.utcfromtimestamp(pkg_timestamp).isoformat(),
}
return ret
2,064 changes: 1,417 additions & 647 deletions salt/modules/win_lgpo.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion salt/states/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def until_no_eval(
current_attempt += 1
try:
res = __salt__[name](*args, **kwargs)
except Exception:
except Exception: # pylint: disable=broad-except
(exc_type, exc_value, _) = sys.exc_info()
ret['comment'] = 'Exception occurred while executing {}: {}:{}'.format(name, exc_type, exc_value)
break
Expand Down
4 changes: 2 additions & 2 deletions salt/states/pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ def downloaded(name,
(if specified).
Currently supported for the following pkg providers:
:mod:`yumpkg <salt.modules.yumpkg>` and :mod:`zypper <salt.modules.zypper>`
:mod:`yumpkg <salt.modules.yumpkg>`, :mod:`zypper <salt.modules.zypper>` and :mod:`zypper <salt.modules.aptpkg>`
:param str name:
The name of the package to be downloaded. This parameter is ignored if
Expand Down Expand Up @@ -2174,7 +2174,7 @@ def downloaded(name,

if not ret['changes'] and not ret['comment']:
ret['result'] = True
ret['comment'] = 'Packages are already downloaded: ' \
ret['comment'] = 'Packages downloaded: ' \
'{0}'.format(', '.join(targets))

return ret
Expand Down
Loading

0 comments on commit bb1e59a

Please sign in to comment.