Skip to content

Commit

Permalink
Use DNF for newer Enterprise Linux
Browse files Browse the repository at this point in the history
Prior to this commit, the install_package and uninstall_package methods
used Yum for all versions of Red Hat Enterprise Linux. However, RHEL has
used DNF as its default package manager since version 8.

This commit updates those methods to use DNF for RHEL 8, 9, and any
future versions and to explicitly use Yum on RHEL versions 1-7.
  • Loading branch information
mhashizume committed Nov 22, 2023
1 parent b637031 commit 38d3879
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/beaker/host/unix/pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def install_package(name, cmdline_args = '', version = nil, opts = {})
execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
when /el-4/
@logger.debug("Package installation not supported on rhel4")
when /amazon-2023|fedora-(2[2-9]|3[0-9])/
when /amazon-2023|el-(8|9|1[0-9])|fedora-(2[2-9]|3[0-9])/
name = "#{name}-#{version}" if version
execute("dnf -y #{cmdline_args} install #{name}", opts)
when /cisco|fedora|centos|redhat|eos|el-/
when /cisco|fedora|centos|redhat|eos|el-[1-7]-/
name = "#{name}-#{version}" if version
execute("yum -y #{cmdline_args} install #{name}", opts)
when /ubuntu|debian|cumulus|huaweios/
Expand Down Expand Up @@ -172,9 +172,9 @@ def uninstall_package(name, cmdline_args = '', opts = {})
execute("zypper --non-interactive rm #{name}", opts)
when /el-4/
@logger.debug("Package uninstallation not supported on rhel4")
when /amazon-2023|fedora-(2[2-9]|3[0-9])/
when /amazon-2023|el-(8|9|1[0-9])|fedora-(2[2-9]|3[0-9])/
execute("dnf -y #{cmdline_args} remove #{name}", opts)
when /cisco|fedora|centos|redhat|eos|el-/
when /cisco|fedora|centos|redhat|eos|el-[1-7]-/
execute("yum -y #{cmdline_args} remove #{name}", opts)
when /ubuntu|debian|cumulus|huaweios/
execute("apt-get purge #{cmdline_args} -y #{name}", opts)
Expand Down

0 comments on commit 38d3879

Please sign in to comment.