Method: Unix::Pkg#upgrade_package

Defined in:
lib/beaker/host/unix/pkg.rb

#upgrade_package(name, cmdline_args = '', opts = {}) ⇒ Object

Upgrade an installed package to the latest available version

Parameters:

  • name (String)

    The name of the package to update

  • cmdline_args (String) (defaults to: '')

    Additional command line arguments for the package manager



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/beaker/host/unix/pkg.rb', line 195

def upgrade_package(name, cmdline_args = '', opts = {})
  case self['platform']
    when /sles-/
      execute("zypper --non-interactive --no-gpg-checks up #{name}", opts)
    when /el-4/
      @logger.debug("Package upgrade is not supported on rhel4")
    when /fedora-(2[2-9]|3[0-9])/
      execute("dnf -y #{cmdline_args} update #{name}", opts)
    when /cisco|fedora|centos|redhat|eos|el-/
      execute("yum -y #{cmdline_args} update #{name}", opts)
    when /ubuntu|debian|cumulus|huaweios/
      update_apt_if_needed
      execute("apt-get install -o Dpkg::Options::='--force-confold' #{cmdline_args} -y --force-yes #{name}", opts)
    when /solaris-11/
      if opts[:acceptable_exit_codes]
        opts[:acceptable_exit_codes] << 4
      else
        opts[:acceptable_exit_codes] = [0, 4] unless opts[:accept_all_exit_codes]
      end
      execute("pkg #{cmdline_args} update #{name}", opts)
    when /solaris-10/
      execute("pkgutil -u -y #{cmdline_args} #{name}", opts)
    else
      raise "Package #{name} cannot be upgraded on #{self}"
  end
end