Skip to content

Commit 2f6e8e3

Browse files
mvo5supakeen
authored andcommitted
bib: fix missing dnf detection
The existing code was checking if dnf could be run with --version to detect if dnf is installed at all. That is wrong, dnf can fail when it is just run with --version, e.g.: ``` Failed to open log file: /var/log/hawkey.log 4.14.0 ``` But errors like this should be surfaced to the user (which the next call to dnf will do). So instead of running dnf just run: ``` sh -c "command -v dnf" ``` to check if its available. This will fix the test failures in osbuild/image-builder-cli#374 Note that the detection is covered by an existing test so no new test needs adding.
1 parent 9add0c0 commit 2f6e8e3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/bib/container/solver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func forceSymlink(symlinkPath, target string) error {
3535
// option).
3636
func (c *Container) InitDNF() error {
3737
/* #nosec G204 */
38-
if err := exec.Command("podman", "exec", c.id, "dnf", "--version").Run(); err != nil {
38+
if err := exec.Command("podman", "exec", c.id, "sh", "-c", `command -v dnf`).Run(); err != nil {
3939
return ErrNoDnf
4040
}
4141

0 commit comments

Comments
 (0)