|
|
4f4af9 |
From 8f3ce4868ac009976da7323ea39ebcd9a062e32d Mon Sep 17 00:00:00 2001
|
|
|
4f4af9 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
4f4af9 |
Date: Mon, 23 Nov 2020 17:00:01 +0100
|
|
|
4f4af9 |
Subject: [PATCH 1/3] Remove source packages from install/upgrade set
|
|
|
4f4af9 |
(RhBug:1898548)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
It prevents Error: Will not install a source rpm package ()
|
|
|
4f4af9 |
|
|
|
4f4af9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1898548
|
|
|
4f4af9 |
---
|
|
|
4f4af9 |
dnf/module/module_base.py | 16 ++++++++++------
|
|
|
4f4af9 |
1 file changed, 10 insertions(+), 6 deletions(-)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
diff --git a/dnf/module/module_base.py b/dnf/module/module_base.py
|
|
|
4f4af9 |
index 04701b9d..49c871c4 100644
|
|
|
4f4af9 |
--- a/dnf/module/module_base.py
|
|
|
4f4af9 |
+++ b/dnf/module/module_base.py
|
|
|
4f4af9 |
@@ -140,20 +140,21 @@ class ModuleBase(object):
|
|
|
4f4af9 |
if fail_safe_repo_used:
|
|
|
4f4af9 |
raise dnf.exceptions.Error(_(
|
|
|
4f4af9 |
"Installing module from Fail-Safe repository is not allowed"))
|
|
|
4f4af9 |
- install_base_query = self.base.sack.query().filterm(
|
|
|
4f4af9 |
- nevra_strict=install_set_artefacts).apply()
|
|
|
4f4af9 |
+ # Remove source packages they cannot be installed or upgraded
|
|
|
4f4af9 |
+ base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
|
|
|
4f4af9 |
+ install_base_query = base_no_source_query.filter(nevra_strict=install_set_artefacts)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
# add hot-fix packages
|
|
|
4f4af9 |
hot_fix_repos = [i.id for i in self.base.repos.iter_enabled() if i.module_hotfixes]
|
|
|
4f4af9 |
- hotfix_packages = self.base.sack.query().filterm(reponame=hot_fix_repos).filterm(
|
|
|
4f4af9 |
- name=install_dict.keys())
|
|
|
4f4af9 |
+ hotfix_packages = base_no_source_query.filter(
|
|
|
4f4af9 |
+ reponame=hot_fix_repos, name=install_dict.keys())
|
|
|
4f4af9 |
install_base_query = install_base_query.union(hotfix_packages)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
for pkg_name, set_specs in install_dict.items():
|
|
|
4f4af9 |
query = install_base_query.filter(name=pkg_name)
|
|
|
4f4af9 |
if not query:
|
|
|
4f4af9 |
# package can also be non-modular or part of another stream
|
|
|
4f4af9 |
- query = self.base.sack.query().filterm(name=pkg_name)
|
|
|
4f4af9 |
+ query = base_no_source_query.filter(name=pkg_name)
|
|
|
4f4af9 |
if not query:
|
|
|
4f4af9 |
for spec in set_specs:
|
|
|
4f4af9 |
logger.error(_("Unable to resolve argument {}").format(spec))
|
|
|
4f4af9 |
@@ -182,6 +183,9 @@ class ModuleBase(object):
|
|
|
4f4af9 |
fail_safe_repo = hawkey.MODULE_FAIL_SAFE_REPO_NAME
|
|
|
4f4af9 |
fail_safe_repo_used = False
|
|
|
4f4af9 |
|
|
|
4f4af9 |
+ # Remove source packages they cannot be installed or upgraded
|
|
|
4f4af9 |
+ base_no_source_query = self.base.sack.query().filterm(arch__neq=['src', 'nosrc']).apply()
|
|
|
4f4af9 |
+
|
|
|
4f4af9 |
for spec in module_specs:
|
|
|
4f4af9 |
module_list, nsvcap = self._get_modules(spec)
|
|
|
4f4af9 |
if not module_list:
|
|
|
4f4af9 |
@@ -221,7 +225,7 @@ class ModuleBase(object):
|
|
|
4f4af9 |
|
|
|
4f4af9 |
if not upgrade_package_set:
|
|
|
4f4af9 |
logger.error(_("Unable to match profile in argument {}").format(spec))
|
|
|
4f4af9 |
- query = self.base.sack.query().filterm(name=upgrade_package_set)
|
|
|
4f4af9 |
+ query = base_no_source_query.filter(name=upgrade_package_set)
|
|
|
4f4af9 |
if query:
|
|
|
4f4af9 |
sltr = dnf.selector.Selector(self.base.sack)
|
|
|
4f4af9 |
sltr.set(pkg=query)
|
|
|
4f4af9 |
--
|
|
|
4f4af9 |
2.26.2
|
|
|
4f4af9 |
|
|
|
4f4af9 |
|
|
|
4f4af9 |
From c42680b292b2cca38b24fb18f46f06f800c1934f Mon Sep 17 00:00:00 2001
|
|
|
4f4af9 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
4f4af9 |
Date: Mon, 23 Nov 2020 17:04:05 +0100
|
|
|
4f4af9 |
Subject: [PATCH 2/3] Remove all source packages from query
|
|
|
4f4af9 |
|
|
|
4f4af9 |
---
|
|
|
4f4af9 |
dnf/base.py | 2 +-
|
|
|
4f4af9 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
diff --git a/dnf/base.py b/dnf/base.py
|
|
|
4f4af9 |
index a2955051..a3d9b63f 100644
|
|
|
4f4af9 |
--- a/dnf/base.py
|
|
|
4f4af9 |
+++ b/dnf/base.py
|
|
|
4f4af9 |
@@ -1550,7 +1550,7 @@ class Base(object):
|
|
|
4f4af9 |
if (comps_pkg.basearchonly):
|
|
|
4f4af9 |
query_args.update({'arch': basearch})
|
|
|
4f4af9 |
q = self.sack.query().filterm(**query_args).apply()
|
|
|
4f4af9 |
- q.filterm(arch__neq="src")
|
|
|
4f4af9 |
+ q.filterm(arch__neq=["src", "nosrc"])
|
|
|
4f4af9 |
if not q:
|
|
|
4f4af9 |
package_string = comps_pkg.name
|
|
|
4f4af9 |
if comps_pkg.basearchonly:
|
|
|
4f4af9 |
--
|
|
|
4f4af9 |
2.26.2
|
|
|
4f4af9 |
|
|
|
4f4af9 |
|
|
|
4f4af9 |
From 1f68fa6dc59fb350e71a24e787135475f3fb5b4c Mon Sep 17 00:00:00 2001
|
|
|
4f4af9 |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
4f4af9 |
Date: Mon, 23 Nov 2020 17:29:45 +0100
|
|
|
4f4af9 |
Subject: [PATCH 3/3] Run tests with sack in tmp directory
|
|
|
4f4af9 |
|
|
|
4f4af9 |
---
|
|
|
4f4af9 |
tests/api/test_dnf_module_base.py | 17 +++++++++++------
|
|
|
4f4af9 |
1 file changed, 11 insertions(+), 6 deletions(-)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
diff --git a/tests/api/test_dnf_module_base.py b/tests/api/test_dnf_module_base.py
|
|
|
4f4af9 |
index aa47555b..18dd080d 100644
|
|
|
4f4af9 |
--- a/tests/api/test_dnf_module_base.py
|
|
|
4f4af9 |
+++ b/tests/api/test_dnf_module_base.py
|
|
|
4f4af9 |
@@ -7,16 +7,26 @@ from __future__ import unicode_literals
|
|
|
4f4af9 |
import dnf
|
|
|
4f4af9 |
import dnf.module.module_base
|
|
|
4f4af9 |
|
|
|
4f4af9 |
+import os
|
|
|
4f4af9 |
+import shutil
|
|
|
4f4af9 |
+import tempfile
|
|
|
4f4af9 |
+
|
|
|
4f4af9 |
from .common import TestCase
|
|
|
4f4af9 |
|
|
|
4f4af9 |
|
|
|
4f4af9 |
class DnfModuleBaseApiTest(TestCase):
|
|
|
4f4af9 |
def setUp(self):
|
|
|
4f4af9 |
self.base = dnf.Base(dnf.conf.Conf())
|
|
|
4f4af9 |
+ self._installroot = tempfile.mkdtemp(prefix="dnf_test_installroot_")
|
|
|
4f4af9 |
+ self.base.conf.installroot = self._installroot
|
|
|
4f4af9 |
+ self.base.conf.cachedir = os.path.join(self._installroot, "var/cache/dnf")
|
|
|
4f4af9 |
+ self.base._sack = dnf.sack._build_sack(self.base)
|
|
|
4f4af9 |
self.moduleBase = dnf.module.module_base.ModuleBase(self.base)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
def tearDown(self):
|
|
|
4f4af9 |
self.base.close()
|
|
|
4f4af9 |
+ if self._installroot.startswith("/tmp/"):
|
|
|
4f4af9 |
+ shutil.rmtree(self._installroot)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
def test_init(self):
|
|
|
4f4af9 |
moduleBase = dnf.module.module_base.ModuleBase(self.base)
|
|
|
4f4af9 |
@@ -51,12 +61,7 @@ class DnfModuleBaseApiTest(TestCase):
|
|
|
4f4af9 |
def test_install(self):
|
|
|
4f4af9 |
# ModuleBase.install()
|
|
|
4f4af9 |
self.assertHasAttr(self.moduleBase, "install")
|
|
|
4f4af9 |
- self.assertRaises(
|
|
|
4f4af9 |
- AttributeError,
|
|
|
4f4af9 |
- self.moduleBase.install,
|
|
|
4f4af9 |
- module_specs=[],
|
|
|
4f4af9 |
- strict=False,
|
|
|
4f4af9 |
- )
|
|
|
4f4af9 |
+ self.moduleBase.install(module_specs=[], strict=False)
|
|
|
4f4af9 |
|
|
|
4f4af9 |
def test_remove(self):
|
|
|
4f4af9 |
# ModuleBase.remove()
|
|
|
4f4af9 |
--
|
|
|
4f4af9 |
2.26.2
|
|
|
4f4af9 |
|