Class: Cfruby::Packages::AptPackageManager
- Inherits:
-
PackageManager
- Object
- PackageManager
- Cfruby::Packages::AptPackageManager
- Defined in:
- lib/libcfruby/osmodules/linux-debian.rb
Overview
PackageManager implementation for apt
Instance Method Summary collapse
-
#initialize ⇒ AptPackageManager
constructor
A new instance of AptPackageManager.
-
#install(packagename) ⇒ Object
Installs the latest version of the named package.
-
#installed_packages ⇒ Object
Returns a PackageList object that contains key value pairs for every installed package where the key is the package name and the value is the currently installed version.
-
#packages ⇒ Object
Returns the latest stable version of the named package that is available (installed or not).
-
#uninstall(packagename) ⇒ Object
Uninstalls the named package.
Methods inherited from PackageManager
#[], #installed?, #installed_version, #method_missing, #version
Constructor Details
#initialize ⇒ AptPackageManager
Returns a new instance of AptPackageManager.
11 12 13 14 15 |
# File 'lib/libcfruby/osmodules/linux-debian.rb', line 11 def initialize() # FIXME - search for apt utils @aptgetbin = 'apt-get' @dpkgbin = 'dpkg' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cfruby::Packages::PackageManager
Instance Method Details
#install(packagename) ⇒ Object
Installs the latest version of the named package
19 20 21 22 23 24 25 |
# File 'lib/libcfruby/osmodules/linux-debian.rb', line 19 def install(packagename) packagename.strip!() Cfruby.controller.attempt("Installing \"#{packagename}\"", 'destructive', 'unknown') { `#{@aptgetbin} install '#{packagename.gsub(/(\')/, "\\\1")}'` } end |
#installed_packages ⇒ Object
Returns a PackageList object that contains key value pairs for every installed package where the key is the package name and the value is the currently installed version. See PackageList for more information
62 63 |
# File 'lib/libcfruby/osmodules/linux-debian.rb', line 62 def installed_packages() end |
#packages ⇒ Object
Returns the latest stable version of the named package that is available (installed or not)
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/libcfruby/osmodules/linux-debian.rb', line 40 def packages() packages = PackageList.new() list = `#{@dpkgbin} -l` regex = /^ii\s+(\S+)\s+(\S+)/ list.each { | s | match = regex.match(s) if(match != nil) packages[match[1]]= PackageInfo.new() packages[match[1]].name = match[1] packages[match[1]].version = match[2] end } return(packages) end |
#uninstall(packagename) ⇒ Object
Uninstalls the named package
29 30 31 32 33 34 35 |
# File 'lib/libcfruby/osmodules/linux-debian.rb', line 29 def uninstall(packagename) packagename.strip!() Cfruby.controller.attempt("Uninstalling \"#{packagename}\"", 'destructive', 'unknown') { raise(Exception, 'uninstall unimplemented for AptPackageManager') } end |