Fix tests for DNF 3

The configuration for modules has changed.

Lookaside handling has changed, and there are now test failures. This
is a not a bug in DNF, so we need to fix it on our side.

Relates: https://bugzilla.redhat.com/show_bug.cgi?id=1603123
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-07-04 09:16:51 +02:00
parent 9ca454007a
commit 7d099012aa
2 changed files with 23 additions and 2 deletions

View File

@ -227,10 +227,27 @@ class Gather(GatherBase):
if not package_list:
return []
# The list can contain packages from lookaside and outside of
# lookaside. If the package is in both, we want to prefer the version
# from lookaside. This can be achieved by removing any package that is
# also in lookaside from the list.
lookaside_pkgs = set()
for pkg in package_list:
if pkg.repoid in self.opts.lookaside_repos:
lookaside_pkgs.add("{0.name}-{0.evr}".format(pkg))
if self.opts.greedy_method == "all":
return list(package_list)
all_pkgs = list(package_list)
all_pkgs = []
for pkg in package_list:
# Remove packages that are also in lookaside
if (
"{0.name}-{0.evr}".format(pkg) not in lookaside_pkgs
or pkg.repoid in self.opts.lookaside_repos
):
all_pkgs.append(pkg)
native_pkgs = self.q_native_binary_packages.filter(pkg=all_pkgs).apply()
multilib_pkgs = self.q_multilib_binary_packages.filter(pkg=all_pkgs).apply()

View File

@ -22,6 +22,7 @@ os.environ['PATH'] = '%s:%s' % (BINDIR, os.environ['PATH'])
from pungi.wrappers.pungi import PungiWrapper
try:
from dnf import __version__ as dnf_version
from pungi.dnf_wrapper import DnfWrapper, Conf
from pungi.gather_dnf import Gather, GatherOptions, PkgFlag
HAS_DNF = True
@ -1810,7 +1811,10 @@ class DNFDepsolvingTestCase(DepsolvingBase, unittest.TestCase):
conf = Conf(base_arch)
conf.persistdir = persistdir
conf.cachedir = self.cachedir
conf.modulesdir = os.path.join(persistdir, 'modules.d')
if int(dnf_version.split('.')[0]) < 3:
conf.modulesdir = os.path.join(persistdir, 'modules.d')
else:
conf.modulesdir._set(os.path.join(persistdir, 'modules.d'))
if exclude:
conf.exclude = exclude
dnf = DnfWrapper(conf)