Module: FreeBSD::Pkg

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/freebsd/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

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



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/beaker/host/freebsd/pkg.rb', line 4

def install_package(name, cmdline_args = nil, opts = {})
  case self['platform']
  when /freebsd-9/
    cmdline_args ||= '-rF'
    result = execute("pkg_add #{cmdline_args} #{name}", opts) { |result| result }
  when /freebsd-10/
    cmdline_args ||= '-y'
    result = execute("pkg install #{cmdline_args} #{name}", opts) { |result| result }
  else
    raise "Package #{name} could not be installed on #{self}"
  end
  result.exit_code == 0
end