mirror of
https://github.com/valitydev/salt-common.git
synced 2024-11-07 02:45:21 +00:00
114 lines
4.3 KiB
Diff
114 lines
4.3 KiB
Diff
--- /usr/lib/python2.7/site-packages/salt/states/pkg.py 2016-08-24 19:25:26.000000000 +0300
|
|
+++ pkg.py.patched 2017-01-12 14:25:16.995253396 +0300
|
|
@@ -143,7 +143,7 @@
|
|
comparison operator was passed, the comparison is assumed to be an "equals"
|
|
comparison, and "==" will be the operator returned.
|
|
'''
|
|
- match = re.match('^([<>])?(=)?([^<>=]+)$', pkgver)
|
|
+ match = re.match('^~?([<>])?(=)?([^<>=]+)$', pkgver)
|
|
if not match:
|
|
raise CommandExecutionError(
|
|
'Invalid version specification \'{0}\'.'.format(pkgver)
|
|
@@ -1570,15 +1570,17 @@
|
|
'changes': {},
|
|
'result': False,
|
|
'comment': 'The "sources" parameter is not supported.'}
|
|
- elif pkgs:
|
|
- desired_pkgs = list(_repack_pkgs(pkgs).keys())
|
|
- if not desired_pkgs:
|
|
+
|
|
+ if pkgs:
|
|
+ pkgs = _repack_pkgs(pkgs)
|
|
+ if not pkgs:
|
|
# Badly-formatted SLS
|
|
return {'name': name,
|
|
'changes': {},
|
|
'result': False,
|
|
'comment': 'Invalidly formatted "pkgs" parameter. See '
|
|
'minion log.'}
|
|
+ desired_pkgs = pkgs.keys()
|
|
else:
|
|
if isinstance(pkgs, list) and len(pkgs) == 0:
|
|
return {
|
|
@@ -1588,6 +1590,7 @@
|
|
'comment': 'No packages to install provided'
|
|
}
|
|
else:
|
|
+ pkgs = {name: None}
|
|
desired_pkgs = [name]
|
|
|
|
try:
|
|
@@ -1624,18 +1627,22 @@
|
|
|
|
targets = {}
|
|
problems = []
|
|
- for pkg in desired_pkgs:
|
|
- if not avail[pkg]:
|
|
- if not cur[pkg]:
|
|
- msg = 'No information found for \'{0}\'.'.format(pkg)
|
|
- log.error(msg)
|
|
- problems.append(msg)
|
|
- elif watch_flags \
|
|
- and __grains__.get('os') == 'Gentoo' \
|
|
- and __salt__['portage_config.is_changed_uses'](pkg):
|
|
+ for pkg, version in pkgs.items():
|
|
+ if cur[pkg]:
|
|
+ if _fulfills_version_spec([cur[pkg]], '!=', avail[pkg]):
|
|
targets[pkg] = avail[pkg]
|
|
- else:
|
|
+ else:
|
|
+ if version:
|
|
+ target, flag_changes = __salt__['pkg.process_target'](pkg, version)
|
|
+ if not cur[pkg] or (__grains__.get('os') == 'Gentoo'
|
|
+ and __salt__['portage_config.is_changed_uses'](pkg)):
|
|
+ targets[pkg] = avail[pkg]
|
|
+ elif avail[pkg]:
|
|
targets[pkg] = avail[pkg]
|
|
+ else:
|
|
+ msg = 'No information found for {0!r}.'.format(pkg)
|
|
+ log.error(msg)
|
|
+ problems.append(msg)
|
|
|
|
if problems:
|
|
return {
|
|
@@ -1647,13 +1654,14 @@
|
|
|
|
if targets:
|
|
# Find up-to-date packages
|
|
- if not pkgs:
|
|
- # There couldn't have been any up-to-date packages if this state
|
|
- # only targeted a single package and is being allowed to proceed to
|
|
- # the install step.
|
|
- up_to_date = []
|
|
- else:
|
|
- up_to_date = [x for x in pkgs if x not in targets]
|
|
+ up_to_date = []
|
|
+ if pkgs:
|
|
+ for x in pkgs:
|
|
+ if not isinstance(x, basestring):
|
|
+ # For the awful list of dicts case.
|
|
+ x = x.keys()[0]
|
|
+ if x not in targets:
|
|
+ up_to_date += x
|
|
|
|
if __opts__['test']:
|
|
to_be_upgraded = ', '.join(sorted(targets))
|
|
@@ -1683,12 +1691,15 @@
|
|
try:
|
|
# No need to refresh, if a refresh was necessary it would have been
|
|
# performed above when pkg.latest_version was run.
|
|
- changes = __salt__['pkg.install'](name,
|
|
+ changes = {}
|
|
+ if 'flag_changes' in locals():
|
|
+ changes.update(flag_changes)
|
|
+ changes.update(__salt__['pkg.install'](name,
|
|
refresh=False,
|
|
fromrepo=fromrepo,
|
|
skip_verify=skip_verify,
|
|
pkgs=targeted_pkgs,
|
|
- **kwargs)
|
|
+ **kwargs))
|
|
except CommandExecutionError as exc:
|
|
return {'name': name,
|
|
'changes': {},
|