Module: Unix::Pkg

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

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#check_for_package(name) ⇒ Object



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

def check_for_package name
  result = exec(Beaker::Command.new("which #{name}"), :acceptable_exit_codes => (0...127))
  result.exit_code == 0
end

#install_package(name) ⇒ Object



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

def install_package name
  if self['platform'] =~ /el-4/
    @logger.debug("Package installation not supported on rhel4")
  elsif self['platform'] =~ /(fedora)|(centos)|(el)/
    execute("yum -y install #{name}")
  elsif self['platform'] =~ /(ubuntu)|(debian)/
    execute("apt-get update")
    execute("apt-get install -y #{name}")
  else
    raise "Package #{name} cannot be installed on #{host}"
  end
end