Skip to content

Commit

Permalink
Don't use --cacheonly on DNF5
Browse files Browse the repository at this point in the history
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:
rpm-software-management/dnf5#722
  • Loading branch information
FrostyX committed Aug 6, 2023
1 parent 2a15b8c commit 114949d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/tito/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _auto_install(self):

print
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)
print("%s" % cmd)
try:
Expand Down Expand Up @@ -1446,10 +1446,10 @@ def query(self, package):


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"
args = list(filter(lambda x: x, [
"-C" if offline else None,
"-C" if self.cacheonly else None,
"-y" if auto else None,
]))
escalation_cmd = "sudo" if escalate else ""
Expand All @@ -1459,6 +1459,24 @@ def install(self, packages, reinstall=False, auto=False, offline=False, escalate
def builddep(self, 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):
def install(self, packages, **kwargs):
Expand Down

0 comments on commit 114949d

Please sign in to comment.