Class: Cfruby::Packages::OpenBSDPackageManager
- Inherits:
-
PackageManager
- Object
- PackageManager
- Cfruby::Packages::OpenBSDPackageManager
- Defined in:
- lib/libcfruby/osmodules/openbsd.rb
Overview
PackageManager implementation for the FreeBSD ports system
Instance Method Summary collapse
-
#install(packagename, force = false) ⇒ Object
Installs the latest version of the named package.
-
#installed?(package) ⇒ Boolean
Return true if the package is installed Checks the origin as well.
-
#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 a PackageList object that contains key value pairs for every package (installed or not) where the key is the package name and the value is a PackageInfo object.
-
#uninstall(packagename) ⇒ Object
Uninstalls the named package.
Methods inherited from PackageManager
#[], #installed_version, #method_missing, #version
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Cfruby::Packages::PackageManager
Instance Method Details
#install(packagename, force = false) ⇒ Object
Installs the latest version of the named package
303 304 305 |
# File 'lib/libcfruby/osmodules/openbsd.rb', line 303 def install(packagename, force=false) raise(InstallError, "Automated package installation is not implemented on OpenBSD") end |
#installed?(package) ⇒ Boolean
Return true if the package is installed Checks the origin as well
289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/libcfruby/osmodules/openbsd.rb', line 289 def installed?(package) Cfruby.controller.inform('debug', "Getting installed? status of \"#{package}\" by origin") installed_packages.each_value() { |packageinfo| if(packageinfo.origin == package) return(true) end } return(super(package)) 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
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/libcfruby/osmodules/openbsd.rb', line 335 def installed_packages() packages = PackageList.new() packageregex = /^([^ ]+)-([^- ]+)\s+(.*)$/ installedpackageslist = `/usr/sbin/pkg_info` installedpackageslist.each_line() { |line| line.strip!() match = packageregex.match(line) if(match != nil) name = match[1] version = match[2] description = match[3] packages[name] = PackageInfo.new() packages[name].name = name packages[name].version = version packages[name].description = description end } return(packages) end |
#packages ⇒ Object
Returns a PackageList object that contains key value pairs for every package (installed or not) where the key is the package name and the value is a PackageInfo object
362 363 364 |
# File 'lib/libcfruby/osmodules/openbsd.rb', line 362 def packages() raise(PackageError, "A full package list is not implemented on OpenBSD") end |
#uninstall(packagename) ⇒ Object
Uninstalls the named package
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/libcfruby/osmodules/openbsd.rb', line 309 def uninstall(packagename) packagename.strip!() Cfruby.controller.attempt("Uninstalling \"#{packagename}\"", 'destructive', 'unknown') { # we have to iterate through all the attributes (name, name-version, origin) to properly delete what this could be. packagetodelete = nil installed_packages().each_value() { |package| if((packagename == package.name) or (packagename == "#{package.name}-#{package.version}")) packagetodelete = package.name + '-' + package.version break end } if packagetodelete.nil? Cfruby.controller.attempt_abort("package \"#{packagename}\": not installed") else Exec.exec("/usr/sbin/pkg_delete #{packagetodelete}`") end } end |