gather: Ignore comps in lookaside repo

This fixes a case where extra packages are pulled in.

The scenario is:

 * there's a lookaside repo which contains group G which has package P
 * we want to pull group G into the compose, but our definition of G
   does not contain P
 * lookaside repo does not contain package P
 * current package set has P

DNF depsolver will then merge the two definitions and try to get all the
packages. For most cases this is not a problem, since the package is in
the lookaside repo and will not be pulled into the compose. But in the
example above since P is not in lookaside, Pungi will put it into
current compose.

This is also ugly in the depsolving log says it includes package P
because it was in input. But checking comps file does not show it.

The result of this change is that some packages might disappear from
current composes. This can only happen if there is a lookaside which
defines groups with similar IDs, which should be very rare. In cases
where this would be a problem the fix is to explicitly add wanted
packages either to comps or to additional packages.

Fixes: https://pagure.io/pungi/issue/978
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-06-08 12:52:50 +02:00
parent eed97f357c
commit 004ef31917
2 changed files with 9 additions and 4 deletions

View File

@ -107,10 +107,13 @@ def main(persistdir, cachedir):
# read repos from ks
for ks_repo in ksparser.handler.repo.repoList:
# HACK: lookaside repos first; this is workaround for no repo priority handling in hawkey
# HACK: lookaside repos first; this is workaround for no repo priority
# handling in hawkey
if ks_repo.name not in gather_opts.lookaside_repos:
continue
dnf_obj.add_repo(ks_repo.name, ks_repo.baseurl, ks_repo.mirrorlist)
dnf_obj.add_repo(
ks_repo.name, ks_repo.baseurl, ks_repo.mirrorlist, enablegroups=False
)
for ks_repo in ksparser.handler.repo.repoList:
if ks_repo.name in gather_opts.lookaside_repos:

View File

@ -55,7 +55,9 @@ class DnfWrapper(dnf.Base):
self.arch_wrapper = ArchWrapper(self.conf.substitutions["arch"])
self.comps_wrapper = CompsWrapper(self)
def add_repo(self, repoid, baseurl=None, mirrorlist=None, ignoregroups=False, lookaside=False):
def add_repo(
self, repoid, baseurl=None, mirrorlist=None, enablegroups=True, lookaside=False
):
if "://" not in baseurl:
baseurl = "file://%s" % os.path.abspath(baseurl)
if LooseVersion(dnf.__version__) < LooseVersion("2.0.0"):
@ -64,7 +66,7 @@ class DnfWrapper(dnf.Base):
repo = dnf.repo.Repo(repoid, self.conf)
repo.baseurl = baseurl
repo.mirrorlist = mirrorlist
repo.ignoregroups = ignoregroups
repo.enablegroups = enablegroups
repo.enable()
self.repos.add(repo)
repo.priority = 10 if lookaside else 20