Hello community, here is the log from the commit of package salt for openSUSE:Factory checked in at 2018-08-02 14:55:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt (Old) and /work/SRC/openSUSE:Factory/.salt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "salt" Thu Aug 2 14:55:36 2018 rev:79 rq:626474 version:2018.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/salt/salt.changes 2018-05-17 18:07:15.487843746 +0200 +++ /work/SRC/openSUSE:Factory/.salt.new/salt.changes 2018-08-02 14:55:43.928034731 +0200 @@ -1,0 +2,55 @@ +Mon Jul 30 10:42:01 UTC 2018 - mihai.dinca@suse.com + +- Update to 2018.3.2 + See https://docs.saltstack.com/en/latest/topics/releases/2018.3.2.html + for full changelog + +- Added: + * accounting-for-when-files-in-an-archive-contain-non-.patch + * add-all_versions-parameter-to-include-all-installed-.patch + * add-custom-suse-capabilities-as-grains.patch + * add-engine-relaying-libvirt-events.patch + * add-environment-variable-to-know-if-yum-is-invoked-f.patch + * add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch + * align-suse-salt-master.service-limitnofiles-limit-wi.patch + * avoid-incomprehensive-message-if-crashes.patch + * fix-deprecation-warning-bsc-1095507.patch + * fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch + * fix-unboundlocalerror-in-file.get_diff.patch + * fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch + * prevent-zypper-from-parsing-repo-configuration-from-.patch + * remove-old-hack-when-reporting-multiversion-packages.patch + * show-recommendations-for-salt-ssh-cross-version-pyth.patch + +- Modified: + * activate-all-beacons-sources-config-pillar-grains.patch + * add-saltssh-multi-version-support-across-python-inte.patch + * avoid-excessive-syslogging-by-watchdog-cronjob-58.patch + * do-not-override-jid-on-returners-only-sending-back-t.patch + * enable-passing-a-unix_socket-for-mysql-returners-bsc.patch + * fall-back-to-pymysql.patch + * feat-add-grain-for-all-fqdns.patch + * fix-bsc-1065792.patch + * fix-decrease-loglevel-when-unable-to-resolve-addr.patch + * fix-for-ec2-rate-limit-failures.patch + * fix-for-errno-0-resolver-error-0-no-error-bsc-108758.patch + * fixed-usage-of-ipaddress.patch + * option-to-merge-current-pillar-with-opts-pillar-duri.patch + * run-salt-api-as-user-salt-bsc-1064520.patch + * run-salt-master-as-dedicated-salt-user.patch + * strip-trailing-commas-on-linux-user-gecos-fields.patch + +- Deleted: + * explore-module.run-response-to-catch-the-result-in-d.patch + * extra-filerefs-include-files-even-if-no-refs-in-stat.patch + * fix-cp.push-empty-file.patch + * fix-for-sorting-of-multi-version-packages-bsc-109717.patch + * fix-openscap-push.patch + * initialize-__context__-retcode-for-functions-handled.patch + * make-it-possible-to-use-login-pull-and-push-from-mod.patch + * move-log_file-option-to-changeable-defaults.patch + * provide-kwargs-to-pkg_resource.parse_targets-require.patch + * remove-obsolete-unicode-handling-in-pkg.info_install.patch + + +------------------------------------------------------------------- Old: ---- explore-module.run-response-to-catch-the-result-in-d.patch extra-filerefs-include-files-even-if-no-refs-in-stat.patch fix-cp.push-empty-file.patch fix-openscap-push.patch initialize-__context__-retcode-for-functions-handled.patch make-it-possible-to-use-login-pull-and-push-from-mod.patch move-log_file-option-to-changeable-defaults.patch provide-kwargs-to-pkg_resource.parse_targets-require.patch remove-obsolete-unicode-handling-in-pkg.info_install.patch v2018.3.0.tar.gz New: ---- accounting-for-when-files-in-an-archive-contain-non-.patch add-all_versions-parameter-to-include-all-installed-.patch add-custom-suse-capabilities-as-grains.patch add-engine-relaying-libvirt-events.patch add-environment-variable-to-know-if-yum-is-invoked-f.patch add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch align-suse-salt-master.service-limitnofiles-limit-wi.patch avoid-incomprehensive-message-if-crashes.patch fix-deprecation-warning-bsc-1095507.patch fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch fix-unboundlocalerror-in-file.get_diff.patch fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch prevent-zypper-from-parsing-repo-configuration-from-.patch remove-old-hack-when-reporting-multiversion-packages.patch show-recommendations-for-salt-ssh-cross-version-pyth.patch v2018.3.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt.spec ++++++ --- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.124036732 +0200 +++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.128036738 +0200 @@ -1,7 +1,7 @@ # # spec file for package salt # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,6 +15,7 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # + %if 0%{?suse_version} >= 1320 # SLE15 %global build_py3 1 @@ -52,7 +53,7 @@ %bcond_with builddocs Name: salt -Version: 2018.3.0 +Version: 2018.3.2 Release: 0 Summary: A parallel remote execution system License: Apache-2.0 @@ -71,43 +72,60 @@ Patch4: avoid-excessive-syslogging-by-watchdog-cronjob-58.patch Patch5: feat-add-grain-for-all-fqdns.patch Patch6: fix-bsc-1065792.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46006 -Patch7: remove-obsolete-unicode-handling-in-pkg.info_install.patch -Patch8: fix-openscap-push.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/45972 -Patch9: move-log_file-option-to-changeable-defaults.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46416 -Patch10: fix-cp.push-empty-file.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46575 -Patch11: fix-decrease-loglevel-when-unable-to-resolve-addr.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46643 -Patch12: make-it-possible-to-use-login-pull-and-push-from-mod.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46413 -Patch13: explore-module.run-response-to-catch-the-result-in-d.patch +Patch7: fix-decrease-loglevel-when-unable-to-resolve-addr.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46684 -Patch14: add-saltssh-multi-version-support-across-python-inte.patch +Patch8: add-saltssh-multi-version-support-across-python-inte.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46635 -Patch15: fix-for-errno-0-resolver-error-0-no-error-bsc-108758.patch +Patch9: fix-for-errno-0-resolver-error-0-no-error-bsc-108758.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46890 -Patch16: fall-back-to-pymysql.patch +Patch10: fall-back-to-pymysql.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47149 -Patch17: strip-trailing-commas-on-linux-user-gecos-fields.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47155 -Patch18: provide-kwargs-to-pkg_resource.parse_targets-require.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47270 -Patch19: initialize-__context__-retcode-for-functions-handled.patch +Patch11: strip-trailing-commas-on-linux-user-gecos-fields.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47232 -Patch20: fixed-usage-of-ipaddress.patch -# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47497 -Patch21: extra-filerefs-include-files-even-if-no-refs-in-stat.patch +Patch12: fixed-usage-of-ipaddress.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47504 -Patch22: option-to-merge-current-pillar-with-opts-pillar-duri.patch +Patch13: option-to-merge-current-pillar-with-opts-pillar-duri.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47471 -Patch23: do-not-override-jid-on-returners-only-sending-back-t.patch +Patch14: do-not-override-jid-on-returners-only-sending-back-t.patch # PATCH-FIX_OPENSUSE bsc#1091371 -Patch24: enable-passing-a-unix_socket-for-mysql-returners-bsc.patch +Patch15: enable-passing-a-unix_socket-for-mysql-returners-bsc.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47211 -Patch25: fix-for-ec2-rate-limit-failures.patch +Patch16: fix-for-ec2-rate-limit-failures.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47638 +Patch17: add-all_versions-parameter-to-include-all-installed-.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47765 +Patch18: prevent-zypper-from-parsing-repo-configuration-from-.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47149 +Patch19: add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47908 +Patch20: align-suse-salt-master.service-limitnofiles-limit-wi.patch +# PATCH-FIX_OPENSUSE bsc#1095507 +Patch21: fix-deprecation-warning-bsc-1095507.patch +# PATCH-FIX_OPENSUSE bsc#1057635 +Patch22: add-environment-variable-to-know-if-yum-is-invoked-f.patch +# PATCH-FIX_OPENSUSE +Patch23: add-custom-suse-capabilities-as-grains.patch +# PATCH-FIX_OPENSUSE bsc#1098394 https://github.com/saltstack/salt/pull/47061 +Patch24: fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch +# PATCH-FIX_OPENSUSE bsc#1072599 +Patch25: show-recommendations-for-salt-ssh-cross-version-pyth.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47405 +Patch26: fix-unboundlocalerror-in-file.get_diff.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/48294 +Patch27: fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47572 +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/48015 +Patch28: accounting-for-when-files-in-an-archive-contain-non-.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/48712 +Patch29: remove-old-hack-when-reporting-multiversion-packages.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46461 +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46928 +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/46957 +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/47243 +Patch30: add-engine-relaying-libvirt-events.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/48781 +Patch31: avoid-incomprehensive-message-if-crashes.patch # BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -193,12 +211,12 @@ # requirements/base.txt %if 0%{?rhel} BuildRequires: python-jinja2 -BuildRequires: python-yaml BuildRequires: python-markupsafe +BuildRequires: python-yaml %else BuildRequires: python-Jinja2 -BuildRequires: python-PyYAML BuildRequires: python-MarkupSafe +BuildRequires: python-PyYAML %endif BuildRequires: python-futures >= 2.0 @@ -231,16 +249,16 @@ # requirements/base.txt %if 0%{?rhel} Requires: python-jinja2 -Requires: python-yaml Requires: python-markupsafe +Requires: python-yaml Requires: yum %if 0%{?rhel} == 6 Requires: yum-plugin-security %endif %else Requires: python-Jinja2 -Requires: python-PyYAML Requires: python-MarkupSafe +Requires: python-PyYAML %endif Requires: python-futures >= 2.0 @@ -280,7 +298,7 @@ Group: System/Management Requires: %{name} = %{version}-%{release} BuildRequires: python-rpm-macros -BuildRequires: python3 +BuildRequires: python3 < 3.7 BuildRequires: python3-devel # requirements/base.txt %if 0%{?rhel} @@ -311,7 +329,7 @@ %if %{with builddocs} BuildRequires: python3-sphinx %endif -Requires: python3 +Requires: python3 < 3.7 # %if ! 0%{?suse_version} > 1110 Requires: python3-certifi @@ -591,6 +609,12 @@ %patch23 -p1 %patch24 -p1 %patch25 -p1 +%patch26 -p1 +%patch27 -p1 +%patch28 -p1 +%patch29 -p1 +%patch30 -p1 +%patch31 -p1 %build %if 0%{?build_py2} @@ -1232,7 +1256,8 @@ %{_mandir}/man1/salt-call.1.gz %{_mandir}/man1/spm.1.gz %config(noreplace) %{_sysconfdir}/logrotate.d/salt -%doc LICENSE AUTHORS README.rst HACKING.rst README.SUSE +%license LICENSE +%doc AUTHORS README.rst HACKING.rst README.SUSE # %dir %attr(0750, root, salt) %{_sysconfdir}/salt %dir %attr(0750, root, salt) %{_sysconfdir}/salt/pki ++++++ _lastrevision ++++++ --- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.164036798 +0200 +++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.164036798 +0200 @@ -1 +1 @@ -d20075a576c1c9931e083798899099cde1a4109e \ No newline at end of file +eb0ca38e07c96eb021ac7490ac1f61a54dc9d904 ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.180036826 +0200 +++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.180036826 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/openSUSE/salt-packaging.git</param> <param name="subdir">salt</param> <param name="filename">package</param> - <param name="revision">2018.3.0</param> + <param name="revision">2018.3.2</param> <param name="scm">git</param> </service> <service name="extract_file" mode="disabled"> @@ -12,8 +12,8 @@ </service> <service name="download_url" mode="disabled"> <param name="host">codeload.github.com</param> - <param name="path">saltstack/salt/tar.gz/v2018.3.0</param> - <param name="filename">v2018.3.0.tar.gz</param> + <param name="path">saltstack/salt/tar.gz/v2018.3.2</param> + <param name="filename">v2018.3.2.tar.gz</param> </service> <service name="update_changelog" mode="disabled"></service> </services> ++++++ accounting-for-when-files-in-an-archive-contain-non-.patch ++++++
From 5305ee8bf07e40dc54aefcbb92016ff868135749 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway"
Date: Wed, 9 May 2018 09:33:58 -0700 Subject: [PATCH] Accounting for when files in an archive contain non-ascii characters
Updating integration/modules/test_archive to include filenames with unicode characters.
only convert to bytes when using Python2
Updating with requested changes.
Ensure member names are decoded before adding to various lists.
Adding a test to ensure archive.list returns the right results when a tar file contains a file with unicode in it's name.
---
salt/modules/archive.py | 13 +++---
salt/states/archive.py | 4 +-
tests/integration/modules/test_archive.py | 52 ++++++++++++++++++++++-
3 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/salt/modules/archive.py b/salt/modules/archive.py
index 48f0efa18e..76cd3eeb97 100644
--- a/salt/modules/archive.py
+++ b/salt/modules/archive.py
@@ -186,12 +186,13 @@ def list_(name,
else {'fileobj': cached.stdout, 'mode': 'r|'}
with contextlib.closing(tarfile.open(**open_kwargs)) as tar_archive:
for member in tar_archive.getmembers():
+ _member = salt.utils.data.decode(member.name)
if member.issym():
- links.append(member.name)
+ links.append(_member)
elif member.isdir():
- dirs.append(member.name + '/')
+ dirs.append(_member + '/')
else:
- files.append(member.name)
+ files.append(_member)
return dirs, files, links
except tarfile.ReadError:
@@ -410,9 +411,9 @@ def list_(name,
item.sort()
if verbose:
- ret = {'dirs': sorted(dirs),
- 'files': sorted(files),
- 'links': sorted(links)}
+ ret = {'dirs': sorted(salt.utils.data.decode_list(dirs)),
+ 'files': sorted(salt.utils.data.decode_list(files)),
+ 'links': sorted(salt.utils.data.decode_list(links))}
ret['top_level_dirs'] = [x for x in ret['dirs']
if x.count('/') == 1]
ret['top_level_files'] = [x for x in ret['files']
diff --git a/salt/states/archive.py b/salt/states/archive.py
index 847c5e9914..6838b2202d 100644
--- a/salt/states/archive.py
+++ b/salt/states/archive.py
@@ -1090,7 +1090,7 @@ def extracted(name,
and not stat.S_ISDIR(x)),
(contents['links'], stat.S_ISLNK)):
for path in path_list:
- full_path = os.path.join(name, path)
+ full_path = salt.utils.path.join(name, path)
try:
path_mode = os.lstat(full_path.rstrip(os.sep)).st_mode
if not func(path_mode):
@@ -1259,7 +1259,7 @@ def extracted(name,
if options is None:
try:
with closing(tarfile.open(cached, 'r')) as tar:
- tar.extractall(name)
+ tar.extractall(salt.utils.stringutils.to_str(name))
files = tar.getnames()
if trim_output:
files = files[:trim_output]
diff --git a/tests/integration/modules/test_archive.py b/tests/integration/modules/test_archive.py
index 59fe2f5f61..4301b9e3b0 100644
--- a/tests/integration/modules/test_archive.py
+++ b/tests/integration/modules/test_archive.py
@@ -47,7 +47,7 @@ class ArchiveTest(ModuleCase):
self.arch = os.path.join(self.base_path, 'archive.{0}'.format(arch_fmt))
self.dst = os.path.join(self.base_path, '{0}_dst_dir'.format(arch_fmt))
- def _set_up(self, arch_fmt):
+ def _set_up(self, arch_fmt, unicode_filename=False):
'''
Create source file tree and destination directory
@@ -62,7 +62,11 @@ class ArchiveTest(ModuleCase):
# Create source
os.makedirs(self.src)
- with salt.utils.files.fopen(os.path.join(self.src, 'file'), 'w') as theorem:
+ if unicode_filename:
+ filename = 'file®'
+ else:
+ filename = 'file'
+ with salt.utils.files.fopen(os.path.join(self.src, filename), 'w') as theorem:
theorem.write(textwrap.dedent(salt.utils.stringutils.to_str(r'''\
Compression theorem of computational complexity theory:
@@ -150,6 +154,50 @@ class ArchiveTest(ModuleCase):
self._tear_down()
+ @skipIf(not salt.utils.path.which('tar'), 'Cannot find tar executable')
+ def test_tar_pack_unicode(self):
+ '''
+ Validate using the tar function to create archives
+ '''
+ self._set_up(arch_fmt='tar', unicode_filename=True)
+
+ # Test create archive
+ ret = self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
+ self.assertTrue(isinstance(ret, list), six.text_type(ret))
+ self._assert_artifacts_in_ret(ret)
+
+ self._tear_down()
+
+ @skipIf(not salt.utils.path.which('tar'), 'Cannot find tar executable')
+ def test_tar_unpack_unicode(self):
+ '''
+ Validate using the tar function to extract archives
+ '''
+ self._set_up(arch_fmt='tar', unicode_filename=True)
+ self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
+
+ # Test extract archive
+ ret = self.run_function('archive.tar', ['-xvf', self.arch], dest=self.dst)
+ self.assertTrue(isinstance(ret, list), six.text_type(ret))
+ self._assert_artifacts_in_ret(ret)
+
+ self._tear_down()
+
+ @skipIf(not salt.utils.path.which('tar'), 'Cannot find tar executable')
+ def test_tar_list_unicode(self):
+ '''
+ Validate using the tar function to extract archives
+ '''
+ self._set_up(arch_fmt='tar', unicode_filename=True)
+ self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
+
+ # Test list archive
+ ret = self.run_function('archive.list', name=self.arch)
+ self.assertTrue(isinstance(ret, list), six.text_type(ret))
+ self._assert_artifacts_in_ret(ret)
+
+ self._tear_down()
+
@skipIf(not salt.utils.path.which('gzip'), 'Cannot find gzip executable')
def test_gzip(self):
'''
--
2.17.1
++++++ activate-all-beacons-sources-config-pillar-grains.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.204036866 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.204036866 +0200
@@ -1,4 +1,4 @@
-From 957ac8fe161db2c4b3b8fe8b84027bc15e144a49 Mon Sep 17 00:00:00 2001
+From 5b48dee2f1b9a8203490e97620581b3a04d42632 Mon Sep 17 00:00:00 2001
From: Bo Maryniuk
From 9de54cf6f7d8d6da4212842fef8c4c658a2a9b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Mon, 14 May 2018 11:33:13 +0100 Subject: [PATCH] Add "all_versions" parameter to include all installed version on rpm.info
Enable "all_versions" parameter for zypper.info_installed Enable "all_versions" parameter for yumpkg.info_installed Prevent adding failed packages when pkg name contains the arch (on SUSE) Add 'all_versions' documentation for info_installed on yum/zypper modules Add unit tests for info_installed with all_versions Refactor: use dict.setdefault instead if-else statement Allow removing only specific package versions with zypper and yum --- salt/modules/rpm.py | 18 ++++++++--- salt/modules/yumpkg.py | 49 ++++++++++++++++++++++-------- salt/modules/zypper.py | 64 ++++++++++++++++++++++++++++++++------- salt/states/pkg.py | 33 +++++++++++++++++++- tests/unit/modules/test_yumpkg.py | 50 ++++++++++++++++++++++++++++++ tests/unit/modules/test_zypper.py | 50 ++++++++++++++++++++++++++++++ 6 files changed, 236 insertions(+), 28 deletions(-) diff --git a/salt/modules/rpm.py b/salt/modules/rpm.py index d065f1e2d9..3683234f59 100644 --- a/salt/modules/rpm.py +++ b/salt/modules/rpm.py @@ -453,7 +453,7 @@ def diff(package, path): return res -def info(*packages, **attr): +def info(*packages, **kwargs): ''' Return a detailed package(s) summary information. If no packages specified, all packages will be returned. @@ -467,6 +467,9 @@ def info(*packages, **attr): version, vendor, release, build_date, build_date_time_t, install_date, install_date_time_t, build_host, group, source_rpm, arch, epoch, size, license, signature, packager, url, summary, description. + :param all_versions: + Return information for all installed versions of the packages + :return: CLI example: @@ -476,7 +479,9 @@ def info(*packages, **attr): salt '*' lowpkg.info apache2 bash salt '*' lowpkg.info apache2 bash attr=version salt '*' lowpkg.info apache2 bash attr=version,build_date_iso,size + salt '*' lowpkg.info apache2 bash attr=version,build_date_iso,size all_versions=True ''' + all_versions = kwargs.get('all_versions', False) # LONGSIZE is not a valid tag for all versions of rpm. If LONGSIZE isn't # available, then we can just use SIZE for older versions. See Issue #31366. rpm_tags = __salt__['cmd.run_stdout']( @@ -516,7 +521,7 @@ def info(*packages, **attr): "edition": "edition: %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\\n", } - attr = attr.get('attr', None) and attr['attr'].split(",") or None + attr = kwargs.get('attr', None) and kwargs['attr'].split(",") or None query = list() if attr: for attr_k in attr: @@ -610,8 +615,13 @@ def info(*packages, **attr): if pkg_name.startswith('gpg-pubkey'): continue if pkg_name not in ret: - ret[pkg_name] = pkg_data.copy() - del ret[pkg_name]['edition'] + if all_versions: + ret[pkg_name] = [pkg_data.copy()] + else: + ret[pkg_name] = pkg_data.copy() + del ret[pkg_name]['edition'] + elif all_versions: + ret[pkg_name].append(pkg_data.copy()) return ret diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 747142264d..9ce4926790 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -994,31 +994,39 @@ def list_downloaded(): return ret -def info_installed(*names): +def info_installed(*names, **kwargs): ''' .. versionadded:: 2015.8.1 Return the information of the named package(s), installed on the system. + :param all_versions: + Include information for all versions of the packages installed on the minion. + CLI example: .. code-block:: bash salt '*' pkg.info_installed <package1> salt '*' pkg.info_installed <package1> <package2> <package3> ... + salt '*' pkg.info_installed <package1> <package2> <package3> all_versions=True ''' + all_versions = kwargs.get('all_versions', False) ret = dict() - for pkg_name, pkg_nfo in __salt__['lowpkg.info'](*names).items(): - t_nfo = dict() - # Translate dpkg-specific keys to a common structure - for key, value in pkg_nfo.items(): - if key == 'source_rpm': - t_nfo['source'] = value + for pkg_name, pkgs_nfo in __salt__['lowpkg.info'](*names, **kwargs).items(): + pkg_nfo = pkgs_nfo if all_versions else [pkgs_nfo] + for _nfo in pkg_nfo: + t_nfo = dict() + # Translate dpkg-specific keys to a common structure + for key, value in _nfo.items(): + if key == 'source_rpm': + t_nfo['source'] = value + else: + t_nfo[key] = value + if not all_versions: + ret[pkg_name] = t_nfo else: - t_nfo[key] = value - - ret[pkg_name] = t_nfo - + ret.setdefault(pkg_name, []).append(t_nfo) return ret @@ -1919,7 +1927,24 @@ def remove(name=None, pkgs=None, **kwargs): # pylint: disable=W0613 raise CommandExecutionError(exc) old = list_pkgs() - targets = [x for x in pkg_params if x in old] + targets = [] + for target in pkg_params: + # Check if package version set to be removed is actually installed: + # old[target] contains a comma-separated list of installed versions + if target in old and not pkg_params[target]: + targets.append(target) + elif target in old and pkg_params[target] in old[target].split(','): + arch = '' + pkgname = target + try: + namepart, archpart = target.rsplit('.', 1) + except ValueError: + pass + else: + if archpart in salt.utils.pkg.rpm.ARCHES: + arch = '.' + archpart + pkgname = namepart + targets.append('{0}-{1}{2}'.format(pkgname, pkg_params[target], arch)) if not targets: return {} diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 668143bdd9..06f8335c18 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -470,28 +470,37 @@ def info_installed(*names, **kwargs): Valid attributes are: ignore, report + :param all_versions: + Include information for all versions of the packages installed on the minion. + CLI example: .. code-block:: bash salt '*' pkg.info_installed <package1> salt '*' pkg.info_installed <package1> <package2> <package3> ... - salt '*' pkg.info_installed <package1> attr=version,vendor + salt '*' pkg.info_installed <package1> <package2> <package3> all_versions=True + salt '*' pkg.info_installed <package1> attr=version,vendor all_versions=True salt '*' pkg.info_installed <package1> <package2> <package3> ... attr=version,vendor salt '*' pkg.info_installed <package1> <package2> <package3> ... attr=version,vendor errors=ignore salt '*' pkg.info_installed <package1> <package2> <package3> ... attr=version,vendor errors=report ''' + all_versions = kwargs.get('all_versions', False) ret = dict() - for pkg_name, pkg_nfo in __salt__['lowpkg.info'](*names, **kwargs).items(): - t_nfo = dict() - # Translate dpkg-specific keys to a common structure - for key, value in six.iteritems(pkg_nfo): - if key == 'source_rpm': - t_nfo['source'] = value + for pkg_name, pkgs_nfo in __salt__['lowpkg.info'](*names, **kwargs).items(): + pkg_nfo = pkgs_nfo if all_versions else [pkgs_nfo] + for _nfo in pkg_nfo: + t_nfo = dict() + # Translate dpkg-specific keys to a common structure + for key, value in six.iteritems(_nfo): + if key == 'source_rpm': + t_nfo['source'] = value + else: + t_nfo[key] = value + if not all_versions: + ret[pkg_name] = t_nfo else: - t_nfo[key] = value - ret[pkg_name] = t_nfo - + ret.setdefault(pkg_name, []).append(t_nfo) return ret @@ -1494,7 +1503,14 @@ def _uninstall(name=None, pkgs=None): raise CommandExecutionError(exc) old = list_pkgs() - targets = [target for target in pkg_params if target in old] + targets = [] + for target in pkg_params: + # Check if package version set to be removed is actually installed: + # old[target] contains a comma-separated list of installed versions + if target in old and pkg_params[target] in old[target].split(','): + targets.append(target + "-" + pkg_params[target]) + elif target in old and not pkg_params[target]: + targets.append(target) if not targets: return {} @@ -1517,6 +1533,32 @@ def _uninstall(name=None, pkgs=None): return ret +def normalize_name(name): + ''' + Strips the architecture from the specified package name, if necessary. + Circumstances where this would be done include: + + * If the arch is 32 bit and the package name ends in a 32-bit arch. + * If the arch matches the OS arch, or is ``noarch``. + + CLI Example: + + .. code-block:: bash + + salt '*' pkg.normalize_name zsh.x86_64 + ''' + try: + arch = name.rsplit('.', 1)[-1] + if arch not in salt.utils.pkg.rpm.ARCHES + ('noarch',): + return name + except ValueError: + return name + if arch in (__grains__['osarch'], 'noarch') \ + or salt.utils.pkg.rpm.check_32(arch, osarch=__grains__['osarch']): + return name[:-(len(arch) + 1)] + return name + + def remove(name=None, pkgs=None, **kwargs): # pylint: disable=unused-argument ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 diff --git a/salt/states/pkg.py b/salt/states/pkg.py index 2682ee17f9..ed405cb6b5 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -415,6 +415,16 @@ def _find_remove_targets(name=None, if __grains__['os'] == 'FreeBSD' and origin: cver = [k for k, v in six.iteritems(cur_pkgs) if v['origin'] == pkgname] + elif __grains__['os_family'] == 'Suse': + # On SUSE systems. Zypper returns packages without "arch" in name + try: + namepart, archpart = pkgname.rsplit('.', 1) + except ValueError: + cver = cur_pkgs.get(pkgname, []) + else: + if archpart in salt.utils.pkg.rpm.ARCHES + ("noarch",): + pkgname = namepart + cver = cur_pkgs.get(pkgname, []) else: cver = cur_pkgs.get(pkgname, []) @@ -844,6 +854,17 @@ def _verify_install(desired, new_pkgs, ignore_epoch=False, new_caps=None): cver = new_pkgs.get(pkgname.split('%')[0]) elif __grains__['os_family'] == 'Debian': cver = new_pkgs.get(pkgname.split('=')[0]) + elif __grains__['os_family'] == 'Suse': + # On SUSE systems. Zypper returns packages without "arch" in name + try: + namepart, archpart = pkgname.rsplit('.', 1) + except ValueError: + cver = new_pkgs.get(pkgname) + else: + if archpart in salt.utils.pkg.rpm.ARCHES + ("noarch",): + cver = new_pkgs.get(namepart) + else: + cver = new_pkgs.get(pkgname) else: cver = new_pkgs.get(pkgname) if not cver and pkgname in new_caps: @@ -2674,7 +2695,17 @@ def _uninstall( changes = __salt__['pkg.{0}'.format(action)](name, pkgs=pkgs, version=version, **kwargs) new = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs) - failed = [x for x in pkg_params if x in new] + failed = [] + for x in pkg_params: + if __grains__['os_family'] in ['Suse', 'RedHat']: + # Check if the package version set to be removed is actually removed: + if x in new and not pkg_params[x]: + failed.append(x) + elif x in new and pkg_params[x] in new[x]: + failed.append(x + "-" + pkg_params[x]) + elif x in new: + failed.append(x) + if action == 'purge': new_removed = __salt__['pkg.list_pkgs'](versions_as_list=True, removed=True, diff --git a/tests/unit/modules/test_yumpkg.py b/tests/unit/modules/test_yumpkg.py index 28b6e1294c..c73f2582b9 100644 --- a/tests/unit/modules/test_yumpkg.py +++ b/tests/unit/modules/test_yumpkg.py @@ -601,3 +601,53 @@ class YumTestCase(TestCase, LoaderModuleMockMixin): '--branch=foo', '--exclude=kernel*', 'upgrade'], output_loglevel='trace', python_shell=False) + + def test_info_installed_with_all_versions(self): + ''' + Test the return information of all versions for the named package(s), installed on the system. + + :return: + ''' + run_out = { + 'virgo-dummy': [ + {'build_date': '2015-07-09T10:55:19Z', + 'vendor': 'openSUSE Build Service', + 'description': 'This is the Virgo dummy package used for testing SUSE Manager', + 'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com', + 'build_date_time_t': 1436432119, 'relocations': '(not relocatable)', + 'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z', + 'install_date_time_t': 1456241517, 'summary': 'Virgo dummy package', 'version': '1.0', + 'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9', + 'release': '1.1', 'group': 'Applications/System', 'arch': 'i686', 'size': '17992'}, + {'build_date': '2015-07-09T10:15:19Z', + 'vendor': 'openSUSE Build Service', + 'description': 'This is the Virgo dummy package used for testing SUSE Manager', + 'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com', + 'build_date_time_t': 1436432119, 'relocations': '(not relocatable)', + 'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z', + 'install_date_time_t': 14562415127, 'summary': 'Virgo dummy package', 'version': '1.0', + 'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9', + 'release': '1.1', 'group': 'Applications/System', 'arch': 'x86_64', 'size': '13124'} + ], + 'libopenssl1_0_0': [ + {'build_date': '2015-11-04T23:20:34Z', 'vendor': 'SUSE LLC https://www.suse.com/', + 'description': 'The OpenSSL Project is a collaborative effort.', + 'license': 'OpenSSL', 'build_host': 'sheep11', 'url': 'https://www.openssl.org/', + 'build_date_time_t': 1446675634, 'relocations': '(not relocatable)', + 'source_rpm': 'openssl-1.0.1i-34.1.src.rpm', 'install_date': '2016-02-23T16:31:35Z', + 'install_date_time_t': 1456241495, 'summary': 'Secure Sockets and Transport Layer Security', + 'version': '1.0.1i', 'signature': 'RSA/SHA256, Wed Nov 4 22:21:34 2015, Key ID 70af9e8139db7c82', + 'release': '34.1', 'group': 'Productivity/Networking/Security', 'packager': 'https://www.suse.com/', + 'arch': 'x86_64', 'size': '2576912'} + ] + } + with patch.dict(yumpkg.__salt__, {'lowpkg.info': MagicMock(return_value=run_out)}): + installed = yumpkg.info_installed(all_versions=True) + # Test overall products length + self.assertEqual(len(installed), 2) + + # Test multiple versions for the same package + for pkg_name, pkg_info_list in installed.items(): + self.assertEqual(len(pkg_info_list), 2 if pkg_name == "virgo-dummy" else 1) + for info in pkg_info_list: + self.assertTrue(info['arch'] in ('x86_64', 'i686')) diff --git a/tests/unit/modules/test_zypper.py b/tests/unit/modules/test_zypper.py index 539a950252..6eccee568b 100644 --- a/tests/unit/modules/test_zypper.py +++ b/tests/unit/modules/test_zypper.py @@ -327,6 +327,56 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin): installed = zypper.info_installed() self.assertEqual(installed['vīrgô']['description'], 'vīrgô d€šçripţiǫñ') + def test_info_installed_with_all_versions(self): + ''' + Test the return information of all versions for the named package(s), installed on the system. + + :return: + ''' + run_out = { + 'virgo-dummy': [ + {'build_date': '2015-07-09T10:55:19Z', + 'vendor': 'openSUSE Build Service', + 'description': 'This is the Virgo dummy package used for testing SUSE Manager', + 'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com', + 'build_date_time_t': 1436432119, 'relocations': '(not relocatable)', + 'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z', + 'install_date_time_t': 1456241517, 'summary': 'Virgo dummy package', 'version': '1.0', + 'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9', + 'release': '1.1', 'group': 'Applications/System', 'arch': 'i686', 'size': '17992'}, + {'build_date': '2015-07-09T10:15:19Z', + 'vendor': 'openSUSE Build Service', + 'description': 'This is the Virgo dummy package used for testing SUSE Manager', + 'license': 'GPL-2.0', 'build_host': 'sheep05', 'url': 'http://www.suse.com', + 'build_date_time_t': 1436432119, 'relocations': '(not relocatable)', + 'source_rpm': 'virgo-dummy-1.0-1.1.src.rpm', 'install_date': '2016-02-23T16:31:57Z', + 'install_date_time_t': 14562415127, 'summary': 'Virgo dummy package', 'version': '1.0', + 'signature': 'DSA/SHA1, Thu Jul 9 08:55:33 2015, Key ID 27fa41bd8a7c64f9', + 'release': '1.1', 'group': 'Applications/System', 'arch': 'x86_64', 'size': '13124'} + ], + 'libopenssl1_0_0': [ + {'build_date': '2015-11-04T23:20:34Z', 'vendor': 'SUSE LLC https://www.suse.com/', + 'description': 'The OpenSSL Project is a collaborative effort.', + 'license': 'OpenSSL', 'build_host': 'sheep11', 'url': 'https://www.openssl.org/', + 'build_date_time_t': 1446675634, 'relocations': '(not relocatable)', + 'source_rpm': 'openssl-1.0.1i-34.1.src.rpm', 'install_date': '2016-02-23T16:31:35Z', + 'install_date_time_t': 1456241495, 'summary': 'Secure Sockets and Transport Layer Security', + 'version': '1.0.1i', 'signature': 'RSA/SHA256, Wed Nov 4 22:21:34 2015, Key ID 70af9e8139db7c82', + 'release': '34.1', 'group': 'Productivity/Networking/Security', 'packager': 'https://www.suse.com/', + 'arch': 'x86_64', 'size': '2576912'} + ] + } + with patch.dict(zypper.__salt__, {'lowpkg.info': MagicMock(return_value=run_out)}): + installed = zypper.info_installed(all_versions=True) + # Test overall products length + self.assertEqual(len(installed), 2) + + # Test multiple versions for the same package + for pkg_name, pkg_info_list in installed.items(): + self.assertEqual(len(pkg_info_list), 2 if pkg_name == "virgo-dummy" else 1) + for info in pkg_info_list: + self.assertTrue(info['arch'] in ('x86_64', 'i686')) + def test_info_available(self): ''' Test return the information of the named package available for the system. -- 2.13.7 ++++++ add-custom-suse-capabilities-as-grains.patch ++++++
From b02aee33a3aa1676cbfdf3a0ed936eef8a40adfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Thu, 21 Jun 2018 11:57:57 +0100 Subject: [PATCH] Add custom SUSE capabilities as Grains
--- salt/grains/extra.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/salt/grains/extra.py b/salt/grains/extra.py index fff70e9f5b..4fb58674bf 100644 --- a/salt/grains/extra.py +++ b/salt/grains/extra.py @@ -75,3 +75,10 @@ def config(): log.warning("Bad syntax in grains file! Skipping.") return {} return {} + + +def suse_backported_capabilities(): + return { + '__suse_reserved_pkg_all_versions_support': True, + '__suse_reserved_pkg_patches_support': True + } -- 2.13.7 ++++++ add-engine-relaying-libvirt-events.patch ++++++ ++++ 894 lines (skipped) ++++++ add-environment-variable-to-know-if-yum-is-invoked-f.patch ++++++
From 39d9d9fb26f9aff83fce4ce67d5b2a6bd4f60b95 Mon Sep 17 00:00:00 2001 From: Marcelo Chiaradia
Date: Thu, 7 Jun 2018 10:29:41 +0200 Subject: [PATCH] Add environment variable to know if yum is invoked from Salt(bsc#1057635)
--- salt/modules/yumpkg.py | 59 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 9ce4926790..51832bf883 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -452,7 +452,8 @@ def latest_version(*names, **kwargs): out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', ignore_retcode=True, - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) if out['retcode'] != 0: if out['stderr']: # Check first if this is just a matter of the packages being @@ -850,7 +851,8 @@ def list_repo_pkgs(*args, **kwargs): yum_version = None if _yum() != 'yum' else _LooseVersion( __salt__['cmd.run']( ['yum', '--version'], - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ).splitlines()[0].strip() ) # Really old version of yum; does not even have --showduplicates option @@ -865,7 +867,8 @@ def list_repo_pkgs(*args, **kwargs): cmd_prefix + [pkg_src], output_loglevel='trace', ignore_retcode=True, - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) if out['retcode'] == 0: _parse_output(out['stdout'], strict=True) @@ -882,7 +885,8 @@ def list_repo_pkgs(*args, **kwargs): cmd_prefix + [pkg_src], output_loglevel='trace', ignore_retcode=True, - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) if out['retcode'] == 0: _parse_output(out['stdout'], strict=True) @@ -898,7 +902,8 @@ def list_repo_pkgs(*args, **kwargs): out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', ignore_retcode=True, - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) if out['retcode'] != 0 and 'Error:' in out['stdout']: continue _parse_output(out['stdout']) @@ -955,7 +960,8 @@ def list_upgrades(refresh=True, **kwargs): out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', ignore_retcode=True, - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) if out['retcode'] != 0 and 'Error:' in out: return {} @@ -1090,12 +1096,13 @@ def refresh_db(**kwargs): clean_cmd.extend(options) update_cmd.extend(options) - __salt__['cmd.run'](clean_cmd, python_shell=False) + __salt__['cmd.run'](clean_cmd, python_shell=False, env={"SALT_RUNNING": '1'}) if check_update_: result = __salt__['cmd.retcode'](update_cmd, output_loglevel='trace', ignore_retcode=True, - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) return retcodes.get(result, False) return True @@ -1634,7 +1641,8 @@ def install(name=None, cmd, output_loglevel='trace', python_shell=False, - redirect_stderr=True + redirect_stderr=True, + env={"SALT_RUNNING": '1'} ) if out['retcode'] != 0: errors.append(out['stdout']) @@ -1654,7 +1662,8 @@ def install(name=None, cmd, output_loglevel='trace', python_shell=False, - redirect_stderr=True + redirect_stderr=True, + env={"SALT_RUNNING": '1'} ) if out['retcode'] != 0: errors.append(out['stdout']) @@ -1674,7 +1683,8 @@ def install(name=None, cmd, output_loglevel='trace', python_shell=False, - redirect_stderr=True + redirect_stderr=True, + env={"SALT_RUNNING": '1'} ) if out['retcode'] != 0: errors.append(out['stdout']) @@ -1866,7 +1876,8 @@ def upgrade(name=None, result = __salt__['cmd.run_all'](cmd, output_loglevel='trace', - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) __context__.pop('pkg.list_pkgs', None) new = list_pkgs() ret = salt.utils.data.compare_dicts(old, new) @@ -1957,7 +1968,8 @@ def remove(name=None, pkgs=None, **kwargs): # pylint: disable=W0613 out = __salt__['cmd.run_all']( [_yum(), '-y', 'remove'] + targets, output_loglevel='trace', - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) if out['retcode'] != 0 and out['stderr']: @@ -2094,7 +2106,8 @@ def hold(name=None, pkgs=None, sources=None, normalize=True, **kwargs): # pylin else: out = __salt__['cmd.run_all']( [_yum(), 'versionlock', target], - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) if out['retcode'] == 0: @@ -2203,7 +2216,8 @@ def unhold(name=None, pkgs=None, sources=None, **kwargs): # pylint: disable=W06 else: out = __salt__['cmd.run_all']( [_yum(), 'versionlock', 'delete'] + search_locks, - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) if out['retcode'] == 0: @@ -2254,7 +2268,8 @@ def list_holds(pattern=__HOLD_PATTERN, full=True): _check_versionlock() out = __salt__['cmd.run']([_yum(), 'versionlock', 'list'], - python_shell=False) + python_shell=False, + env={"SALT_RUNNING": '1'}) ret = [] for line in salt.utils.itertools.split(out, '\n'): match = _get_hold(line, pattern=pattern, full=full) @@ -2319,7 +2334,8 @@ def group_list(): out = __salt__['cmd.run_stdout']( [_yum(), 'grouplist', 'hidden'], output_loglevel='trace', - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) key = None for line in salt.utils.itertools.split(out, '\n'): @@ -2386,7 +2402,8 @@ def group_info(name, expand=False): out = __salt__['cmd.run_stdout']( cmd, output_loglevel='trace', - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) g_info = {} @@ -3055,7 +3072,8 @@ def download(*packages): __salt__['cmd.run']( cmd, output_loglevel='trace', - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) ret = {} for dld_result in os.listdir(CACHE_DIR): @@ -3130,7 +3148,8 @@ def _get_patches(installed_only=False): cmd = [_yum(), '--quiet', 'updateinfo', 'list', 'all'] ret = __salt__['cmd.run_stdout']( cmd, - python_shell=False + python_shell=False, + env={"SALT_RUNNING": '1'} ) for line in salt.utils.itertools.split(ret, os.linesep): inst, advisory_id, sev, pkg = re.match(r'([i|\s]) ([^\s]+) +([^\s]+) +([^\s]+)', -- 2.13.7 ++++++ add-other-attribute-to-gecos-fields-to-avoid-inconsi.patch ++++++
From cc8d6eaddf59973a94512779853558789b56ca3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Wed, 25 Apr 2018 12:55:36 +0100 Subject: [PATCH] Add 'other' attribute to GECOS fields to avoid inconsistencies with chfn
Fix unsupported chars checking on GECOS fields
Add unit test for new method 'user.chother'
Do make comparisons in a single line
Add 'other' as valid kwargs for 'user.add' method
---
salt/modules/useradd.py | 41 ++++++++++++++++++++++++++++----------
salt/states/user.py | 28 ++++++++++++++++++--------
tests/unit/modules/test_useradd.py | 36 +++++++++++++++++++++++++++++++--
3 files changed, 84 insertions(+), 21 deletions(-)
diff --git a/salt/modules/useradd.py b/salt/modules/useradd.py
index a61ba0e960..fc3c82a8bc 100644
--- a/salt/modules/useradd.py
+++ b/salt/modules/useradd.py
@@ -60,17 +60,18 @@ def _get_gecos(name):
Retrieve GECOS field info and return it in dictionary form
'''
gecos_field = salt.utils.stringutils.to_unicode(
- pwd.getpwnam(_quote_username(name)).pw_gecos).split(',', 3)
+ pwd.getpwnam(_quote_username(name)).pw_gecos).split(',', 4)
if not gecos_field:
return {}
else:
# Assign empty strings for any unspecified trailing GECOS fields
- while len(gecos_field) < 4:
+ while len(gecos_field) < 5:
gecos_field.append('')
return {'fullname': salt.utils.locales.sdecode(gecos_field[0]),
'roomnumber': salt.utils.locales.sdecode(gecos_field[1]),
'workphone': salt.utils.locales.sdecode(gecos_field[2]),
- 'homephone': salt.utils.locales.sdecode(gecos_field[3])}
+ 'homephone': salt.utils.locales.sdecode(gecos_field[3]),
+ 'other': salt.utils.locales.sdecode(gecos_field[4])}
def _build_gecos(gecos_dict):
@@ -78,10 +79,11 @@ def _build_gecos(gecos_dict):
Accepts a dictionary entry containing GECOS field names and their values,
and returns a full GECOS comment string, to be used with usermod.
'''
- return '{0},{1},{2},{3}'.format(gecos_dict.get('fullname', ''),
- gecos_dict.get('roomnumber', ''),
- gecos_dict.get('workphone', ''),
- gecos_dict.get('homephone', '')).rstrip(',')
+ return '{0},{1},{2},{3},{4}'.format(gecos_dict.get('fullname', ''),
+ gecos_dict.get('roomnumber', ''),
+ gecos_dict.get('workphone', ''),
+ gecos_dict.get('homephone', ''),
+ gecos_dict.get('other', ''),).rstrip(',')
def _update_gecos(name, key, value, root=None):
@@ -124,6 +126,7 @@ def add(name,
roomnumber='',
workphone='',
homephone='',
+ other='',
createhome=True,
loginclass=None,
root=None,
@@ -237,6 +240,8 @@ def add(name,
chworkphone(name, workphone)
if homephone:
chhomephone(name, homephone)
+ if other:
+ chother(name, other)
return True
@@ -507,6 +512,19 @@ def chhomephone(name, homephone):
return _update_gecos(name, 'homephone', homephone)
+def chother(name, other):
+ '''
+ Change the user's other GECOS attribute
+
+ CLI Example:
+
+ .. code-block:: bash
+
+ salt '*' user.chother foobar
+ '''
+ return _update_gecos(name, 'other', other)
+
+
def chloginclass(name, loginclass, root=None):
'''
Change the default login class of the user
@@ -588,9 +606,9 @@ def _format_info(data):
Return user information in a pretty way
'''
# Put GECOS info into a list
- gecos_field = salt.utils.stringutils.to_unicode(data.pw_gecos).split(',', 3)
- # Make sure our list has at least four elements
- while len(gecos_field) < 4:
+ gecos_field = salt.utils.stringutils.to_unicode(data.pw_gecos).split(',', 4)
+ # Make sure our list has at least five elements
+ while len(gecos_field) < 5:
gecos_field.append('')
return {'gid': data.pw_gid,
@@ -603,7 +621,8 @@ def _format_info(data):
'fullname': gecos_field[0],
'roomnumber': gecos_field[1],
'workphone': gecos_field[2],
- 'homephone': gecos_field[3]}
+ 'homephone': gecos_field[3],
+ 'other': gecos_field[4]}
@salt.utils.decorators.path.which('id')
diff --git a/salt/states/user.py b/salt/states/user.py
index f4ae81dd31..34f5a9d541 100644
--- a/salt/states/user.py
+++ b/salt/states/user.py
@@ -68,6 +68,7 @@ def _changes(name,
roomnumber='',
workphone='',
homephone='',
+ other='',
loginclass=None,
date=None,
mindays=0,
@@ -170,24 +171,26 @@ def _changes(name,
# MacOS doesn't have full GECOS support, so check for the "ch" functions
# and ignore these parameters if these functions do not exist.
- if 'user.chroomnumber' in __salt__ \
- and roomnumber is not None:
+ if 'user.chroomnumber' in __salt__ and roomnumber is not None:
roomnumber = sdecode_if_string(roomnumber)
lusr['roomnumber'] = sdecode_if_string(lusr['roomnumber'])
if lusr['roomnumber'] != roomnumber:
change['roomnumber'] = roomnumber
- if 'user.chworkphone' in __salt__ \
- and workphone is not None:
+ if 'user.chworkphone' in __salt__ and workphone is not None:
workphone = sdecode_if_string(workphone)
lusr['workphone'] = sdecode_if_string(lusr['workphone'])
if lusr['workphone'] != workphone:
change['workphone'] = workphone
- if 'user.chhomephone' in __salt__ \
- and homephone is not None:
+ if 'user.chhomephone' in __salt__ and homephone is not None:
homephone = sdecode_if_string(homephone)
lusr['homephone'] = sdecode_if_string(lusr['homephone'])
if lusr['homephone'] != homephone:
change['homephone'] = homephone
+ if 'user.chother' in __salt__ and other is not None:
+ other = sdecode_if_string(other)
+ lusr['other'] = sdecode_if_string(lusr['other'])
+ if lusr['other'] != other:
+ change['other'] = other
# OpenBSD/FreeBSD login class
if __grains__['kernel'] in ('OpenBSD', 'FreeBSD'):
if loginclass:
@@ -236,6 +239,7 @@ def present(name,
roomnumber=None,
workphone=None,
homephone=None,
+ other=None,
loginclass=None,
date=None,
mindays=None,
@@ -377,7 +381,10 @@ def present(name,
homephone
The user's home phone number (not supported in MacOS)
- If GECOS field contains more than 3 commas, this field will have the rest of 'em
+
+ other
+ The user's other attribute (not supported in MacOS)
+ If GECOS field contains more than 4 commas, this field will have the rest of 'em
.. versionchanged:: 2014.7.0
Shadow attribute support added.
@@ -448,6 +455,8 @@ def present(name,
workphone = sdecode(workphone)
if homephone is not None:
homephone = sdecode(homephone)
+ if other is not None:
+ other = sdecode(other)
# createhome not supported on Windows or Mac
if __grains__['kernel'] in ('Darwin', 'Windows'):
@@ -460,7 +469,7 @@ def present(name,
# the comma is used to separate field in GECOS, thus resulting into
# salt adding the end of fullname each time this function is called
- for gecos_field in ['fullname', 'roomnumber', 'workphone']:
+ for gecos_field in [fullname, roomnumber, workphone]:
if isinstance(gecos_field, string_types) and ',' in gecos_field:
ret['comment'] = "Unsupported char ',' in {0}".format(gecos_field)
ret['result'] = False
@@ -519,6 +528,7 @@ def present(name,
roomnumber,
workphone,
homephone,
+ other,
loginclass,
date,
mindays,
@@ -654,6 +664,7 @@ def present(name,
roomnumber,
workphone,
homephone,
+ other,
loginclass,
date,
mindays,
@@ -705,6 +716,7 @@ def present(name,
'roomnumber': roomnumber,
'workphone': workphone,
'homephone': homephone,
+ 'other': other,
'createhome': createhome,
'nologinit': nologinit,
'loginclass': loginclass}
diff --git a/tests/unit/modules/test_useradd.py b/tests/unit/modules/test_useradd.py
index fa30a0df71..e79c78c663 100644
--- a/tests/unit/modules/test_useradd.py
+++ b/tests/unit/modules/test_useradd.py
@@ -46,7 +46,8 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
'fullname': 'root',
'roomnumber': '',
'workphone': '',
- 'homephone': ''}
+ 'homephone': '',
+ 'other': ''}
@classmethod
def tearDownClass(cls):
@@ -96,7 +97,8 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
'fullname': 'root',
'roomnumber': '',
'workphone': '',
- 'homephone': ''}]
+ 'homephone': '',
+ 'other': ''}]
with patch('salt.modules.useradd._format_info', MagicMock(return_value=self.mock_pwall)):
self.assertEqual(useradd.getent(), ret)
@@ -330,6 +332,36 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
with patch.object(useradd, 'info', mock):
self.assertFalse(useradd.chhomephone('salt', 1))
+ # 'chother' function tests: 1
+
+ def test_chother(self):
+ '''
+ Test if the user's other GECOS attribute is changed
+ '''
+ mock = MagicMock(return_value=False)
+ with patch.object(useradd, '_get_gecos', mock):
+ self.assertFalse(useradd.chother('salt', 1))
+
+ mock = MagicMock(return_value={'other': 'foobar'})
+ with patch.object(useradd, '_get_gecos', mock):
+ self.assertTrue(useradd.chother('salt', 'foobar'))
+
+ mock = MagicMock(return_value={'other': 'foobar2'})
+ with patch.object(useradd, '_get_gecos', mock):
+ mock = MagicMock(return_value=None)
+ with patch.dict(useradd.__salt__, {'cmd.run': mock}):
+ mock = MagicMock(return_value={'other': 'foobar3'})
+ with patch.object(useradd, 'info', mock):
+ self.assertFalse(useradd.chother('salt', 'foobar'))
+
+ mock = MagicMock(return_value={'other': 'foobar3'})
+ with patch.object(useradd, '_get_gecos', mock):
+ mock = MagicMock(return_value=None)
+ with patch.dict(useradd.__salt__, {'cmd.run': mock}):
+ mock = MagicMock(return_value={'other': 'foobar3'})
+ with patch.object(useradd, 'info', mock):
+ self.assertFalse(useradd.chother('salt', 'foobar'))
+
# 'info' function tests: 1
@skipIf(HAS_PWD is False, 'The pwd module is not available')
--
2.13.7
++++++ add-saltssh-multi-version-support-across-python-inte.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.248036939 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.252036946 +0200
@@ -1,4 +1,4 @@
-From 36bc22560e050b7afe3d872aed99c0cdb9fde282 Mon Sep 17 00:00:00 2001
+From 23aba97ccbdf9952f6a8107a8d90b40d0d2c41ee Mon Sep 17 00:00:00 2001
From: Bo Maryniuk
From 816c7ec3b72510346deef17deb2990a09ddab03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Thu, 31 May 2018 10:58:16 +0100 Subject: [PATCH] Align SUSE salt-master.service 'LimitNOFILES' limit with upstream Salt
---
pkg/suse/salt-master.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pkg/suse/salt-master.service b/pkg/suse/salt-master.service
index c0ea4606d8..b31c1a1373 100644
--- a/pkg/suse/salt-master.service
+++ b/pkg/suse/salt-master.service
@@ -4,7 +4,7 @@ Documentation=man:salt-master(1) file:///usr/share/doc/salt/html/contents.html h
After=network.target
[Service]
-LimitNOFILE=16384
+LimitNOFILE=100000
Type=simple
ExecStart=/usr/bin/salt-master
TasksMax=infinity
--
2.13.7
++++++ avoid-excessive-syslogging-by-watchdog-cronjob-58.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.268036972 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.268036972 +0200
@@ -1,4 +1,4 @@
-From edb1c95fa06b8bb1d7e6d91beaaddec6d22c966b Mon Sep 17 00:00:00 2001
+From 310f8eb22db6010ba48ab371a7223c1345cfbcf0 Mon Sep 17 00:00:00 2001
From: Hubert Mantel
From c4d9227b6da4407348e181f092445f17e3c14b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Thu, 26 Jul 2018 16:42:10 +0100 Subject: [PATCH] Avoid incomprehensive message if crashes
Check dmidecoder executable on each call to avoid crashing
Fix pylint issues
---
salt/modules/smbios.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/salt/modules/smbios.py b/salt/modules/smbios.py
index c8a0e54a5c..c0b94c2a65 100644
--- a/salt/modules/smbios.py
+++ b/salt/modules/smbios.py
@@ -19,6 +19,7 @@ import re
# Import salt libs
import salt.utils.path
+from salt.exceptions import CommandExecutionError
# Solve the Chicken and egg problem where grains need to run before any
# of the modules are loaded and are generally available for any usage.
@@ -32,10 +33,16 @@ log = logging.getLogger(__name__)
DMIDECODER = salt.utils.path.which_bin(['dmidecode', 'smbios'])
+def _refresh_dmidecoder():
+ global DMIDECODER
+ DMIDECODER = salt.utils.path.which_bin(['dmidecode', 'smbios'])
+
+
def __virtual__():
'''
Only work when dmidecode is installed.
'''
+ _refresh_dmidecoder()
if DMIDECODER is None:
log.debug('SMBIOS: neither dmidecode nor smbios found!')
return (False, 'The smbios execution module failed to load: neither dmidecode nor smbios in the path.')
@@ -327,6 +334,10 @@ def _dmidecoder(args=None):
'''
Call DMIdecode
'''
+ _refresh_dmidecoder()
+ if DMIDECODER is None:
+ raise CommandExecutionError('SMBIOS: neither dmidecode nor smbios found!')
+
if args is None:
return salt.modules.cmdmod._run_quiet(DMIDECODER)
else:
--
2.17.1
++++++ do-not-override-jid-on-returners-only-sending-back-t.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.284036999 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.284036999 +0200
@@ -1,4 +1,4 @@
-From c49a9aca3519d1baef2f9d82963a6e80eabb26d4 Mon Sep 17 00:00:00 2001
+From 911d61d1479d89ed31b23b038874505b731c6d86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
From 9289e1607ebf6f397c027d4a6edcf35c59bd600c Mon Sep 17 00:00:00 2001 From: Mihai Dinca
Date: Wed, 6 Jun 2018 15:47:45 +0200 Subject: [PATCH] Fix deprecation warning (bsc#1095507)
--- salt/utils/thin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/thin.py b/salt/utils/thin.py index e4b878eb19..b99e407583 100644 --- a/salt/utils/thin.py +++ b/salt/utils/thin.py @@ -546,7 +546,7 @@ def thin_sum(cachedir, form='sha1'): thintar = gen_thin(cachedir) code_checksum_path = os.path.join(cachedir, 'thin', 'code-checksum') if os.path.isfile(code_checksum_path): - with salt.utils.fopen(code_checksum_path, 'r') as fh: + with salt.utils.files.fopen(code_checksum_path, 'r') as fh: code_checksum = "'{0}'".format(fh.read().strip()) else: code_checksum = "'0'" -- 2.13.7 ++++++ fix-diffing-binary-files-in-file.get_diff-bsc-109839.patch ++++++
From 7bda1dcd4f14da55abe38b1739b1e46ad0f5213c Mon Sep 17 00:00:00 2001 From: Erik Johnson
Date: Fri, 13 Apr 2018 11:25:24 -0500 Subject: [PATCH] Fix diffing binary files in file.get_diff (bsc#1098394)
---
salt/modules/file.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/salt/modules/file.py b/salt/modules/file.py
index 1b4b7e0e46..95bca7fb1b 100644
--- a/salt/modules/file.py
+++ b/salt/modules/file.py
@@ -5008,8 +5008,7 @@ def get_diff(file1,
*salt.utils.data.decode(args)
)
)
- return ret
- return ''
+ return ret
def manage_file(name,
--
2.13.7
++++++ fix-for-ec2-rate-limit-failures.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.348037106 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.348037106 +0200
@@ -1,4 +1,4 @@
-From b0273e150b29fb44d72246918792117b485441de Mon Sep 17 00:00:00 2001
+From 88a99b5beeaa51eaf646eb92d8f546f65f654008 Mon Sep 17 00:00:00 2001
From: Daniel Wallace
From 854ffed98894b8aa8b51973c0ba13fb75093e715 Mon Sep 17 00:00:00 2001 From: Erik Johnson
Date: Mon, 30 Apr 2018 10:25:40 -0500 Subject: [PATCH] Fix UnboundLocalError in file.get_diff
This was only in 2018.3 head and not part of a release Add unit test for file.get_diff Use a lambda instead of defining a one-line function --- salt/modules/file.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 95bca7fb1b..1b4b7e0e46 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -5008,7 +5008,8 @@ def get_diff(file1, *salt.utils.data.decode(args) ) ) - return ret + return ret + return '' def manage_file(name, -- 2.13.7 ++++++ fix-zypper.list_pkgs-to-be-aligned-with-pkg-state.patch ++++++
From 997edb18b81d73933324b299da36474c24630b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Mon, 25 Jun 2018 13:06:40 +0100 Subject: [PATCH] Fix zypper.list_pkgs to be aligned with pkg state
Handle packages with multiple version properly with zypper
Add unit test coverage for multiple version packages on Zypper
Fix '_find_remove_targets' after aligning Zypper with pkg state
---
salt/modules/zypper.py | 57 +++++++++++++---------
salt/states/pkg.py | 21 --------
tests/unit/modules/test_zypper.py | 100 +++++++++++++++++++++++++-------------
3 files changed, 102 insertions(+), 76 deletions(-)
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
index 05ba3d86c9..4689f84926 100644
--- a/salt/modules/zypper.py
+++ b/salt/modules/zypper.py
@@ -38,6 +38,7 @@ import salt.utils.files
import salt.utils.functools
import salt.utils.path
import salt.utils.pkg
+import salt.utils.pkg.rpm
import salt.utils.stringutils
import salt.utils.systemd
from salt.utils.versions import LooseVersion
@@ -714,24 +715,44 @@ def list_pkgs(versions_as_list=False, **kwargs):
contextkey = 'pkg.list_pkgs'
if contextkey not in __context__:
-
- cmd = ['rpm', '-qa', '--queryformat', (
- "%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-"
- "%|EPOCH?{%{EPOCH}}:{}|_|-%{INSTALLTIME}\\n")]
ret = {}
- for line in __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False).splitlines():
- name, pkgver, rel, arch, epoch, install_time = line.split('_|-')
- install_date = datetime.datetime.utcfromtimestamp(int(install_time)).isoformat() + "Z"
- install_date_time_t = int(install_time)
-
- all_attr = {'epoch': epoch, 'version': pkgver, 'release': rel, 'arch': arch,
- 'install_date': install_date, 'install_date_time_t': install_date_time_t}
- __salt__['pkg_resource.add_pkg'](ret, name, all_attr)
+ cmd = ['rpm', '-qa', '--queryformat',
+ salt.utils.pkg.rpm.QUERYFORMAT.replace('%{REPOID}', '(none)') + '\n']
+ output = __salt__['cmd.run'](cmd,
+ python_shell=False,
+ output_loglevel='trace')
+ for line in output.splitlines():
+ pkginfo = salt.utils.pkg.rpm.parse_pkginfo(
+ line,
+ osarch=__grains__['osarch']
+ )
+ if pkginfo is not None:
+ # see rpm version string rules available at https://goo.gl/UGKPNd
+ pkgver = pkginfo.version
+ epoch = ''
+ release = ''
+ if ':' in pkgver:
+ epoch, pkgver = pkgver.split(":", 1)
+ if '-' in pkgver:
+ pkgver, release = pkgver.split("-", 1)
+ all_attr = {
+ 'epoch': epoch,
+ 'version': pkgver,
+ 'release': release,
+ 'arch': pkginfo.arch,
+ 'install_date': pkginfo.install_date,
+ 'install_date_time_t': pkginfo.install_date_time_t
+ }
+ __salt__['pkg_resource.add_pkg'](ret, pkginfo.name, all_attr)
+ _ret = {}
for pkgname in ret:
- ret[pkgname] = sorted(ret[pkgname], key=lambda d: d['version'])
+ # Filter out GPG public keys packages
+ if pkgname.startswith('gpg-pubkey'):
+ continue
+ _ret[pkgname] = sorted(ret[pkgname], key=lambda d: d['version'])
- __context__[contextkey] = ret
+ __context__[contextkey] = _ret
return __salt__['pkg_resource.format_pkg_list'](
__context__[contextkey],
@@ -1350,14 +1371,6 @@ def install(name=None,
_clean_cache()
new = list_pkgs(attr=diff_attr) if not downloadonly else list_downloaded()
-
- # Handle packages which report multiple new versions
- # (affects only kernel packages at this point)
- for pkg_name in new:
- pkg_data = new[pkg_name]
- if isinstance(pkg_data, six.string_types):
- new[pkg_name] = pkg_data.split(',')[-1]
-
ret = salt.utils.data.compare_dicts(old, new)
if errors:
diff --git a/salt/states/pkg.py b/salt/states/pkg.py
index ed405cb6b5..aad87e3278 100644
--- a/salt/states/pkg.py
+++ b/salt/states/pkg.py
@@ -415,16 +415,6 @@ def _find_remove_targets(name=None,
if __grains__['os'] == 'FreeBSD' and origin:
cver = [k for k, v in six.iteritems(cur_pkgs) if v['origin'] == pkgname]
- elif __grains__['os_family'] == 'Suse':
- # On SUSE systems. Zypper returns packages without "arch" in name
- try:
- namepart, archpart = pkgname.rsplit('.', 1)
- except ValueError:
- cver = cur_pkgs.get(pkgname, [])
- else:
- if archpart in salt.utils.pkg.rpm.ARCHES + ("noarch",):
- pkgname = namepart
- cver = cur_pkgs.get(pkgname, [])
else:
cver = cur_pkgs.get(pkgname, [])
@@ -854,17 +844,6 @@ def _verify_install(desired, new_pkgs, ignore_epoch=False, new_caps=None):
cver = new_pkgs.get(pkgname.split('%')[0])
elif __grains__['os_family'] == 'Debian':
cver = new_pkgs.get(pkgname.split('=')[0])
- elif __grains__['os_family'] == 'Suse':
- # On SUSE systems. Zypper returns packages without "arch" in name
- try:
- namepart, archpart = pkgname.rsplit('.', 1)
- except ValueError:
- cver = new_pkgs.get(pkgname)
- else:
- if archpart in salt.utils.pkg.rpm.ARCHES + ("noarch",):
- cver = new_pkgs.get(namepart)
- else:
- cver = new_pkgs.get(pkgname)
else:
cver = new_pkgs.get(pkgname)
if not cver and pkgname in new_caps:
diff --git a/tests/unit/modules/test_zypper.py b/tests/unit/modules/test_zypper.py
index 6eccee568b..bb15aca11a 100644
--- a/tests/unit/modules/test_zypper.py
+++ b/tests/unit/modules/test_zypper.py
@@ -475,7 +475,7 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
with patch('salt.modules.zypper.list_pkgs', MagicMock(side_effect=[
{"kernel-default": "3.12.49-11.1"}, {"kernel-default": "3.12.49-11.1,3.12.51-60.20.2"}])):
ret = zypper.install('kernel-default', '--auto-agree-with-licenses')
- self.assertDictEqual(ret, {"kernel-default": {"old": "3.12.49-11.1", "new": "3.12.51-60.20.2"}})
+ self.assertDictEqual(ret, {"kernel-default": {"old": "3.12.49-11.1", "new": "3.12.49-11.1,3.12.51-60.20.2"}})
def test_upgrade_failure(self):
'''
@@ -540,27 +540,36 @@ Repository 'DUMMY' not found by its alias, number, or URI.
data.setdefault(key, []).append(value)
rpm_out = [
- 'protobuf-java_|-2.6.1_|-3.1.develHead_|-noarch_|-_|-1499257756',
- 'yast2-ftp-server_|-3.1.8_|-8.1_|-x86_64_|-_|-1499257798',
- 'jose4j_|-0.4.4_|-2.1.develHead_|-noarch_|-_|-1499257756',
- 'apache-commons-cli_|-1.2_|-1.233_|-noarch_|-_|-1498636510',
- 'jakarta-commons-discovery_|-0.4_|-129.686_|-noarch_|-_|-1498636511',
- 'susemanager-build-keys-web_|-12.0_|-5.1.develHead_|-noarch_|-_|-1498636510',
+ 'protobuf-java_|-(none)_|-2.6.1_|-3.1.develHead_|-noarch_|-(none)_|-1499257756',
+ 'yast2-ftp-server_|-(none)_|-3.1.8_|-8.1_|-x86_64_|-(none)_|-1499257798',
+ 'jose4j_|-(none)_|-0.4.4_|-2.1.develHead_|-noarch_|-(none)_|-1499257756',
+ 'apache-commons-cli_|-(none)_|-1.2_|-1.233_|-noarch_|-(none)_|-1498636510',
+ 'jakarta-commons-discovery_|-(none)_|-0.4_|-129.686_|-noarch_|-(none)_|-1498636511',
+ 'susemanager-build-keys-web_|-(none)_|-12.0_|-5.1.develHead_|-noarch_|-(none)_|-1498636510',
+ 'gpg-pubkey_|-(none)_|-39db7c82_|-5847eb1f_|-(none)_|-(none)_|-1519203802',
+ 'gpg-pubkey_|-(none)_|-8a7c64f9_|-5aaa93ca_|-(none)_|-(none)_|-1529925595',
+ 'kernel-default_|-(none)_|-4.4.138_|-94.39.1_|-x86_64_|-(none)_|-1529936067',
+ 'kernel-default_|-(none)_|-4.4.73_|-5.1_|-x86_64_|-(none)_|-1503572639',
+ 'perseus-dummy_|-(none)_|-1.1_|-1.1_|-i586_|-(none)_|-1529936062',
]
- with patch.dict(zypper.__salt__, {'cmd.run': MagicMock(return_value=os.linesep.join(rpm_out))}), \
+ with patch.dict(zypper.__grains__, {'osarch': 'x86_64'}), \
+ patch.dict(zypper.__salt__, {'cmd.run': MagicMock(return_value=os.linesep.join(rpm_out))}), \
patch.dict(zypper.__salt__, {'pkg_resource.add_pkg': _add_data}), \
patch.dict(zypper.__salt__, {'pkg_resource.format_pkg_list': pkg_resource.format_pkg_list}), \
patch.dict(zypper.__salt__, {'pkg_resource.stringify': MagicMock()}):
pkgs = zypper.list_pkgs(versions_as_list=True)
+ self.assertFalse(pkgs.get('gpg-pubkey', False))
for pkg_name, pkg_version in {
- 'jakarta-commons-discovery': '0.4-129.686',
- 'yast2-ftp-server': '3.1.8-8.1',
- 'protobuf-java': '2.6.1-3.1.develHead',
- 'susemanager-build-keys-web': '12.0-5.1.develHead',
- 'apache-commons-cli': '1.2-1.233',
- 'jose4j': '0.4.4-2.1.develHead'}.items():
+ 'jakarta-commons-discovery': ['0.4-129.686'],
+ 'yast2-ftp-server': ['3.1.8-8.1'],
+ 'protobuf-java': ['2.6.1-3.1.develHead'],
+ 'susemanager-build-keys-web': ['12.0-5.1.develHead'],
+ 'apache-commons-cli': ['1.2-1.233'],
+ 'kernel-default': ['4.4.138-94.39.1', '4.4.73-5.1'],
+ 'perseus-dummy.i586': ['1.1-1.1'],
+ 'jose4j': ['0.4.4-2.1.develHead']}.items():
self.assertTrue(pkgs.get(pkg_name))
- self.assertEqual(pkgs[pkg_name], [pkg_version])
+ self.assertEqual(pkgs[pkg_name], pkg_version)
def test_list_pkgs_with_attr(self):
'''
@@ -572,57 +581,82 @@ Repository 'DUMMY' not found by its alias, number, or URI.
data.setdefault(key, []).append(value)
rpm_out = [
- 'protobuf-java_|-2.6.1_|-3.1.develHead_|-noarch_|-_|-1499257756',
- 'yast2-ftp-server_|-3.1.8_|-8.1_|-x86_64_|-_|-1499257798',
- 'jose4j_|-0.4.4_|-2.1.develHead_|-noarch_|-_|-1499257756',
- 'apache-commons-cli_|-1.2_|-1.233_|-noarch_|-_|-1498636510',
- 'jakarta-commons-discovery_|-0.4_|-129.686_|-noarch_|-_|-1498636511',
- 'susemanager-build-keys-web_|-12.0_|-5.1.develHead_|-noarch_|-_|-1498636510',
+ 'protobuf-java_|-(none)_|-2.6.1_|-3.1.develHead_|-noarch_|-(none)_|-1499257756',
+ 'yast2-ftp-server_|-(none)_|-3.1.8_|-8.1_|-x86_64_|-(none)_|-1499257798',
+ 'jose4j_|-(none)_|-0.4.4_|-2.1.develHead_|-noarch_|-(none)_|-1499257756',
+ 'apache-commons-cli_|-(none)_|-1.2_|-1.233_|-noarch_|-(none)_|-1498636510',
+ 'jakarta-commons-discovery_|-(none)_|-0.4_|-129.686_|-noarch_|-(none)_|-1498636511',
+ 'susemanager-build-keys-web_|-(none)_|-12.0_|-5.1.develHead_|-noarch_|-(none)_|-1498636510',
+ 'gpg-pubkey_|-(none)_|-39db7c82_|-5847eb1f_|-(none)_|-(none)_|-1519203802',
+ 'gpg-pubkey_|-(none)_|-8a7c64f9_|-5aaa93ca_|-(none)_|-(none)_|-1529925595',
+ 'kernel-default_|-(none)_|-4.4.138_|-94.39.1_|-x86_64_|-(none)_|-1529936067',
+ 'kernel-default_|-(none)_|-4.4.73_|-5.1_|-x86_64_|-(none)_|-1503572639',
+ 'perseus-dummy_|-(none)_|-1.1_|-1.1_|-i586_|-(none)_|-1529936062',
]
with patch.dict(zypper.__salt__, {'cmd.run': MagicMock(return_value=os.linesep.join(rpm_out))}), \
+ patch.dict(zypper.__grains__, {'osarch': 'x86_64'}), \
patch.dict(zypper.__salt__, {'pkg_resource.add_pkg': _add_data}), \
patch.dict(zypper.__salt__, {'pkg_resource.format_pkg_list': pkg_resource.format_pkg_list}), \
patch.dict(zypper.__salt__, {'pkg_resource.stringify': MagicMock()}):
pkgs = zypper.list_pkgs(attr=['epoch', 'release', 'arch', 'install_date_time_t'])
+ self.assertFalse(pkgs.get('gpg-pubkey', False))
for pkg_name, pkg_attr in {
- 'jakarta-commons-discovery': {
+ 'jakarta-commons-discovery': [{
'version': '0.4',
'release': '129.686',
'arch': 'noarch',
'install_date_time_t': 1498636511,
- },
- 'yast2-ftp-server': {
+ }],
+ 'yast2-ftp-server': [{
'version': '3.1.8',
'release': '8.1',
'arch': 'x86_64',
'install_date_time_t': 1499257798,
- },
- 'protobuf-java': {
+ }],
+ 'protobuf-java': [{
'version': '2.6.1',
'release': '3.1.develHead',
'install_date_time_t': 1499257756,
'arch': 'noarch',
- },
- 'susemanager-build-keys-web': {
+ }],
+ 'susemanager-build-keys-web': [{
'version': '12.0',
'release': '5.1.develHead',
'arch': 'noarch',
'install_date_time_t': 1498636510,
- },
- 'apache-commons-cli': {
+ }],
+ 'apache-commons-cli': [{
'version': '1.2',
'release': '1.233',
'arch': 'noarch',
'install_date_time_t': 1498636510,
+ }],
+ 'kernel-default': [{
+ 'version': '4.4.138',
+ 'release': '94.39.1',
+ 'arch': 'x86_64',
+ 'install_date_time_t': 1529936067
},
- 'jose4j': {
+ {
+ 'version': '4.4.73',
+ 'release': '5.1',
+ 'arch': 'x86_64',
+ 'install_date_time_t': 1503572639,
+ }],
+ 'perseus-dummy.i586': [{
+ 'version': '1.1',
+ 'release': '1.1',
+ 'arch': 'i586',
+ 'install_date_time_t': 1529936062,
+ }],
+ 'jose4j': [{
'arch': 'noarch',
'version': '0.4.4',
'release': '2.1.develHead',
'install_date_time_t': 1499257756,
- }}.items():
+ }]}.items():
self.assertTrue(pkgs.get(pkg_name))
- self.assertEqual(pkgs[pkg_name], [pkg_attr])
+ self.assertEqual(pkgs[pkg_name], pkg_attr)
def test_list_patches(self):
'''
--
2.13.7
++++++ fixed-usage-of-ipaddress.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.380037160 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.380037160 +0200
@@ -1,4 +1,4 @@
-From 205e031f6e5552ac860120f7ac852e24c5da73e5 Mon Sep 17 00:00:00 2001
+From 8ae052fbb07d7506492b430579308e4611e51754 Mon Sep 17 00:00:00 2001
From: Jochen Breuer
From d282de5c59e27c17bd5afb207c4eeaa754993368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Tue, 22 May 2018 12:04:48 +0100 Subject: [PATCH] Prevent zypper from parsing repo configuration from not .repo files
--- salt/modules/zypper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 06f8335c18..05ba3d86c9 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -862,7 +862,7 @@ def _get_configured_repos(): ''' repos_cfg = configparser.ConfigParser() - repos_cfg.read([REPOS + '/' + fname for fname in os.listdir(REPOS)]) + repos_cfg.read([REPOS + '/' + fname for fname in os.listdir(REPOS) if fname.endswith(".repo")]) return repos_cfg -- 2.13.7 ++++++ remove-old-hack-when-reporting-multiversion-packages.patch ++++++
From 11186ce52ae42967c49a6e238659a566e488a6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
Date: Mon, 23 Jul 2018 16:32:26 +0100 Subject: [PATCH] Remove old hack when reporting multiversion packages
Fix unit tests for zypper pkg.upgrade
---
salt/modules/zypper.py | 5 -----
tests/unit/modules/test_zypper.py | 8 +++++++-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py
index 4689f84926..695bce4f4e 100644
--- a/salt/modules/zypper.py
+++ b/salt/modules/zypper.py
@@ -1480,11 +1480,6 @@ def upgrade(refresh=True,
__zypper__(systemd_scope=_systemd_scope()).noraise.call(*cmd_update)
_clean_cache()
new = list_pkgs()
-
- # Handle packages which report multiple new versions
- # (affects only kernel packages at this point)
- for pkg in new:
- new[pkg] = new[pkg].split(',')[-1]
ret = salt.utils.data.compare_dicts(old, new)
if __zypper__.exit_code not in __zypper__.SUCCESS_EXIT_CODES:
diff --git a/tests/unit/modules/test_zypper.py b/tests/unit/modules/test_zypper.py
index bb15aca11a..424438c8bf 100644
--- a/tests/unit/modules/test_zypper.py
+++ b/tests/unit/modules/test_zypper.py
@@ -429,7 +429,13 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
zypper_mock.assert_any_call('update', '--auto-agree-with-licenses')
with patch('salt.modules.zypper.list_pkgs',
- MagicMock(side_effect=[{"vim": "1.1"}, {"vim": "1.1,1.2"}])):
+ MagicMock(side_effect=[{"kernel-default": "1.1"}, {"kernel-default": "1.1,1.2"}])):
+ ret = zypper.upgrade()
+ self.assertDictEqual(ret, {"kernel-default": {"old": "1.1", "new": "1.1,1.2"}})
+ zypper_mock.assert_any_call('update', '--auto-agree-with-licenses')
+
+ with patch('salt.modules.zypper.list_pkgs',
+ MagicMock(side_effect=[{"vim": "1.1"}, {"vim": "1.2"}])):
ret = zypper.upgrade()
self.assertDictEqual(ret, {"vim": {"old": "1.1", "new": "1.2"}})
zypper_mock.assert_any_call('update', '--auto-agree-with-licenses')
--
2.17.1
++++++ run-salt-api-as-user-salt-bsc-1064520.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.460037294 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.460037294 +0200
@@ -1,4 +1,4 @@
-From 92f41027bc08be3e14a47bbf7f43205a60606643 Mon Sep 17 00:00:00 2001
+From e9b5c0ae02552eb9a76488da32217a0e339d86a2 Mon Sep 17 00:00:00 2001
From: Christian Lanig
From 15e97fd2916176fe850850fe90983ac95a1f8e7b Mon Sep 17 00:00:00 2001 From: Erik Johnson
Date: Mon, 11 Jun 2018 14:46:58 -0500 Subject: [PATCH] Show recommendations for salt-ssh cross-version python errors
This shows more accurate information on how to resolve version issues
(e.g. master only has Salt deps installed for Python 3 but remote host
has no Python 3 installed).
Use parenthesis for line continuation
---
salt/client/ssh/__init__.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py
index f1300b5698..8a85cc2480 100644
--- a/salt/client/ssh/__init__.py
+++ b/salt/client/ssh/__init__.py
@@ -1387,6 +1387,30 @@ ARGS = {arguments}\n'''.format(config=self.minion_config,
perm_error_fmt = 'Permissions problem, target user may need '\
'to be root or use sudo:\n {0}'
+ def _version_mismatch_error():
+ messages = {
+ 2: {
+ 6: 'Install Python 2.7 / Python 3 Salt dependencies on the Salt SSH master \n'
+ 'to interact with Python 2.7 / Python 3 targets',
+ 7: 'Install Python 2.6 / Python 3 Salt dependencies on the Salt SSH master \n'
+ 'to interact with Python 2.6 / Python 3 targets',
+ },
+ 3: {
+ 'default': '- Install Python 2.6/2.7 Salt dependencies on the Salt SSH \n'
+ ' master to interact with Python 2.6/2.7 targets\n'
+ '- Install Python 3 on the target machine(s)',
+ },
+ 'default': 'Matching major/minor Python release (>=2.6) needed both on the Salt SSH \n'
+ 'master and target machine',
+ }
+ major, minor = sys.version_info[:2]
+ help_msg = (
+ messages.get(major, {}).get(minor)
+ or messages.get(major, {}).get('default')
+ or messages['default']
+ )
+ return 'Python version error. Recommendation(s) follow:\n' + help_msg
+
errors = [
(
(),
@@ -1396,7 +1420,7 @@ ARGS = {arguments}\n'''.format(config=self.minion_config,
(
(salt.defaults.exitcodes.EX_THIN_PYTHON_INVALID,),
'Python interpreter is too old',
- 'salt requires python 2.6 or newer on target hosts, must have same major version as origin host'
+ _version_mismatch_error()
),
(
(salt.defaults.exitcodes.EX_THIN_CHECKSUM,),
--
2.13.7
++++++ strip-trailing-commas-on-linux-user-gecos-fields.patch ++++++
--- /var/tmp/diff_new_pack.Vk4x2R/_old 2018-08-02 14:55:45.516037388 +0200
+++ /var/tmp/diff_new_pack.Vk4x2R/_new 2018-08-02 14:55:45.516037388 +0200
@@ -1,4 +1,4 @@
-From f9fb3639bb3c44babd92d9499bdde83a0a81d6ab Mon Sep 17 00:00:00 2001
+From f515f99ee42ffaba30cee2e1941a7e9af9db7453 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=