Class: Specinfra::Command::Debian::Base::Package

Inherits:
Linux::Base::Package show all
Defined in:
lib/specinfra/command/debian/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_pip2, check_is_installed_by_pip3, check_is_installed_by_rvm, check_is_installed_by_td_agent_gem

Methods inherited from Base

create, escape

Class Method Details

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



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

def check_is_installed(package, version=nil)
  escaped_package = escape(package)
  if version
    cmd = "dpkg-query -f '${Status} ${Version}' -W #{escaped_package} | grep -E '^(install|hold) ok installed #{Regexp.escape(version)}$'"
  else
    cmd = "dpkg-query -f '${Status}' -W #{escaped_package} | grep -E '^(install|hold) ok installed$'"
  end
  cmd
end

.get_version(package, opts = nil) ⇒ Object



24
25
26
# File 'lib/specinfra/command/debian/base/package.rb', line 24

def get_version(package, opts=nil)
  "dpkg-query -f '${Status} ${Version}' -W #{package} | sed -n 's/^install ok installed //p'"
end

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



15
16
17
18
19
20
21
22
# File 'lib/specinfra/command/debian/base/package.rb', line 15

def install(package, version=nil, option='')
  if version
    full_package = "#{package}=#{version}"
  else
    full_package = package
  end
  "DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' #{option} install #{escape(full_package)}"
end

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



28
29
30
# File 'lib/specinfra/command/debian/base/package.rb', line 28

def remove(package, option='')
  "DEBIAN_FRONTEND='noninteractive' apt-get -y #{option} remove #{package}"
end