From ed8d76f151752fb370f13241ee1a73670429fcd9 Mon Sep 17 00:00:00 2001 From: Han Boetes Date: Sat, 15 Mar 2025 15:28:59 +0100 Subject: [PATCH 1/3] Use dnf options if dnf is installed, use legacy options if dnf is not installed The "-d 0" and "-e error_level" options are, to the best of my knowledge, old yum options. On anything since centos 7 dnf is installed and the old options are deprecated(see manpage). On fedora 41 support for these options has been removed. Fixes https://github.com/OpenVoxProject/puppet/issues/19 --- lib/puppet/provider/package/yum.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 15bc372c6b..6e0d8184d5 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -245,9 +245,19 @@ def install wanted = @resource[:name] error_level = self.class.error_level update_command = self.class.update_command + + # Check if dnf is installed + def dnf_installed? + system('command -v dnf > /dev/null 2>&1') + end + + # Use new syntax if dnf is installed, otherwise use old syntax + no_debug = dnf_installed? ? ["-q"] : ["-d", "0"] + no_error = dnf_installed? ? [] : ["-e", error_level] + # If not allowing virtual packages, do a query to ensure a real package exists unless @resource.allow_virtual? - execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact) + execute([command(:cmd)] + no_debug + no_error + ['-y', install_options, :list, wanted].compact) end should = @resource.should(:ensure) @@ -309,8 +319,7 @@ def install # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize; # ensure we capture output to check for errors. - no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : [] - command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact + command = [command(:cmd)] + no_debug + no_error + ["-y", install_options, operation, wanted].compact output = execute(command) if output.to_s =~ /^No package #{wanted} available\.$/ @@ -395,4 +404,4 @@ def scan_options(options, key) end values.compact.uniq end -end +end \ No newline at end of file From 481659dc56ffdb31bd6c624bcd0f76e638678e65 Mon Sep 17 00:00:00 2001 From: Han Boetes Date: Sat, 15 Mar 2025 16:40:18 +0100 Subject: [PATCH 2/3] readd newline --- lib/puppet/provider/package/yum.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 6e0d8184d5..8bd23355d3 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -404,4 +404,4 @@ def scan_options(options, key) end values.compact.uniq end -end \ No newline at end of file +end From a805de965846917abd4cd9fe74f6d0f6f78dc992 Mon Sep 17 00:00:00 2001 From: Han Boetes Date: Sat, 15 Mar 2025 15:28:59 +0100 Subject: [PATCH 3/3] Use dnf options if dnf is installed, use legacy options if dnf is not installed The "-d 0" and "-e error_level" options are, to the best of my knowledge, old yum options. On anything since centos 7 dnf is installed and the old options are deprecated(see manpage). On fedora 41 support for these options has been removed. Fixes https://github.com/OpenVoxProject/puppet/issues/19 readd newline --- lib/puppet/provider/package/yum.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 15bc372c6b..8bd23355d3 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -245,9 +245,19 @@ def install wanted = @resource[:name] error_level = self.class.error_level update_command = self.class.update_command + + # Check if dnf is installed + def dnf_installed? + system('command -v dnf > /dev/null 2>&1') + end + + # Use new syntax if dnf is installed, otherwise use old syntax + no_debug = dnf_installed? ? ["-q"] : ["-d", "0"] + no_error = dnf_installed? ? [] : ["-e", error_level] + # If not allowing virtual packages, do a query to ensure a real package exists unless @resource.allow_virtual? - execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact) + execute([command(:cmd)] + no_debug + no_error + ['-y', install_options, :list, wanted].compact) end should = @resource.should(:ensure) @@ -309,8 +319,7 @@ def install # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize; # ensure we capture output to check for errors. - no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : [] - command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact + command = [command(:cmd)] + no_debug + no_error + ["-y", install_options, operation, wanted].compact output = execute(command) if output.to_s =~ /^No package #{wanted} available\.$/