class Chef::Resource::FreebsdPackage
Attributes
created_as_type[RW]
Public Class Methods
new(name, run_context=nil)
click to toggle source
Calls superclass method
Chef::Resource::Package.new
# File lib/chef/resource/freebsd_package.rb, line 36 def initialize(name, run_context=nil) super @resource_name = :freebsd_package @created_as_type = "freebsd_package" end
Public Instance Methods
after_created()
click to toggle source
# File lib/chef/resource/freebsd_package.rb, line 42 def after_created assign_provider end
to_s()
click to toggle source
This resource can be invoked with multiple names package & freebsd_package. We override the #to_s method to ensure the key in resource collection matches the type resource is declared as using created_as_type. This logic can be removed once Chef does this for all resource in Chef 12: github.com/opscode/chef/issues/1817
# File lib/chef/resource/freebsd_package.rb, line 51 def to_s "#{created_as_type}[#{name}]" end
Private Instance Methods
assign_provider()
click to toggle source
# File lib/chef/resource/freebsd_package.rb, line 57 def assign_provider @provider = if @source.to_s =~ /^ports$/i Chef::Provider::Package::Freebsd::Port elsif ships_with_pkgng? || supports_pkgng? Chef::Provider::Package::Freebsd::Pkgng else Chef::Provider::Package::Freebsd::Pkg end end
ships_with_pkgng?()
click to toggle source
# File lib/chef/resource/freebsd_package.rb, line 67 def ships_with_pkgng? # It was not until __FreeBSD_version 1000017 that pkgng became # the default binary package manager. See '/usr/ports/Mk/bsd.port.mk'. node[:os_version].to_i >= 1000017 end
supports_pkgng?()
click to toggle source
# File lib/chef/resource/freebsd_package.rb, line 73 def supports_pkgng? !!shell_out!("make -V WITH_PKGNG", :env => nil).stdout.match(/yes/i) end