Don't use --cacheonly on DNF5

Fix #466
See #363

Actually, it still doesn't work completely but this particular issue
is fixed. I am now getting:

    Auto-installing packages:
    sudo dnf install -y /tmp/tito/noarch/tito-0.6.24-1.git.0.2a15b8c.fc39.noarch.rpm
    ...
    Failed to resolve the transaction:
    Problem: problem with installed package
      - cannot install both tito-0.6.24-1.git.0.2a15b8c.fc39.noarch and tito-0.6.24-2.fc39.noarch
      - conflicting requests

Which seems to be fixed in the dnf5 main branch:
https://github.com/rpm-software-management/dnf5/issues/722
This commit is contained in:
Jakub Kadlcik 2023-08-06 14:07:20 +02:00 committed by Jakub Kadlčík
parent 2a15b8c171
commit 39b298aa38

View file

@ -344,7 +344,7 @@ class BuilderBase(object):
print print
reinstall = self.package_manager.is_installed(self.project_name, self.build_version) reinstall = self.package_manager.is_installed(self.project_name, self.build_version)
cmd = self.package_manager.install(do_install, reinstall=reinstall, auto=True, offline=True, cmd = self.package_manager.install(do_install, reinstall=reinstall, auto=True,
escalate=self.escalate_privileges) escalate=self.escalate_privileges)
print("%s" % cmd) print("%s" % cmd)
try: try:
@ -1446,10 +1446,10 @@ class Rpm(object):
class Dnf(Rpm): class Dnf(Rpm):
def install(self, packages, reinstall=False, auto=False, offline=False, escalate=True, **kwargs): def install(self, packages, reinstall=False, auto=False, escalate=True, **kwargs):
action = "reinstall" if reinstall else "install" action = "reinstall" if reinstall else "install"
args = list(filter(lambda x: x, [ args = list(filter(lambda x: x, [
"-C" if offline else None, "-C" if self.cacheonly else None,
"-y" if auto else None, "-y" if auto else None,
])) ]))
escalation_cmd = "sudo" if escalate else "" escalation_cmd = "sudo" if escalate else ""
@ -1459,6 +1459,24 @@ class Dnf(Rpm):
def builddep(self, spec): def builddep(self, spec):
return "dnf builddep %s" % spec return "dnf builddep %s" % spec
@property
def cacheonly(self):
"""
Should a DNF command be as -C/--cacheonly?
"""
# AFAIK metadata refreshing is one of the areas where DNF5 brings the most performance
# improvements. It will help us fix #466 but also a long-time annoying #363.
if self.dnf_version == 5:
return False
return True
@property
def dnf_version(self):
"""
What DNF version is used?
"""
return 5 if os.readlink("/usr/bin/dnf") == "dnf5" else 4
class Yum(Rpm): class Yum(Rpm):
def install(self, packages, **kwargs): def install(self, packages, **kwargs):