Skip to content

Commit

Permalink
base: Add obsoleters of only latest versions
Browse files Browse the repository at this point in the history
Resolves situations where a package is in older version obsoleted, but
there is newer (not obsoleted) version available.
This patch covers installation of group packages and arch specific
packages. The rest is in hawkey library.

Relevant bugs:
https://bugzilla.redhat.com/show_bug.cgi?id=2183279
https://bugzilla.redhat.com/show_bug.cgi?id=2176263
  • Loading branch information
m-blaha authored and j-mracek committed Sep 22, 2023
1 parent 9074f44 commit a9593d2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,16 @@ def trans_install(query, remove_query, comps_pkg, strict):
sltr.set(provides="({} if {})".format(comps_pkg.name, comps_pkg.requires))
else:
if self.conf.obsoletes:
query = query.union(self.sack.query().filterm(obsoletes=query))
# If there is no installed package in the pkgs_list, add only
# obsoleters of the latest versions. Otherwise behave
# consistently with upgrade and add all obsoleters.
# See https://bugzilla.redhat.com/show_bug.cgi?id=2176263
# for details of the problem.
if query.installed():
query = query.union(self.sack.query().filterm(obsoletes=query))
else:
query = query.union(self.sack.query().filterm(
obsoletes=query.filter(latest_per_arch_by_priority=True)))
sltr.set(pkg=query)
self._goal.install(select=sltr, optional=not strict)
return remove_query
Expand Down Expand Up @@ -1927,7 +1936,11 @@ def _install_multiarch(self, query, reponame=None, strict=True):
sltr = dnf.selector.Selector(self.sack)
q = self.sack.query().filterm(pkg=packages)
if self.conf.obsoletes:
q = q.union(self.sack.query().filterm(obsoletes=q))
# use only obsoletes of the latest versions
# See https://bugzilla.redhat.com/show_bug.cgi?id=2176263
# for details of the problem.
q = q.union(self.sack.query().filterm(
obsoletes=q.filter(latest_per_arch_by_priority=True)))
sltr = sltr.set(pkg=q)
if reponame is not None:
sltr = sltr.set(reponame=reponame)
Expand Down

0 comments on commit a9593d2

Please sign in to comment.