Class: Specinfra::Command::Redhat::Base::Package

Inherits:
Linux::Base::Package show all
Defined in:
lib/specinfra/command/redhat/base/package.rb

Class Method Summary collapse

Methods inherited from Base::Package

check_is_installed_by_cpan, check_is_installed_by_gem, check_is_installed_by_npm, check_is_installed_by_pear, check_is_installed_by_pecl, check_is_installed_by_pip, check_is_installed_by_rvm

Methods inherited from Base

create, escape

Class Method Details

.check_is_installed(package, version = nil) ⇒ Object Also known as: check_is_installed_by_rpm



3
4
5
6
7
8
9
# File 'lib/specinfra/command/redhat/base/package.rb', line 3

def check_is_installed(package, version=nil)
  cmd = "rpm -q #{escape(package)}"
  if version
    cmd = "#{cmd} | grep -w -- #{escape(package)}-#{escape(version)}"
  end
  cmd
end

.get_version(package, opts = nil) ⇒ Object



13
14
15
# File 'lib/specinfra/command/redhat/base/package.rb', line 13

def get_version(package, opts=nil)
  "rpm -q --qf '%{VERSION}-%{RELEASE}' #{package}"
end

.install(package, version = nil, option = '') ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/specinfra/command/redhat/base/package.rb', line 17

def install(package, version=nil, option='')
  if version
    full_package = "#{package}-#{version}"
  else
    full_package = package
  end
  cmd = "yum -y #{option} install #{full_package}"
end

.remove(package, option = '') ⇒ Object



26
27
28
# File 'lib/specinfra/command/redhat/base/package.rb', line 26

def remove(package, option='')
  "yum -y #{option} remove #{package}"
end