Class: AutomateIt::PackageManager::YUM
- Inherits:
-
BaseDriver
- Object
- Common
- AutomateIt::Plugin::Base
- AutomateIt::Plugin::Driver
- BaseDriver
- AutomateIt::PackageManager::YUM
- Defined in:
- lib/automateit/package_manager/yum.rb
Overview
PackageManager::YUM
The YUM driver for the PackageManager provides a way to manage software packages on Red Hat-style systems using yum
and rpm
.
Constant Summary
Constants inherited from AutomateIt::Plugin::Driver
AutomateIt::Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from AutomateIt::Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#install(*packages) ⇒ Object
See AutomateIt::PackageManager#install.
-
#installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#installed?.
-
#not_installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#not_installed?.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
-
#uninstall(*packages) ⇒ Object
See AutomateIt::PackageManager#uninstall.
Methods inherited from AutomateIt::Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup
Methods inherited from AutomateIt::Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#install(*packages) ⇒ Object
See AutomateIt::PackageManager#install
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/automateit/package_manager/yum.rb', line 38 def install(*packages) return _install_helper(*packages) do |list, opts| # yum options: # -y : yes to queries # -d 0 : no debugging info # -e 0 : show only fatal errors # -C : don't download headers cmd = "yum -y -d 0 -e 0" cmd << " -C" if opts[:cache] == true cmd << " install "+list.join(" ")+" < /dev/null" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end |
#installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#installed?
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/automateit/package_manager/yum.rb', line 13 def installed?(*packages) return _installed_helper?(*packages) do |list, opts| ### rpm -q --nosignature --nodigest --qf "%{NAME} # %{VERSION} # %{RELEASE}\n" httpd nomarch foo cmd = 'rpm -q --nosignature --nodigest --qf "%{NAME} # %{VERSION} # %{RELEASE}\n"' list.each{|package| cmd << " "+package} cmd << " 2>&1" # missing packages are listed on STDERR log.debug(PEXEC+cmd) data = `#{cmd}` matches = data.scan(/^(.+) # (.+) # .+$/) available = matches.inject([]) do |sum, match| package, status = match sum << package sum end available end end |
#not_installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#not_installed?
33 34 35 |
# File 'lib/automateit/package_manager/yum.rb', line 33 def not_installed?(*packages) _not_installed_helper?(*packages) end |
#suitability(method, *args) ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/automateit/package_manager/yum.rb', line 8 def suitability(method, *args) # :nodoc: return available? ? 1 : 0 end |
#uninstall(*packages) ⇒ Object
See AutomateIt::PackageManager#uninstall
56 57 58 59 60 61 62 63 64 |
# File 'lib/automateit/package_manager/yum.rb', line 56 def uninstall(*packages) return _uninstall_helper(*packages) do |list, opts| cmd = "rpm --erase --quiet "+list.join(" ")+" < /dev/null" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end |