Module: Unix::Pkg

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/unix/pkg.rb

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#check_for_command(name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/beaker/host/unix/pkg.rb', line 10

def check_for_command(name)
  result = exec(Beaker::Command.new("which #{name}"), :accept_all_exit_codes => true)
  case self['platform']
  when /solaris-10/
    # solaris 10 appears to have considered `which` to have run successfully,
    # even if the command didn't exist, so it'll return a 0 exit code in
    # either case. Instead we match for the phrase output when a match isn't
    # found: "no #{name} in $PATH", reversing it to match our API
    !( result.stdout.match(/^no\ #{name}\ in\ /) )
  else
    result.exit_code == 0
  end
end

#check_for_package(name, opts = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/beaker/host/unix/pkg.rb', line 24

def check_for_package(name, opts = {})
  opts = {:accept_all_exit_codes => true}.merge(opts)
  case self['platform']
    when /sles-10/
      result = execute("zypper se -i --match-exact #{name}", opts) { |result| result }
      result.stdout =~ /No packages found/ ? (return false) : (return result.exit_code == 0)
    when /sles-/
      if !self[:sles_rpmkeys_nightly_pl_imported]
        # The `:sles_rpmkeys_nightly_pl_imported` key is only read here at this
        # time. It's just to make sure that we only do the key import once, &
        # isn't for setting or use outside of beaker.
        execute('rpmkeys --import http://nightlies.puppetlabs.com/07BB6C57', opts)
        self[:sles_rpmkeys_nightly_pl_imported] = true
      end
      result = execute("zypper --gpg-auto-import-keys se -i --match-exact #{name}", opts) { |result| result }
    when /el-4/
      @logger.debug("Package query not supported on rhel4")
      return false
    when /cisco|fedora|centos|redhat|eos|el-/
      result = execute("rpm -q #{name}", opts) { |result| result }
    when /ubuntu|debian|cumulus|huaweios/
      result = execute("dpkg -s #{name}", opts) { |result| result }
    when /solaris-11/
      result = execute("pkg info #{name}", opts) { |result| result }
    when /solaris-10/
      result = execute("pkginfo #{name}", opts) { |result| result }
      if result.exit_code == 1
        result = execute("pkginfo CSW#{name}", opts) { |result| result }
      end
    when /openbsd/
      result = execute("pkg_info #{name}", opts) { |result| result }
    when /archlinux/
      result = execute("pacman -Q #{name}", opts) { |result| result }
    else
      raise "Package #{name} cannot be queried on #{self}"
  end
  result.exit_code == 0
end

#determine_if_x86_64Boolean

Examine the host system to determine the architecture

Returns:

  • (Boolean)

    true if x86_64, false otherwise



302
303
304
305
306
307
308
309
310
# File 'lib/beaker/host/unix/pkg.rb', line 302

def determine_if_x86_64
  if self[:platform] =~ /solaris/
    result = exec(Beaker::Command.new("uname -a | grep x86_64"), :accept_all_exit_codes => true)
      result.exit_code == 0
  else
    result = exec(Beaker::Command.new("arch | grep x86_64"), :accept_all_exit_codes => true)
    result.exit_code == 0
  end
end

#extract_rpm_proxy_options(url) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extract RPM command’s proxy options from URL

Parameters:

Returns:

  • (String)

    httpproxy and httport options for rpm

Raises:

  • (StandardError)

    When encountering a string that cannot be parsed



320
321
322
323
324
325
326
327
328
# File 'lib/beaker/host/unix/pkg.rb', line 320

def extract_rpm_proxy_options(url)
  begin
    host, port = url.match(/https?:\/\/(.*):(\d*)/)[1,2]
    raise if host.empty? or port.empty?
    "--httpproxy #{host} --httpport #{port}"
  rescue
    raise "Cannot extract host and port from '#{url}'"
  end
end

#install_local_package(onhost_package_file, onhost_copy_dir = nil) ⇒ Object

Installs a package already located on a SUT

Parameters:

  • onhost_package_file (String)

    Path to the package file to install

  • onhost_copy_dir (String) (defaults to: nil)

    Path to the directory where the package file is located. Used on solaris only

Returns:

  • nil



509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/beaker/host/unix/pkg.rb', line 509

def install_local_package(onhost_package_file, onhost_copy_dir = nil)
  variant, version, arch, codename = self['platform'].to_array
  case variant
  when /^(fedora|el|redhat|centos)$/
    command_name = 'yum'
    command_name = 'dnf' if variant == 'fedora' && version > 21
    execute("#{command_name} --nogpgcheck localinstall -y #{onhost_package_file}")
  when /^(sles)$/
    execute("zypper --non-interactive --no-gpg-checks in #{onhost_package_file}")
  when /^(debian|ubuntu|cumulus)$/
    execute("dpkg -i --force-all #{onhost_package_file}")
    execute("apt-get update")
  when /^solaris$/
    self.solaris_install_local_package( onhost_package_file, onhost_copy_dir )
  when /^osx$/
    install_package( onhost_package_file )
  else
    msg = "Platform #{variant} is not supported by the method "
    msg << 'install_local_package'
    raise ArgumentError, msg
  end
end

#install_package(name, cmdline_args = '', version = nil, opts = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/beaker/host/unix/pkg.rb', line 74

def install_package(name, cmdline_args = '', version = nil, opts = {})
  case self['platform']
    when /sles-/
      execute("zypper --non-interactive --gpg-auto-import-keys in #{name}", opts)
    when /el-4/
      @logger.debug("Package installation not supported on rhel4")
    when /fedora-(2[2-9]|3[0-9])/
      if version
        name = "#{name}-#{version}"
      end
      execute("dnf -y #{cmdline_args} install #{name}", opts)
    when /cisco|fedora|centos|redhat|eos|el-/
      if version
        name = "#{name}-#{version}"
      end
      execute("yum -y #{cmdline_args} install #{name}", opts)
    when /ubuntu|debian|cumulus|huaweios/
      if version
        name = "#{name}=#{version}"
      end
      update_apt_if_needed
      execute("apt-get install --force-yes #{cmdline_args} -y #{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} install #{name}", opts)
    when /solaris-10/
      if ! check_for_command('pkgutil')
        # https://www.opencsw.org/package/pkgutil/
        noask_text = self.noask_file_text
        noask_file = File.join(external_copy_base, 'noask')
        create_remote_file(self, noask_file, noask_text)
        execute("pkgadd -d http://get.opencsw.org/now -a #{noask_file} -n all", opts)
        execute('/opt/csw/bin/pkgutil -U', opts)
        execute('/opt/csw/bin/pkgutil -y -i pkgutil', opts)
      end
      execute("pkgutil -i -y #{cmdline_args} #{name}", opts)
    when /openbsd/
      begin
        execute("pkg_add -I #{cmdline_args} #{name}", opts) do |command|
          # Handles where there are multiple rubies, installs the latest one
          if command.stderr =~ /^Ambiguous: #{name} could be (.+)$/
            name = $1.chomp.split(' ').collect { |x|
              x =~ /-(\d[^-p]+)/
              [x, $1]
            }.select { |x|
              # Blacklist Ruby 2.2.0+ for the sake of Puppet 3.x
              Gem::Version.new(x[1]) < Gem::Version.new('2.2.0')
            }.sort { |a,b|
              Gem::Version.new(b[1]) <=> Gem::Version.new(a[1])
            }.collect { |x|
              x[0]
            }.first
            raise ArgumentException
          end
          # If the package advises symlinks to be created, do it
          command.stdout.split(/\n/).select { |x| x =~ /^\s+ln\s/ }.each do |ln|
            execute(ln, opts)
          end
        end
      rescue
        retry
      end
    when /archlinux/
      execute("pacman -S --noconfirm #{cmdline_args} #{name}", opts)
    else
      raise "Package #{name} cannot be installed on #{self}"
  end
end

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

Install a package using RPM

Parameters:

  • name (String)

    The name of the package to install. It may be a filename or a URL.

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

    Additional command line arguments for the package manager.

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :package_proxy (String)

    A proxy of form host:port

Returns:

  • nil



157
158
159
160
161
162
163
# File 'lib/beaker/host/unix/pkg.rb', line 157

def install_package_with_rpm(name, cmdline_args = '', opts = {})
  proxy = ''
  if name =~ /^http/ and opts[:package_proxy]
    proxy = extract_rpm_proxy_options(opts[:package_proxy])
  end
  execute("rpm #{cmdline_args} -Uvh #{name} #{proxy}")
end

#pe_puppet_agent_promoted_package_info(puppet_collection = nil, opts = {}) ⇒ String

Gets host-specific information for PE promoted puppet-agent packages

Parameters:

  • puppet_collection (String) (defaults to: nil)

    Name of the puppet collection to use

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options hash to provide extra values

Returns:

  • (String, String, String)

    Host-specific information for packages

    1. release_path_end Suffix for the release_path. Used on Windows. Check

    Windows::Pkg#pe_puppet_agent_promoted_package_info to see usage.

    1. release_file Path to the file on release build servers

    2. download_file Filename for the package itself

Raises:

  • (ArgumentError)


448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/beaker/host/unix/pkg.rb', line 448

def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
  error_message = "Must provide %s argument to get puppet agent dev package information"
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection

  variant, version, arch, codename = self['platform'].to_array
  case variant
  when /^(fedora|el|centos|redhat|sles)$/
    variant = ((['centos', 'redhat'].include?(variant)) ? 'el' : variant)
    release_file = "/repos/#{variant}/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*.rpm"
    download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
  when /^(debian|ubuntu|cumulus)$/
    if arch == 'x86_64'
      arch = 'amd64'
    end
    version = version[0,2] + '.' + version[2,2] if (variant =~ /ubuntu/ && !version.include?("."))
    release_file = "/repos/apt/#{codename}/pool/#{puppet_collection}/p/puppet-agent/puppet-agent*#{arch}.deb"
    download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
  when /^solaris$/
    if arch == 'x86_64'
      arch = 'i386'
    end
    release_file = "/repos/solaris/#{version}/#{puppet_collection}/"
    download_file = "puppet-agent-#{variant}-#{version}-#{arch}.tar.gz"
  else
    raise "No pe-promoted installation step for #{variant} yet..."
  end
  return '', release_file, download_file
end

#pe_puppet_agent_promoted_package_install(onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts) ⇒ Object

Installs a given PE promoted package on a host

Parameters:

  • onhost_copy_base (String)

    Base copy directory on the host

  • onhost_copied_download (String)

    Downloaded file path on the host

  • onhost_copied_file (String)

    Copied file path once un-compressed

  • download_file (String)

    File name of the downloaded file

  • opts (Hash{Symbol=>String})

    additional options

Returns:

  • nil



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/beaker/host/unix/pkg.rb', line 486

def pe_puppet_agent_promoted_package_install(
  onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts
)
  uncompress_local_tarball( onhost_copied_download, onhost_copy_base, download_file )
  if self['platform'] =~ /^solaris/
    # above uncompresses the install from .tar.gz -> .p5p into the
    # onhost_copied_file directory w/a weird name. We have to read that file
    # name from the filesystem, so that we can provide it to install_local...
    pkg_filename = execute( "ls #{onhost_copied_file}" )
    onhost_copied_file = "#{onhost_copied_file}#{pkg_filename}"
  end

  install_local_package( onhost_copied_file, onhost_copy_base )
  nil
end

#pkg_initializeObject

This method overrides Beaker::Host#pkg_initialize to provide unix-specific package management setup



6
7
8
# File 'lib/beaker/host/unix/pkg.rb', line 6

def pkg_initialize
  @apt_needs_update = true
end

#puppet_agent_dev_package_info(puppet_collection = nil, puppet_agent_version = nil, opts = {}) ⇒ String

Note:

Solaris & OSX do require some options to be set. See #solaris_puppet_agent_dev_package_info & Mac::Pkg#puppet_agent_dev_package_info for more details

Gets the path & file name for the puppet agent dev package on Unix

Parameters:

  • puppet_collection (String) (defaults to: nil)

    Name of the puppet collection to use

  • puppet_agent_version (String) (defaults to: nil)

    Version of puppet agent to get

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options hash to provide extra values

Returns:

  • (String, String)

    Path to the directory and filename of the package, respectively

Raises:

  • (ArgumentError)

    If one of the two required parameters (puppet_collection, puppet_agent_version) is either not passed or set to nil



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/beaker/host/unix/pkg.rb', line 408

def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
  error_message = "Must provide %s argument to get puppet agent dev package information"
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
  raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version

  variant, version, arch, codename = self['platform'].to_array
  case variant
  when /^(solaris)$/
    release_path_end, release_file = solaris_puppet_agent_dev_package_info(
      puppet_collection, puppet_agent_version, opts )
  when /^(sles|aix|el|centos|oracle|redhat|scientific)$/
    variant = 'el' if variant.match(/(?:el|centos|oracle|redhat|scientific)/)
    if variant == 'aix'
      arch = 'ppc' if arch == 'power'
      version_x, version_y = /^(\d+)\.(\d+)/.match(puppet_agent_version).captures.map(&:to_i)
      if version_x < 5 || version_x == 5 && version_y < 99 # 5.99.z indicates pre-release puppet6
        version = '7.1' if version == '7.2'
      else
        version = '6.1'
      end
    end
    release_path_end = "#{variant}/#{version}/#{puppet_collection}/#{arch}"
    release_file = "puppet-agent-#{puppet_agent_version}-1.#{variant}#{version}.#{arch}.rpm"
  else
    msg = "puppet_agent dev package info unknown for platform '#{self['platform']}'"
    raise ArgumentError, msg
  end
  return release_path_end, release_file
end

#solaris_install_local_package(package_path, noask_directory = nil) ⇒ Beaker::Result

Installs a local package file on a solaris host

Parameters:

  • package_path (String)

    Path to the package file on the host

  • noask_directory (String) (defaults to: nil)

    Path to the directory for the noask file (only needed for solaris 10).

Returns:

Raises:

  • (ArgumentError)


571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'lib/beaker/host/unix/pkg.rb', line 571

def solaris_install_local_package(package_path, noask_directory = nil)
  variant, version, arch, codename = self['platform'].to_array

  version = version.split('.')[0] # packages are only published for major versions

  error_message = nil
  unless variant == 'solaris'
    error_message = "Can not call solaris_install_local_package for the "
    error_message << "non-solaris platform '#{variant}'"
  end
  if version != '10' && version != '11'
    error_message = "Solaris #{version} is not supported by the method "
    error_message << 'solaris_install_local_package'
  end
  raise ArgumentError, error_message if error_message

  if version == '10'
    noask_text = self.noask_file_text
    create_remote_file self, File.join(noask_directory, 'noask'), noask_text

    install_cmd = "gunzip -c #{package_path} | pkgadd -d /dev/stdin -a noask -n all"
  elsif version == '11'
    install_cmd = "pkg install -g #{package_path} puppet-agent"
  end
  self.exec(Beaker::Command.new(install_cmd))
end

#solaris_puppet_agent_dev_package_info(puppet_collection = nil, puppet_agent_version = nil, opts = {}) ⇒ String

Note:

Solaris does require :download_url to be set on the opts argument in order to check for builds on the builds server

Gets the path & file name for the puppet agent dev package on Unix

Parameters:

  • puppet_collection (String) (defaults to: nil)

    Name of the puppet collection to use

  • puppet_agent_version (String) (defaults to: nil)

    Version of puppet agent to get

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options hash to provide extra values

Returns:

  • (String, String)

    Path to the directory and filename of the package, respectively

Raises:

  • (ArgumentError)

    If one of the two required parameters (puppet_collection, puppet_agent_version) is either not passed or set to nil



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/beaker/host/unix/pkg.rb', line 343

def solaris_puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
  error_message = "Must provide %s argument to get puppet agent package information"
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
  raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version
  raise ArgumentError, error_message % "opts[:download_url]" unless opts[:download_url]

  variant, version, arch, codename = self['platform'].to_array

  version = version.split('.')[0] # packages are only published for major versions

  platform_error = "Incorrect platform '#{variant}' for #solaris_puppet_agent_dev_package_info"
  raise ArgumentError, platform_error if variant != 'solaris'

  if arch == 'x86_64'
    arch = 'i386'
  end
  release_path_end = "solaris/#{version}/#{puppet_collection}"
  solaris_revision_conjunction = '-'
  revision = '1'
  if version == '10'
    solaris_release_version = ''
    pkg_suffix = 'pkg.gz'
    solaris_name_conjunction = '-'
    component_version = puppet_agent_version
  elsif version == '11'
    # Ref:
    # http://www.oracle.com/technetwork/articles/servers-storage-admin/ips-package-versioning-2232906.html
    #
    # Example to show package name components:
    #   Full package name: [email protected],5.11-1.sparc.p5p
    #   Schema: <component-name><solaris_name_conjunction><component_version><solaris_release_version><solaris_revision_conjunction><revision>.<arch>.<pkg_suffix>
    solaris_release_version = ',5.11' # injecting comma to prevent from adding another var
    pkg_suffix = 'p5p'
    solaris_name_conjunction = '@'
    component_version = puppet_agent_version.dup
    component_version.gsub!(/[a-zA-Z]/, '')
    component_version.gsub!(/(^-)|(-$)/, '')
    # Here we strip leading 0 from version components but leave
    # singular 0 on their own.
    component_version = component_version.split('-').join('.')
    component_version = component_version.split('.').map(&:to_i).join('.')
  end
  release_file_base = "puppet-agent#{solaris_name_conjunction}#{component_version}#{solaris_release_version}"
  release_file_end = "#{arch}.#{pkg_suffix}"
  release_file = "#{release_file_base}#{solaris_revision_conjunction}#{revision}.#{release_file_end}"
  if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}")
    release_file = "#{release_file_base}.#{release_file_end}"
  end
  return release_path_end, release_file
end

#uncompress_local_tarball(onhost_tar_file, onhost_base_dir, download_file) ⇒ Object

Uncompresses a tarball on the SUT

Parameters:

  • onhost_tar_file (String)

    Path to the tarball to uncompress

  • onhost_base_dir (String)

    Path to the directory to uncompress to

  • download_file (String)

    Name of the file after uncompressing

Returns:

  • nil



539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/beaker/host/unix/pkg.rb', line 539

def uncompress_local_tarball(onhost_tar_file, onhost_base_dir, download_file)
  variant, version, arch, codename = self['platform'].to_array
  case variant
  when /^(fedora|el|centos|redhat|sles|debian|ubuntu|cumulus)$/
    execute("tar -zxvf #{onhost_tar_file} -C #{onhost_base_dir}")
  when /^solaris$/
    # uncompress PE puppet-agent tarball
    if version == '10'
      execute("gunzip #{onhost_tar_file}")
      tar_file_name = File.basename(download_file, '.gz')
      execute("tar -xvf #{tar_file_name}")
    elsif version == '11'
      execute("tar -zxvf #{onhost_tar_file}")
    else
      msg = "Solaris #{version} is not supported by the method "
      msg << 'uncompress_local_tarball'
      raise ArgumentError, msg
    end
  else
    msg = "Platform #{variant} is not supported by the method "
    msg << 'uncompress_local_tarball'
    raise ArgumentError, msg
  end
end

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



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/beaker/host/unix/pkg.rb', line 165

def uninstall_package(name, cmdline_args = '', opts = {})
  case self['platform']
    when /sles-/
      execute("zypper --non-interactive rm #{name}", opts)
    when /el-4/
      @logger.debug("Package uninstallation not supported on rhel4")
    when /edora-(2[2-9]|3[0-9])/
      execute("dnf -y #{cmdline_args} remove #{name}", opts)
    when /cisco|fedora|centos|redhat|eos|el-/
      execute("yum -y #{cmdline_args} remove #{name}", opts)
    when /ubuntu|debian|cumulus|huaweios/
      execute("apt-get purge #{cmdline_args} -y #{name}", opts)
    when /solaris-11/
      execute("pkg #{cmdline_args} uninstall #{name}", opts)
    when /solaris-10/
      execute("pkgrm -n #{cmdline_args} #{name}", opts)
    when /aix/
      execute("rpm #{cmdline_args} -e #{name}", opts)
    when /archlinux/
      execute("pacman -R --noconfirm #{cmdline_args} #{name}", opts)
    else
      raise "Package #{name} cannot be installed on #{self}"
  end
end

#update_apt_if_neededObject

If apt has not been updated since the last repo deployment it is updated. Otherwise this is a noop



65
66
67
68
69
70
71
72
# File 'lib/beaker/host/unix/pkg.rb', line 65

def update_apt_if_needed
  if self['platform'] =~ /debian|ubuntu|cumulus|huaweios/
    if @apt_needs_update
      execute("apt-get update")
      @apt_needs_update = false
    end
  end
end

#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