1592ccc37e
- fix argument handling of pkg.download Add: 0022-fix-argument-handling-for-pkg.download.patch - unify behavior of zypper refresh in salt Add: 0018-unify-behavior-of-refresh.patch 0019-add-refresh-option-to-more-functions.patch 0020-simplify-checking-the-refresh-paramater.patch 0021-do-not-change-kwargs-in-refresh-while-checking-a-val.patch - Fix crash with scheduler and runners Add: 0017-Fix-crash-with-scheduler-and-runners-31106.patch - Call zypper always with --non-interactive Add: * 0015-call-zypper-with-option-non-interactive-everywhere.patch * 0016-write-a-zypper-command-builder-function.patch - require rpm-python on SUSE for zypper support - fix state return code Add: 0009-The-functions-in-the-state-module-that-return-a-retc.patch - add handling of OEM products to pkg.list_products Add: 0010-add-handling-for-OEM-products.patch - improve doc for list_pkgs Add: 0011-improve-doc-for-list_pkgs.patch - implement pkg.version_cmp in zypper.py Add: * 0012-implement-version_cmp-for-zypper.patch * 0013-pylint-changes.patch * 0014-Check-if-rpm-python-can-be-imported.patch - Update to 2015.8.7 this is a small update to fix some regressions see https://docs.saltstack.com/en/latest/topics/releases/2015.8.7.html - Booleans should not be strings from XML, add Unix ticks time and format result in a list of maps. Add: * 0008-Fix-types-in-the-output-data-and-return-just-a-list-.patch - Stop salt-api daemon faster (bsc#963322) Add: * 0007-Force-kill-websocket-s-child-processes-faster-than-d.patch - Do not crash on salt-key reject/delete consecutive calls. Add: * 0006-add_key-reject_key-do-not-crash-w-Permission-denied-.patch - Update to 2015.8.5 See https://docs.saltstack.com/en/latest/topics/releases/2015.8.5.html Dropped patches (all upstream): * 0003-List-products-consistently-across-all-SLES-systems.patch * 0004-Add-missing-return-data-to-scheduled-jobs.patch * 0005-Fix-RPM-issues-with-the-date-time-and-add-package-at.patch * 0006-Bugfix-info_available-does-not-work-correctly-on-SLE.patch Renamed patches: * 0007-Check-if-byte-strings-are-properly-encoded-in-UTF-8.patch -> 0003-Check-if-byte-strings-are-properly-encoded-in-UTF-8.patch * 0008-Fix-pkg.latest-prevent-crash-on-multiple-package-ins.patch -> 0004-Fix-pkg.latest-prevent-crash-on-multiple-package-ins.patch * 0009-Fix-package-status-filtering-on-latest-version-and-i.patch -> 0005-Fix-package-status-filtering-on-latest-version-and-i.patch - Update to 2015.8.4 See https://docs.saltstack.com/en/latest/topics/releases/2015.8.4.html - Fix latest version available comparison and implement epoch support in Zypper module. Add: * 0009-Fix-package-status-filtering-on-latest-version-and-i.patch - Update patch from opensuse to upstream version. Update: * 0008-Fix-pkg.latest-prevent-crash-on-multiple-package-ins.patch - Fix dependencies to Salt subpackages requiring release along the version. - Fix pkg.latest crash. - Fix pkg.latest SLS ID bug, when pkgs empty list is passed, but SLS ID still treated as a package name. Add: * 0008-Fix-pkg.latest-prevent-crash-on-multiple-package-ins.patch - Drop: * -0004-zypper-check-package-header-content-for-valid-utf-8.patch - Rename: * -0004-zypper-check-package-header-content-for-valid-utf-8.patch +0004-Add-missing-return-data-to-scheduled-jobs.patch * -0005-Add-missing-return-data-to-scheduled-jobs.patch +0004-Add-missing-return-data-to-scheduled-jobs.patch * -0006-Fix-RPM-issues-with-the-date-time-and-add-package-at.patch +0005-Fix-RPM-issues-with-the-date-time-and-add-package-at.patch * -0007-Bugfix-info_available-does-not-work-correctly-on-SLE.patch +0006-Bugfix-info_available-does-not-work-correctly-on-SLE.patch - Add: * 0007-Check-if-byte-strings-are-properly-encoded-in-UTF-8.patch - Rename use-forking-daemon.patch to 0001-tserong-suse.com-We-don-t-have-python-systemd-so-not.patch - Rename use-salt-user-for-master.patch to 0002-Run-salt-master-as-dedicated-salt-user.patch - Rename 1efe484309a5c776974e723f3da0f5181f4bdb86.patch to 0003-List-products-consistently-across-all-SLES-systems.patch - Rename zypper-utf-8.patch to 0004-zypper-check-package-header-content-for-valid-utf-8.patch - Rename salt-2015.8-schedule-ret.patch to 0005-Add-missing-return-data-to-scheduled-jobs.patch - Rename salt-2015.8-pkg-zypper-attr-filtering.patch to 0006-Fix-RPM-issues-with-the-date-time-and-add-package-at.patch - Rename salt-2015.8-zypper-info.patch to 0007-Bugfix-info_available-does-not-work-correctly-on-SLE.patch OBS-URL: https://build.opensuse.org/request/show/361294 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=55
256 lines
9.3 KiB
Diff
256 lines
9.3 KiB
Diff
From e21ddab93f22d1b2e1ad94368527f41102b69f16 Mon Sep 17 00:00:00 2001
|
|
From: Bo Maryniuk <bo@suse.de>
|
|
Date: Fri, 22 Jan 2016 18:37:12 +0100
|
|
Subject: [PATCH 04/22] Fix pkg.latest - prevent crash on multiple package
|
|
installation
|
|
|
|
Fix PEP8: line continuation
|
|
|
|
Replace old fashion string memcopy with the list
|
|
|
|
Fix PEP8: line continuation
|
|
|
|
Bugfix: crash on "key not found" error
|
|
|
|
Fix formatting
|
|
|
|
Check the version of the package, instead of the package name
|
|
|
|
Get version as an explicit parameter
|
|
|
|
Use regexp type for the string.
|
|
|
|
Avoid backslashes where they are not needed
|
|
|
|
Remove unnecessary complexity and string increment
|
|
|
|
Add a new line before the last return
|
|
|
|
Add error handling
|
|
|
|
Cleanup formatting
|
|
|
|
Bugfix: do not treat SLS id as a package name if an empty 'pkgs' list specified.
|
|
|
|
Put 'kwargs' on its own line according to the common pattern
|
|
---
|
|
salt/modules/zypper.py | 43 +++++++++++++---------------------
|
|
salt/states/pkg.py | 62 ++++++++++++++++++++++++--------------------------
|
|
2 files changed, 46 insertions(+), 59 deletions(-)
|
|
|
|
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
|
|
index dddcc2f..63b38af 100644
|
|
--- a/salt/modules/zypper.py
|
|
+++ b/salt/modules/zypper.py
|
|
@@ -598,6 +598,7 @@ def install(name=None,
|
|
pkgs=None,
|
|
sources=None,
|
|
downloadonly=None,
|
|
+ version=None,
|
|
**kwargs):
|
|
'''
|
|
Install the passed package(s), add refresh=True to run 'zypper refresh'
|
|
@@ -666,23 +667,20 @@ def install(name=None,
|
|
'new': '<new-version>'}}
|
|
'''
|
|
try:
|
|
- pkg_params, pkg_type = __salt__['pkg_resource.parse_targets'](
|
|
- name, pkgs, sources, **kwargs
|
|
- )
|
|
+ pkg_params, pkg_type = __salt__['pkg_resource.parse_targets'](name, pkgs, sources, **kwargs)
|
|
except MinionError as exc:
|
|
raise CommandExecutionError(exc)
|
|
|
|
if pkg_params is None or len(pkg_params) == 0:
|
|
return {}
|
|
|
|
- version_num = kwargs.get('version')
|
|
+ version_num = version
|
|
if version_num:
|
|
if pkgs is None and sources is None:
|
|
# Allow "version" to work for single package target
|
|
pkg_params = {name: version_num}
|
|
else:
|
|
- log.warning('\'version\' parameter will be ignored for multiple '
|
|
- 'package targets')
|
|
+ log.warning("'version' parameter will be ignored for multiple package targets")
|
|
|
|
if pkg_type == 'repository':
|
|
targets = []
|
|
@@ -691,18 +689,13 @@ def install(name=None,
|
|
if version_num is None:
|
|
targets.append(param)
|
|
else:
|
|
- match = re.match('^([<>])?(=)?([^<>=]+)$', version_num)
|
|
+ match = re.match(r'^([<>])?(=)?([^<>=]+)$', version_num)
|
|
if match:
|
|
gt_lt, equal, verstr = match.groups()
|
|
- prefix = gt_lt or ''
|
|
- prefix += equal or ''
|
|
- # If no prefix characters were supplied, use '='
|
|
- prefix = prefix or '='
|
|
- targets.append('{0}{1}{2}'.format(param, prefix, verstr))
|
|
+ targets.append('{0}{1}{2}'.format(param, ((gt_lt or '') + (equal or '')) or '=', verstr))
|
|
log.debug(targets)
|
|
else:
|
|
- msg = ('Invalid version string {0!r} for package '
|
|
- '{1!r}'.format(version_num, name))
|
|
+ msg = ('Invalid version string {0!r} for package {1!r}'.format(version_num, name))
|
|
problems.append(msg)
|
|
if problems:
|
|
for problem in problems:
|
|
@@ -731,19 +724,14 @@ def install(name=None,
|
|
while targets:
|
|
cmd = cmd_install + targets[:500]
|
|
targets = targets[500:]
|
|
-
|
|
- out = __salt__['cmd.run'](
|
|
- cmd,
|
|
- output_loglevel='trace',
|
|
- python_shell=False
|
|
- )
|
|
- for line in out.splitlines():
|
|
- match = re.match(
|
|
- "^The selected package '([^']+)'.+has lower version",
|
|
- line
|
|
- )
|
|
- if match:
|
|
- downgrades.append(match.group(1))
|
|
+ call = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False)
|
|
+ if call['retcode'] != 0:
|
|
+ raise CommandExecutionError(call['stderr']) # Fixme: This needs a proper report mechanism.
|
|
+ else:
|
|
+ for line in call['stdout'].splitlines():
|
|
+ match = re.match(r"^The selected package '([^']+)'.+has lower version", line)
|
|
+ if match:
|
|
+ downgrades.append(match.group(1))
|
|
|
|
while downgrades:
|
|
cmd = cmd_install + ['--force'] + downgrades[:500]
|
|
@@ -752,6 +740,7 @@ def install(name=None,
|
|
__salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)
|
|
__context__.pop('pkg.list_pkgs', None)
|
|
new = list_pkgs()
|
|
+
|
|
return salt.utils.compare_dicts(old, new)
|
|
|
|
|
|
diff --git a/salt/states/pkg.py b/salt/states/pkg.py
|
|
index 65ba779..d7c4503 100644
|
|
--- a/salt/states/pkg.py
|
|
+++ b/salt/states/pkg.py
|
|
@@ -1373,8 +1373,7 @@ def latest(
|
|
'''
|
|
rtag = __gen_rtag()
|
|
refresh = bool(
|
|
- salt.utils.is_true(refresh)
|
|
- or (os.path.isfile(rtag) and refresh is not False)
|
|
+ salt.utils.is_true(refresh) or (os.path.isfile(rtag) and refresh is not False)
|
|
)
|
|
|
|
if kwargs.get('sources'):
|
|
@@ -1392,7 +1391,15 @@ def latest(
|
|
'comment': 'Invalidly formatted "pkgs" parameter. See '
|
|
'minion log.'}
|
|
else:
|
|
- desired_pkgs = [name]
|
|
+ if isinstance(pkgs, list) and len(pkgs) == 0:
|
|
+ return {
|
|
+ 'name': name,
|
|
+ 'changes': {},
|
|
+ 'result': True,
|
|
+ 'comment': 'No packages to install provided'
|
|
+ }
|
|
+ else:
|
|
+ desired_pkgs = [name]
|
|
|
|
cur = __salt__['pkg.version'](*desired_pkgs, **kwargs)
|
|
try:
|
|
@@ -1431,33 +1438,29 @@ def latest(
|
|
log.error(msg)
|
|
problems.append(msg)
|
|
else:
|
|
- if salt.utils.compare_versions(ver1=cur[pkg],
|
|
- oper='!=',
|
|
- ver2=avail[pkg],
|
|
- cmp_func=cmp_func):
|
|
+ if salt.utils.compare_versions(ver1=cur[pkg], oper='!=', ver2=avail[pkg], cmp_func=cmp_func):
|
|
targets[pkg] = avail[pkg]
|
|
else:
|
|
if not cur[pkg] or __salt__['portage_config.is_changed_uses'](pkg):
|
|
targets[pkg] = avail[pkg]
|
|
else:
|
|
for pkg in desired_pkgs:
|
|
- if not avail[pkg]:
|
|
- if not cur[pkg]:
|
|
+ if pkg not in avail:
|
|
+ if not cur.get(pkg):
|
|
msg = 'No information found for \'{0}\'.'.format(pkg)
|
|
log.error(msg)
|
|
problems.append(msg)
|
|
- elif not cur[pkg] \
|
|
- or salt.utils.compare_versions(ver1=cur[pkg],
|
|
- oper='<',
|
|
- ver2=avail[pkg],
|
|
- cmp_func=cmp_func):
|
|
+ elif not cur.get(pkg) \
|
|
+ or salt.utils.compare_versions(ver1=cur[pkg], oper='<', ver2=avail[pkg], cmp_func=cmp_func):
|
|
targets[pkg] = avail[pkg]
|
|
|
|
if problems:
|
|
- return {'name': name,
|
|
- 'changes': {},
|
|
- 'result': False,
|
|
- 'comment': ' '.join(problems)}
|
|
+ return {
|
|
+ 'name': name,
|
|
+ 'changes': {},
|
|
+ 'result': False,
|
|
+ 'comment': ' '.join(problems)
|
|
+ }
|
|
|
|
if targets:
|
|
# Find up-to-date packages
|
|
@@ -1471,9 +1474,7 @@ def latest(
|
|
|
|
if __opts__['test']:
|
|
to_be_upgraded = ', '.join(sorted(targets))
|
|
- comment = 'The following packages are set to be ' \
|
|
- 'installed/upgraded: ' \
|
|
- '{0}'.format(to_be_upgraded)
|
|
+ comment = ['The following packages are set to be installed/upgraded: {0}'.format(to_be_upgraded)]
|
|
if up_to_date:
|
|
up_to_date_nb = len(up_to_date)
|
|
if up_to_date_nb <= 10:
|
|
@@ -1482,19 +1483,16 @@ def latest(
|
|
'{0} ({1})'.format(name, cur[name])
|
|
for name in up_to_date_sorted
|
|
)
|
|
- comment += (
|
|
- ' The following packages are already '
|
|
- 'up-to-date: {0}'
|
|
- ).format(up_to_date_details)
|
|
+ comment.append('The following packages are already up-to-date: {0}'.format(up_to_date_details))
|
|
else:
|
|
- comment += ' {0} packages are already up-to-date'.format(
|
|
- up_to_date_nb
|
|
- )
|
|
+ comment.append('{0} packages are already up-to-date'.format(up_to_date_nb))
|
|
|
|
- return {'name': name,
|
|
- 'changes': {},
|
|
- 'result': None,
|
|
- 'comment': comment}
|
|
+ return {
|
|
+ 'name': name,
|
|
+ 'changes': {},
|
|
+ 'result': None,
|
|
+ 'comment': ' '.join(comment)
|
|
+ }
|
|
|
|
# Build updated list of pkgs to exclude non-targeted ones
|
|
targeted_pkgs = list(targets.keys()) if pkgs else None
|
|
--
|
|
2.1.4
|
|
|