Class: AutomateIt::PackageManager::DPKG
- Inherits:
-
BaseDriver
- Object
- Common
- AutomateIt::Plugin::Base
- AutomateIt::Plugin::Driver
- BaseDriver
- AutomateIt::PackageManager::DPKG
- Defined in:
- lib/automateit/package_manager/dpkg.rb
Overview
PackageManager::DPKG
The DPKG driver for the PackageManager provides a way to manage software packages on Debian-style systems using dpkg
.
Direct Known Subclasses
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?.
-
#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, #suitability
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
33 34 35 36 37 38 39 40 41 |
# File 'lib/automateit/package_manager/dpkg.rb', line 33 def install(*packages) return _install_helper(*packages) do |list, opts| cmd = "export DEBIAN_FRONTEND=noninteractive; dpkg --install --skip-same-version "+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?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/automateit/package_manager/dpkg.rb', line 9 def installed?(*packages) return _installed_helper?(*packages) do |list, opts| ### data = `dpkg --status nomarch apache2 not_a_real_package 2>&1` cmd = "dpkg --status "+list.join(" ")+" 2>&1" log.debug(PEXEC+cmd) data = `#{cmd}` matches = data.scan(/^Package: (.+)$\s*^Status: (.+)$/) available = matches.inject([]) do |sum, match| package, status = match sum << package if status.match(/(?:^|\s)installed\b/) sum end available end end |
#not_installed?(*packages) ⇒ Boolean
See AutomateIt::PackageManager#not_installed?
28 29 30 |
# File 'lib/automateit/package_manager/dpkg.rb', line 28 def not_installed?(*packages) return _not_installed_helper?(*packages) end |
#uninstall(*packages) ⇒ Object
See AutomateIt::PackageManager#uninstall
44 45 46 47 48 49 50 51 52 |
# File 'lib/automateit/package_manager/dpkg.rb', line 44 def uninstall(*packages) return _uninstall_helper(*packages) do |list, opts| cmd = "export DEBIAN_FRONTEND=noninteractive; dpkg --remove "+list.join(" ")+" < /dev/null" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end |