Hello community, here is the log from the commit of package salt for openSUSE:Factory checked in at 2016-05-13 09:24:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt (Old) and /work/SRC/openSUSE:Factory/.salt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "salt" Changes: -------- --- /work/SRC/openSUSE:Factory/salt/salt.changes 2016-04-28 17:02:56.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.salt.new/salt.changes 2016-05-13 09:24:15.000000000 +0200 @@ -1,0 +2,30 @@ +Wed May 11 07:20:40 UTC 2016 - bmaryn...@suse.com + +- Fix shared directories ownership issues. + +------------------------------------------------------------------- +Mon May 9 12:06:32 UTC 2016 - bmaryn...@suse.com + +- Add Zypper plugin to generate an event, + once Zypper is used outside the Salt infrastructure + demand (bsc#971372). + Add: + * 0017-Add-SUSE-Manager-plugin.patch + +------------------------------------------------------------------- +Fri May 6 13:37:12 UTC 2016 - bmaryn...@suse.com + +- Restore boolean values from the repo configuration + Fix priority attribute (bsc#978833) + Add: + * 0016-Bugfix-Restore-boolean-values-from-the-repo-configur.patch + +------------------------------------------------------------------- +Wed May 4 13:17:29 UTC 2016 - bmaryn...@suse.com + +- Unblock-Zypper. (bsc#976148) + Modify-environment. (bsc#971372) + Add: + * 0015-Unblock-Zypper.-Modify-environment.patch + +------------------------------------------------------------------- New: ---- 0015-Unblock-Zypper.-Modify-environment.patch 0016-Bugfix-Restore-boolean-values-from-the-repo-configur.patch 0017-Add-SUSE-Manager-plugin.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt.spec ++++++ --- /var/tmp/diff_new_pack.O7MCcO/_old 2016-05-13 09:24:17.000000000 +0200 +++ /var/tmp/diff_new_pack.O7MCcO/_new 2016-05-13 09:24:17.000000000 +0200 @@ -75,6 +75,13 @@ Patch13: 0013-Prevent-crash-if-pygit2-package-is-requesting-re-com.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/32649 Patch14: 0014-align-OS-grains-from-older-SLES-with-current-one-326.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/32892 +Patch15: 0015-Unblock-Zypper.-Modify-environment.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/33088 +Patch16: 0016-Bugfix-Restore-boolean-values-from-the-repo-configur.patch +# PATCH-FIX-OPENSUSE Generate events from the Salt minion, +# if Zypper has been used outside the Salt infrastructure +Patch17: 0017-Add-SUSE-Manager-plugin.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: logrotate @@ -142,6 +149,8 @@ %if 0%{?suse_version} # required for zypper.py Requires: rpm-python +Requires(pre): libzypp(plugin:system) >= 0 +Requires: zypp-plugin-python # requirements/opt.txt (not all) Recommends: python-MySQL-python Recommends: python-timelib @@ -431,6 +440,13 @@ %patch12 -p1 %patch13 -p1 %patch14 -p1 +%patch15 -p1 +%patch16 -p1 + +# This is SUSE-only patch +%if 0%{?suse_version} +%patch17 -p1 +%endif %build python setup.py --salt-transport=both build @@ -479,6 +495,12 @@ install -Dd -m 0750 %{buildroot}%{_sysconfdir}/salt/pki/master/minions_rejected install -Dd -m 0750 %{buildroot}%{_sysconfdir}/salt/pki/minion +## Install Zypper plugins only on SUSE machines +%if 0%{?suse_version} +install -Dd -m 0750 %{buildroot}%{_prefix}/lib/zypp/plugins/commit +%{__install} scripts/zypper/plugins/commit/susemanager %{buildroot}%{_prefix}/lib/zypp/plugins/commit/susemanager +%endif + ## install init and systemd scripts %if %{with systemd} install -Dpm 0644 pkg/salt-master.service %{buildroot}%{_unitdir}/salt-master.service @@ -758,6 +780,12 @@ %dir %attr(0750, root, root) %{_sysconfdir}/salt/pki/minion/ %dir %attr(0750, root, root) %{_localstatedir}/cache/salt/minion/ %{_sbindir}/rcsalt-minion + +# Install plugin only on SUSE machines +%if 0%{?suse_version} +%{_prefix}/lib/zypp/plugins/commit/susemanager +%endif + %if %{with systemd} %{_unitdir}/salt-minion.service %else ++++++ 0015-Unblock-Zypper.-Modify-environment.patch ++++++ ++++ 904 lines (skipped) ++++++ 0016-Bugfix-Restore-boolean-values-from-the-repo-configur.patch ++++++ >From e52b55979bdc0734c2e452dd2fd67fb56a3fb37b Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <b...@suse.de> Date: Fri, 6 May 2016 12:29:48 +0200 Subject: [PATCH 16/16] Bugfix: Restore boolean values from the repo configuration * Add test data for repos * Add repo config test * Bugfix (follow-up): setting priority requires non-positive integer --- salt/modules/zypper.py | 16 +++++++++------- tests/unit/modules/zypp/zypper-repo-1.cfg | 5 +++++ tests/unit/modules/zypp/zypper-repo-2.cfg | 5 +++++ tests/unit/modules/zypper_test.py | 21 +++++++++++++++++++++ 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 tests/unit/modules/zypp/zypper-repo-1.cfg create mode 100644 tests/unit/modules/zypp/zypper-repo-2.cfg diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 53b5d9f..c37b382 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -602,12 +602,14 @@ def _get_repo_info(alias, repos_cfg=None): Get one repo meta-data. ''' try: - ret = dict((repos_cfg or _get_configured_repos()).items(alias)) - ret['alias'] = alias - for key, val in six.iteritems(ret): - if val == 'NONE': - ret[key] = None - return ret + meta = dict((repos_cfg or _get_configured_repos()).items(alias)) + meta['alias'] = alias + for key, val in six.iteritems(meta): + if val in ['0', '1']: + meta[key] = int(meta[key]) == 1 + elif val == 'NONE': + meta[key] = None + return meta except (ValueError, configparser.NoSectionError): return {} @@ -769,7 +771,7 @@ def mod_repo(repo, **kwargs): cmd_opt.append('--gpg-auto-import-keys') if 'priority' in kwargs: - cmd_opt.append("--priority='{0}'".format(kwargs.get('priority', DEFAULT_PRIORITY))) + cmd_opt.append("--priority={0}".format(kwargs.get('priority', DEFAULT_PRIORITY))) if 'humanname' in kwargs: cmd_opt.append("--name='{0}'".format(kwargs.get('humanname'))) diff --git a/tests/unit/modules/zypp/zypper-repo-1.cfg b/tests/unit/modules/zypp/zypper-repo-1.cfg new file mode 100644 index 0000000..958718c --- /dev/null +++ b/tests/unit/modules/zypp/zypper-repo-1.cfg @@ -0,0 +1,5 @@ +[SLE12-SP1-x86_64-Update] +enabled=1 +autorefresh=1 +baseurl=http://somehost.com/SUSE/Updates/SLE-SERVER/12-SP1/x86_64/update/ +type=NONE diff --git a/tests/unit/modules/zypp/zypper-repo-2.cfg b/tests/unit/modules/zypp/zypper-repo-2.cfg new file mode 100644 index 0000000..f55cf18 --- /dev/null +++ b/tests/unit/modules/zypp/zypper-repo-2.cfg @@ -0,0 +1,5 @@ +[SLE12-SP1-x86_64-Update-disabled] +enabled=0 +autorefresh=0 +baseurl=http://somehost.com/SUSE/Updates/SLE-SERVER/12-SP1/x86_64/update/ +type=NONE diff --git a/tests/unit/modules/zypper_test.py b/tests/unit/modules/zypper_test.py index 16e8542..4e735cd 100644 --- a/tests/unit/modules/zypper_test.py +++ b/tests/unit/modules/zypper_test.py @@ -17,6 +17,8 @@ from salttesting.mock import ( from salt.exceptions import CommandExecutionError import os +from salt.ext.six.moves import configparser +import StringIO from salttesting.helpers import ensure_in_syspath @@ -391,6 +393,25 @@ class ZypperTestCase(TestCase): self.assertTrue(diff[pkg_name]['old']) self.assertFalse(diff[pkg_name]['new']) + def test_repo_value_info(self): + ''' + Tests if repo info is properly parsed. + + :return: + ''' + repos_cfg = configparser.ConfigParser() + for cfg in ['zypper-repo-1.cfg', 'zypper-repo-2.cfg']: + repos_cfg.readfp(StringIO.StringIO(get_test_data(cfg))) + + for alias in repos_cfg.sections(): + r_info = zypper._get_repo_info(alias, repos_cfg=repos_cfg) + self.assertEqual(type(r_info['type']), type(None)) + self.assertEqual(type(r_info['enabled']), bool) + self.assertEqual(type(r_info['autorefresh']), bool) + self.assertEqual(type(r_info['baseurl']), str) + self.assertEqual(r_info['type'], None) + self.assertEqual(r_info['enabled'], alias == 'SLE12-SP1-x86_64-Update') + self.assertEqual(r_info['autorefresh'], alias == 'SLE12-SP1-x86_64-Update') if __name__ == '__main__': from integration import run_tests -- 2.8.1 ++++++ 0017-Add-SUSE-Manager-plugin.patch ++++++ >From 92f17a79c53bb5b75b9dac4aa0add94dfe2f447f Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <b...@suse.de> Date: Mon, 9 May 2016 10:33:44 +0200 Subject: [PATCH 17/17] Add SUSE Manager plugin --- scripts/zypper/plugins/commit/README.md | 3 ++ scripts/zypper/plugins/commit/susemanager | 73 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 scripts/zypper/plugins/commit/README.md create mode 100755 scripts/zypper/plugins/commit/susemanager diff --git a/scripts/zypper/plugins/commit/README.md b/scripts/zypper/plugins/commit/README.md new file mode 100644 index 0000000..01c8917 --- /dev/null +++ b/scripts/zypper/plugins/commit/README.md @@ -0,0 +1,3 @@ +# Zypper plugins + +Plugins here are required to interact with SUSE Manager in conjunction of SaltStack and Zypper. diff --git a/scripts/zypper/plugins/commit/susemanager b/scripts/zypper/plugins/commit/susemanager new file mode 100755 index 0000000..e64d683 --- /dev/null +++ b/scripts/zypper/plugins/commit/susemanager @@ -0,0 +1,73 @@ +#!/usr/bin/python +# +# Copyright (c) 2016 SUSE Linux LLC +# All Rights Reserved. +# +# This software is licensed to you under the GNU General Public License, +# version 2 (GPLv2). There is NO WARRANTY for this software, express or +# implied, including the implied warranties of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 +# along with this software; if not, see +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. +# +# Author: Bo Maryniuk <b...@suse.de> + +import sys +import os + +import salt.client +import salt.utils + +from zypp_plugin import Plugin + + +class SpacewalkDriftDetector(Plugin): + """ + Return diff of the installed packages outside the Salt. + """ + def __init__(self): + Plugin.__init__(self) + self.salt = salt.client.Caller().sminion.functions + + def _within_salt(self): + """ + Return true, if Zypper is running from within the SaltStack. + """ + return 'SALT_RUNNING' in os.environ + + def _get_packages(self): + """ + Get the list of the packages at the current time. + """ + ret = dict() + cmd = "rpm -qa --queryformat '%{NAME}_|-%{VERSION}_|-%{RELEASE}_|-%|EPOCH?{%{EPOCH}}:{}|\\n'" + for line in os.popen(cmd).read().split("\n"): + if not line: + continue + name, pkgver, rel, epoch = line.split('_|-') + if epoch: + pkgver = '{0}:{1}'.format(epoch, pkgver) + if rel: + pkgver += '-{0}'.format(rel) + ret[name] = pkgver + + return ret + + def PLUGINBEGIN(self, headers, body): + """ + Hook when plugin begins Zypper's transaction. + """ + if not self._within_salt(): + self._pkg_before = self._get_packages() + self.ack() + + def PLUGINEND(self, headers, body): + """ + Hook when plugin closes Zypper's transaction. + """ + if not self._within_salt(): + self.salt['event.send']('zypper/changed', salt.utils.compare_dicts(self._pkg_before, self._get_packages())) + self.ack() + + +SpacewalkDriftDetector().main() -- 2.8.2