Module: Chef::Provider::Package::Freebsd::PortsHelper
Instance Method Summary collapse
- #makefile_variable_value(variable, dir = nil) ⇒ Object
- #port_dir(port) ⇒ Object
- #supports_ports? ⇒ Boolean
Instance Method Details
#makefile_variable_value(variable, dir = nil) ⇒ Object
58 59 60 61 62 |
# File 'lib/chef/provider/package/freebsd/base.rb', line 58 def makefile_variable_value(variable, dir = nil) = dir ? { :cwd => dir } : {} make_v = shell_out_with_timeout!("make -V #{variable}", .merge!(:env => nil, :returns => [0, 1])) make_v.exitstatus.zero? ? make_v.stdout.strip.split($\).first : nil # $\ is the line separator, i.e. newline. end |
#port_dir(port) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/chef/provider/package/freebsd/base.rb', line 36 def port_dir(port) case port # When the package name starts with a '/' treat it as the full path to the ports directory. when /^\// port # Otherwise if the package name contains a '/' not at the start (like 'www/wordpress') treat # as a relative path from /usr/ports. when /\// "/usr/ports/#{port}" # Otherwise look up the path to the ports directory using 'whereis' else whereis = shell_out_with_timeout!("whereis -s #{port}", :env => nil) unless path = whereis.stdout[/^#{Regexp.escape(port)}:\s+(.+)$/, 1] raise Chef::Exceptions::Package, "Could not find port with the name #{port}" end path end end |
#supports_ports? ⇒ Boolean
32 33 34 |
# File 'lib/chef/provider/package/freebsd/base.rb', line 32 def supports_ports? ::File.exist?("/usr/ports/Makefile") end |