Skip to content

Commit

Permalink
feat(dnf5): add dnf 5 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
remigermain authored and kdeldycke committed Nov 15, 2024
1 parent d0c371e commit 01eef4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions meta_package_manager/managers/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DNF(PackageManager):

requirement = "4.0.0"

cli_names = ("dnf",)
cli_names = ("dnf4",)
"""
.. code-block:: shell-session
Expand All @@ -65,12 +65,15 @@ def installed(self) -> Iterator[Package]:
audit-libs 2.2.53-1.el8 audit_libs_dummary x86_64
(...)
"""
qf = ["%{name}", "%{version}", "%{summary}", "%{arch}"]
qf = ["%{name}", "%{version}", "%{summary}", "%{arch}\n"]
output = self.run_cli(
"repoquery", "--userinstalled", "--qf", DNF.DELIMITER.join(qf)
)

for line_package in output.splitlines():
# remove empty new line
if not line_package:
continue
package_id, installed_version, summary, arch = line_package.split(
DNF.DELIMITER
)
Expand All @@ -94,10 +97,13 @@ def outdated(self) -> Iterator[Package]:
audit-libs 2.2.53-1.el8 2.6.53-1.el8 audit_libs_dummary x86_64
(...)
"""
qf = ["%{name}", "%{version}", "%{evr}", "%{summary}", "%{arch}"]
qf = ["%{name}", "%{version}", "%{evr}", "%{summary}", "%{arch}\n"]
output = self.run_cli("repoquery", "--upgrades", "--qf", DNF.DELIMITER.join(qf))

for line_package in output.splitlines():
# remove empty new line
if not line_package:
continue
package_id, installed_version, last_version, summary, arch = (
line_package.split(DNF.DELIMITER)
)
Expand Down Expand Up @@ -213,6 +219,13 @@ def remove(self, package_id: str) -> str:
return self.run_cli("--assumeyes", "autoremove", package_id, sudo=True)


class DNF5(DNF):
homepage_url = "https://github.com/rpm-software-management/dnf5"
requirement = "5.0.0"
cli_names = ("dnf5",)
pre_args = ()


class YUM(DNF):
"""Yum is dnf is yum."""

Expand Down
3 changes: 2 additions & 1 deletion meta_package_manager/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .managers.cargo import Cargo
from .managers.chocolatey import Choco
from .managers.composer import Composer
from .managers.dnf import DNF, YUM
from .managers.dnf import DNF, DNF5, YUM
from .managers.emerge import Emerge
from .managers.flatpak import Flatpak
from .managers.gem import Gem
Expand Down Expand Up @@ -65,6 +65,7 @@
Choco,
Composer,
DNF,
DNF5,
Emerge,
Flatpak,
Gem,
Expand Down

0 comments on commit 01eef4a

Please sign in to comment.