Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/pyinfra/facts/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class RpmPackageProvides(FactBase):

@override
def requires_command(self, *args, **kwargs) -> str:
return "repoquery"
return "dnf"

@override
def command(self, package):
# Accept failure here (|| true) for invalid/unknown packages
return make_formatted_string_command(
"repoquery --queryformat {0} --whatprovides {1} || true",
"dnf repoquery --quiet --queryformat {0} --whatprovides {1} || true",
QuoteString(rpm_query_format),
QuoteString(package),
)
Expand Down
3 changes: 2 additions & 1 deletion src/pyinfra/operations/util/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def ensure_packages(
upgrade_command: str | StringCommand | None = None,
version_join: str | None = None,
expand_package_fact: Callable[[str], list[str | list[str]]] | None = None,
expand_match_any: bool = False,
):
"""
Handles this common scenario:
Expand Down Expand Up @@ -196,7 +197,7 @@ def ensure_packages(
if present is True:
for package in packages:
has_package, expanded_packages = _has_package(
package.lkup_name, current_packages, expand_package_fact
package.lkup_name, current_packages, expand_package_fact, match_any=expand_match_any
)

if not has_package:
Expand Down
4 changes: 2 additions & 2 deletions tests/facts/rpm.RpmPackageProvides/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"arg": "vim",
"command": "repoquery --queryformat '%{NAME} %{VERSION}-%{RELEASE}\\n' --whatprovides vim || true",
"requires_command": "repoquery",
"command": "dnf repoquery --quiet --queryformat '%{NAME} %{VERSION}-%{RELEASE}\\n' --whatprovides vim || true",
"requires_command": "dnf",
"output": [
"vim-enhanced 8.0.1763-15.el8"
],
Expand Down
4 changes: 2 additions & 2 deletions tests/facts/rpm.RpmPackageProvides/package_needs_quotes.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"arg": "my;package",
"command": "repoquery --queryformat '%{NAME} %{VERSION}-%{RELEASE}\\n' --whatprovides 'my;package' || true",
"requires_command": "repoquery",
"command": "dnf repoquery --quiet --queryformat '%{NAME} %{VERSION}-%{RELEASE}\\n' --whatprovides 'my;package' || true",
"requires_command": "dnf",
"output": [
"my-package 1.0.0-1.el8"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"args": [["wget"]],
"facts": {
"rpm.RpmPackages": {
"wget2-wget": ["2.2.1-1.fc43"]
},
"rpm.RpmPackageProvides": {
"package=wget": [["wget1-wget", "1.25.0-2.fc43"], ["wget2-wget", "2.2.1-1.fc43"]]
}
},
"commands": [],
"noop_description": "package wget is installed"
}
Loading