diff --git a/_lastrevision b/_lastrevision index 92e8a2a..909f8b6 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -5c46ca0c3961fc3954afcf884bf2ac754507c151 \ No newline at end of file +b6cbd715dc69b13db8d3fec05840366a1202a62a \ No newline at end of file diff --git a/accumulated-changes-from-yomi-167.patch b/accumulated-changes-from-yomi-167.patch new file mode 100644 index 0000000..f33669b --- /dev/null +++ b/accumulated-changes-from-yomi-167.patch @@ -0,0 +1,186 @@ +From 46a60d81604eaf6f9fc3712e02d1066e959c96e3 Mon Sep 17 00:00:00 2001 +From: Alberto Planas +Date: Tue, 22 Oct 2019 11:02:33 +0200 +Subject: [PATCH] Accumulated changes from Yomi (#167) + +* core.py: ignore wrong product_name files + +Some firmwares (like some NUC machines), do not provide valid +/sys/class/dmi/id/product_name strings. In those cases an +UnicodeDecodeError exception happens. + +This patch ignore this kind of issue during the grains creation. + +(cherry picked from commit 2d57d2a6063488ad9329a083219e3826e945aa2d) + +* zypperpkg: understand product type + +(cherry picked from commit b865491b74679140f7a71c5ba50d482db47b600f) +--- + salt/grains/core.py | 4 +++ + salt/modules/zypperpkg.py | 30 +++++++++++++------ + tests/unit/grains/test_core.py | 45 ++++++++++++++++++++++++++++ + tests/unit/modules/test_zypperpkg.py | 26 ++++++++++++++++ + 4 files changed, 96 insertions(+), 9 deletions(-) + +diff --git a/salt/grains/core.py b/salt/grains/core.py +index fa188a6ff7..fdabe484a8 100644 +--- a/salt/grains/core.py ++++ b/salt/grains/core.py +@@ -986,6 +986,10 @@ def _virtual(osdata): + grains['virtual'] = 'gce' + elif 'BHYVE' in output: + grains['virtual'] = 'bhyve' ++ except UnicodeDecodeError: ++ # Some firmwares provide non-valid 'product_name' ++ # files, ignore them ++ pass + except IOError: + pass + elif osdata['kernel'] == 'FreeBSD': +diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py +index da1953b2a5..a87041aa70 100644 +--- a/salt/modules/zypperpkg.py ++++ b/salt/modules/zypperpkg.py +@@ -861,23 +861,35 @@ def list_pkgs(versions_as_list=False, root=None, includes=None, **kwargs): + _ret[pkgname] = sorted(ret[pkgname], key=lambda d: d['version']) + + for include in includes: ++ if include == 'product': ++ products = list_products(all=False, root=root) ++ for product in products: ++ extended_name = '{}:{}'.format(include, product['name']) ++ _ret[extended_name] = [{ ++ 'epoch': product['epoch'], ++ 'version': product['version'], ++ 'release': product['release'], ++ 'arch': product['arch'], ++ 'install_date': None, ++ 'install_date_time_t': None, ++ }] + if include in ('pattern', 'patch'): + if include == 'pattern': +- pkgs = list_installed_patterns(root=root) ++ elements = list_installed_patterns(root=root) + elif include == 'patch': +- pkgs = list_installed_patches(root=root) ++ elements = list_installed_patches(root=root) + else: +- pkgs = [] +- for pkg in pkgs: +- pkg_extended_name = '{}:{}'.format(include, pkg) +- info = info_available(pkg_extended_name, ++ elements = [] ++ for element in elements: ++ extended_name = '{}:{}'.format(include, element) ++ info = info_available(extended_name, + refresh=False, + root=root) +- _ret[pkg_extended_name] = [{ ++ _ret[extended_name] = [{ + 'epoch': None, +- 'version': info[pkg]['version'], ++ 'version': info[element]['version'], + 'release': None, +- 'arch': info[pkg]['arch'], ++ 'arch': info[element]['arch'], + 'install_date': None, + 'install_date_time_t': None, + }] +diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py +index 889fb90074..aa04a7a7ac 100644 +--- a/tests/unit/grains/test_core.py ++++ b/tests/unit/grains/test_core.py +@@ -1117,6 +1117,51 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin): + 'uuid': '' + }) + ++ @skipIf(not salt.utils.platform.is_linux(), 'System is not Linux') ++ def test_kernelparams_return(self): ++ expectations = [ ++ ('BOOT_IMAGE=/vmlinuz-3.10.0-693.2.2.el7.x86_64', ++ {'kernelparams': [('BOOT_IMAGE', '/vmlinuz-3.10.0-693.2.2.el7.x86_64')]}), ++ ('root=/dev/mapper/centos_daemon-root', ++ {'kernelparams': [('root', '/dev/mapper/centos_daemon-root')]}), ++ ('rhgb quiet ro', ++ {'kernelparams': [('rhgb', None), ('quiet', None), ('ro', None)]}), ++ ('param="value1"', ++ {'kernelparams': [('param', 'value1')]}), ++ ('param="value1 value2 value3"', ++ {'kernelparams': [('param', 'value1 value2 value3')]}), ++ ('param="value1 value2 value3" LANG="pl" ro', ++ {'kernelparams': [('param', 'value1 value2 value3'), ('LANG', 'pl'), ('ro', None)]}), ++ ('ipv6.disable=1', ++ {'kernelparams': [('ipv6.disable', '1')]}), ++ ('param="value1:value2:value3"', ++ {'kernelparams': [('param', 'value1:value2:value3')]}), ++ ('param="value1,value2,value3"', ++ {'kernelparams': [('param', 'value1,value2,value3')]}), ++ ('param="value1" param="value2" param="value3"', ++ {'kernelparams': [('param', 'value1'), ('param', 'value2'), ('param', 'value3')]}), ++ ] ++ ++ for cmdline, expectation in expectations: ++ with patch('salt.utils.files.fopen', mock_open(read_data=cmdline)): ++ self.assertEqual(core.kernelparams(), expectation) ++ ++ @skipIf(not salt.utils.platform.is_linux(), 'System is not Linux') ++ @patch('os.path.exists') ++ @patch('salt.utils.platform.is_proxy') ++ def test__hw_data_linux_empty(self, is_proxy, exists): ++ is_proxy.return_value = False ++ exists.return_value = True ++ with patch('salt.utils.files.fopen', mock_open(read_data='')): ++ self.assertEqual(core._hw_data({'kernel': 'Linux'}), { ++ 'biosreleasedate': '', ++ 'biosversion': '', ++ 'manufacturer': '', ++ 'productname': '', ++ 'serialnumber': '', ++ 'uuid': '' ++ }) ++ + @skipIf(not salt.utils.platform.is_linux(), 'System is not Linux') + @skipIf(six.PY2, 'UnicodeDecodeError is throw in Python 3') + @patch('os.path.exists') +diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py +index 695d982ca6..7617113401 100644 +--- a/tests/unit/modules/test_zypperpkg.py ++++ b/tests/unit/modules/test_zypperpkg.py +@@ -943,6 +943,32 @@ Repository 'DUMMY' not found by its alias, number, or URI. + with self.assertRaisesRegex(CommandExecutionError, '^Advisory id "SUSE-PATCH-XXX" not found$'): + zypper.install(advisory_ids=['SUSE-PATCH-XXX']) + ++ @patch('salt.modules.zypperpkg._systemd_scope', ++ MagicMock(return_value=False)) ++ @patch('salt.modules.zypperpkg.list_products', ++ MagicMock(return_value={'openSUSE': {'installed': False, 'summary': 'test'}})) ++ @patch('salt.modules.zypperpkg.list_pkgs', MagicMock(side_effect=[{"product:openSUSE": "15.2"}, ++ {"product:openSUSE": "15.3"}])) ++ def test_install_product_ok(self): ++ ''' ++ Test successfully product installation. ++ ''' ++ with patch.dict(zypper.__salt__, ++ { ++ 'pkg_resource.parse_targets': MagicMock( ++ return_value=(['product:openSUSE'], None)) ++ }): ++ with patch('salt.modules.zypperpkg.__zypper__.noraise.call', MagicMock()) as zypper_mock: ++ ret = zypper.install('product:openSUSE', includes=['product']) ++ zypper_mock.assert_called_once_with( ++ '--no-refresh', ++ 'install', ++ '--auto-agree-with-licenses', ++ '--name', ++ 'product:openSUSE' ++ ) ++ self.assertDictEqual(ret, {"product:openSUSE": {"old": "15.2", "new": "15.3"}}) ++ + def test_remove_purge(self): + ''' + Test package removal +-- +2.23.0 + + diff --git a/adds-the-possibility-to-also-use-downloadonly-in-kwa.patch b/adds-the-possibility-to-also-use-downloadonly-in-kwa.patch new file mode 100644 index 0000000..32b38b7 --- /dev/null +++ b/adds-the-possibility-to-also-use-downloadonly-in-kwa.patch @@ -0,0 +1,88 @@ +From f9e7ace2f7c56a7fb4df60a048131dbd6887340b Mon Sep 17 00:00:00 2001 +From: Jochen Breuer +Date: Fri, 27 Sep 2019 11:33:47 +0200 +Subject: [PATCH] Adds the possibility to also use downloadonly in kwargs + +The download_only parameter in the apt module is not in line with +the yum and zypper modules. Both of them use downloadonly without +the underline. + +With this change apt now additionally supports the downloadonly +parameter. + +Fixes #54790 +--- + salt/modules/aptpkg.py | 7 ++++--- + tests/unit/modules/test_aptpkg.py | 30 ++++++++++++++++++++++++++++++ + 2 files changed, 34 insertions(+), 3 deletions(-) + +diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py +index a11bb51c16..1a60255a1d 100644 +--- a/salt/modules/aptpkg.py ++++ b/salt/modules/aptpkg.py +@@ -1054,8 +1054,9 @@ def upgrade(refresh=True, dist_upgrade=False, **kwargs): + Skip refreshing the package database if refresh has already occurred within + seconds + +- download_only +- Only download the packages, don't unpack or install them ++ download_only (or downloadonly) ++ Only download the packages, don't unpack or install them. Use ++ downloadonly to be in line with yum and zypper module. + + .. versionadded:: 2018.3.0 + +@@ -1086,7 +1087,7 @@ def upgrade(refresh=True, dist_upgrade=False, **kwargs): + cmd.append('--force-yes') + if kwargs.get('skip_verify', False): + cmd.append('--allow-unauthenticated') +- if kwargs.get('download_only', False): ++ if kwargs.get('download_only', False) or kwargs.get('downloadonly', False): + cmd.append('--download-only') + + cmd.append('dist-upgrade' if dist_upgrade else 'upgrade') +diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py +index 85360da181..d3fac5902a 100644 +--- a/tests/unit/modules/test_aptpkg.py ++++ b/tests/unit/modules/test_aptpkg.py +@@ -393,6 +393,36 @@ class AptPkgTestCase(TestCase, LoaderModuleMockMixin): + with patch.multiple(aptpkg, **patch_kwargs): + self.assertEqual(aptpkg.upgrade(), dict()) + ++ def test_upgrade_downloadonly(self): ++ ''' ++ Tests the download-only options for upgrade. ++ ''' ++ with patch('salt.utils.pkg.clear_rtag', MagicMock()): ++ with patch('salt.modules.aptpkg.list_pkgs', ++ MagicMock(return_value=UNINSTALL)): ++ mock_cmd = MagicMock(return_value={ ++ 'retcode': 0, ++ 'stdout': UPGRADE ++ }) ++ patch_kwargs = { ++ '__salt__': { ++ 'config.get': MagicMock(return_value=True), ++ 'cmd.run_all': mock_cmd ++ }, ++ } ++ with patch.multiple(aptpkg, **patch_kwargs): ++ aptpkg.upgrade() ++ args_matching = [True for args in patch_kwargs['__salt__']['cmd.run_all'].call_args.args if "--download-only" in args] ++ self.assertFalse(any(args_matching)) ++ ++ aptpkg.upgrade(downloadonly=True) ++ args_matching = [True for args in patch_kwargs['__salt__']['cmd.run_all'].call_args.args if "--download-only" in args] ++ self.assertTrue(any(args_matching)) ++ ++ aptpkg.upgrade(download_only=True) ++ args_matching = [True for args in patch_kwargs['__salt__']['cmd.run_all'].call_args.args if "--download-only" in args] ++ self.assertTrue(any(args_matching)) ++ + def test_show(self): + ''' + Test that the pkg.show function properly parses apt-cache show output. +-- +2.16.4 + + diff --git a/salt.changes b/salt.changes index 665fee1..e6c459f 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Tue Oct 22 09:29:19 UTC 2019 - Pablo Suárez Hernández + +- core.py: ignore wrong product_name files +- zypperpkg: understand product type + +- Added: + * accumulated-changes-from-yomi-167.patch + +------------------------------------------------------------------- +Mon Oct 21 15:10:37 UTC 2019 - Jochen Breuer + +- Enable usage of downloadonly parameter for apt module + +- Added: + * adds-the-possibility-to-also-use-downloadonly-in-kwa.patch + ------------------------------------------------------------------- Wed Oct 9 12:40:33 UTC 2019 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index fd87409..ec9bb0b 100644 --- a/salt.spec +++ b/salt.spec @@ -255,6 +255,11 @@ Patch87: use-current-ioloop-for-the-localclient-instance-of-b.patch Patch88: fix-failing-unit-tests-for-batch-async.patch # PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/54935 Patch89: add-missing-fun-for-returns-from-wfunc-executions.patch +# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/179 +Patch90: adds-the-possibility-to-also-use-downloadonly-in-kwa.patch +# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/53326 +# PATCH_FIX_UPSTREAM: https://github.com/saltstack/salt/pull/54954 +Patch91: accumulated-changes-from-yomi-167.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: logrotate @@ -832,6 +837,8 @@ cp %{S:5} ./.travis.yml %patch87 -p1 %patch88 -p1 %patch89 -p1 +%patch90 -p1 +%patch91 -p1 %build %if 0%{?build_py2}