Module: Unix::Pkg
Instance Method Summary collapse
- #check_for_package(name) ⇒ Object
- #install_package(name, cmdline_args = '') ⇒ Object
- #uninstall_package(name, cmdline_args = '') ⇒ Object
Methods included from Beaker::CommandFactory
Instance Method Details
#check_for_package(name) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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)) case self['platform'] when /solaris-10/ result.stdout =~ %r|/.*/#{name}| else result.exit_code == 0 end end |
#install_package(name, cmdline_args = '') ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/beaker/host/unix/pkg.rb', line 14 def install_package(name, cmdline_args = '') case self['platform'] when /sles-/ execute("zypper --non-interactive in #{name}") when /el-4/ @logger.debug("Package installation not supported on rhel4") when /fedora|centos|el-/ execute("yum -y #{cmdline_args} install #{name}") when /ubuntu|debian/ execute("apt-get update") execute("apt-get install #{cmdline_args} -y #{name}") when /solaris-11/ execute("pkg #{cmdline_args} install #{name}") when /solaris-10/ execute("pkgutil -i -y #{cmdline_args} #{name}") else raise "Package #{name} cannot be installed on #{self}" end end |
#uninstall_package(name, cmdline_args = '') ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/beaker/host/unix/pkg.rb', line 34 def uninstall_package(name, cmdline_args = '') case self['platform'] when /sles-/ execute("zypper --non-interactive rm #{name}") when /el-4/ @logger.debug("Package uninstallation not supported on rhel4") when /fedora|centos|el-/ execute("yum -y #{cmdline_args} remove #{name}") when /ubuntu|debian/ execute("apt-get purge #{cmdline_args} -y #{name}") when /solaris-11/ execute("pkg #{cmdline_args} uninstall #{name}") when /solaris-10/ execute("pkgutil -r -y #{cmdline_args} #{name}") else raise "Package #{name} cannot be installed on #{self}" end end |