Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dnf5): add dnf 5 compatible #1423

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading