Sha256: 02cc5b8a6dcefb9d782a411cb1eb61c50686aae536c9c7749fcfc975f9636cc7
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require 'wright/provider' require 'wright/provider/package' module Wright class Provider class Package # Apt package provider. Used as a provider for # {Resource::Package} on Debian-based systems. class Apt < Wright::Provider::Package # @return [Array<String>] the installed package versions def installed_versions package = @resource.name err = "Cannot determine installed versions for package '#{package}'" apt_policy = exec_or_fail('apt-cache', ['policy', package], err) version_re = /(?!\(none\)).*/ installed_re = /^ Installed: (?<version>#{version_re})$/ match = installed_re.match(apt_policy) match ? [match['version']] : [] end private def install_package apt_get(:install, @resource.name, @resource.version) end def remove_package apt_get(:remove, @resource.name) end def apt_get(action, package, version = nil) package_version = version.nil? ? '' : "=#{version}" cmd = 'apt-get' args = [action.to_s, '-qy', package + package_version] exec_or_fail(cmd, args, "cannot #{action} package '#{package}'") end def env { 'DEBIAN_FRONTEND' => 'noninteractive' } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wright-0.3.2 | lib/wright/provider/package/apt.rb |
wright-0.3.1 | lib/wright/provider/package/apt.rb |
wright-0.3.0 | lib/wright/provider/package/apt.rb |