Skip to content

Commit

Permalink
Add all candidates for reinstall to solver
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mracek committed Feb 15, 2024
1 parent 259e4c9 commit f9fc557
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 6 additions & 3 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2335,19 +2335,22 @@ def reinstall(self, pkg_spec, old_reponame=None, new_reponame=None,

if not installed_pkgs:
raise dnf.exceptions.PackagesNotInstalledError(
'no package matched', pkg_spec, available_nevra2pkg.values())
'no package matched', pkg_spec, available_q.run())

cnt = 0
clean_deps = self.conf.clean_requirements_on_remove
strict = self.conf.strict
for installed_pkg in installed_pkgs:
try:
available_pkg = available_nevra2pkg[ucd(installed_pkg)]
available_pkgs = available_nevra2pkg[ucd(installed_pkg)]
except KeyError:
if not remove_na:
continue
self._goal.erase(installed_pkg, clean_deps=clean_deps)
else:
self._goal.install(available_pkg)
sltr = dnf.selector.Selector(self.sack)
sltr.set(pkg=available_pkgs)
self._goal.install(select=sltr, optional=(not strict))
cnt += 1

if cnt == 0:
Expand Down
5 changes: 4 additions & 1 deletion dnf/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ def _by_provides(sack, patterns, ignore_case=False, get_query=False):
return q.run()

def _per_nevra_dict(pkg_list):
return {ucd(pkg):pkg for pkg in pkg_list}
nevra_dic = {}
for pkg in pkg_list:
nevra_dic.setdefault(ucd(pkg), []).append(pkg)
return nevra_dic
7 changes: 6 additions & 1 deletion tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,9 @@ def test_per_nevra_dict(self):
dct = dnf.query._per_nevra_dict(pkgs)
self.assertCountEqual(dct.keys(),
["lotus-3-16.x86_64", "lotus-3-16.i686"])
self.assertCountEqual(dct.values(), pkgs)
test_list = []
for list_items in dct.values():
for item in list_items:
test_list.append(item)

self.assertCountEqual(test_list, pkgs)

0 comments on commit f9fc557

Please sign in to comment.