module Chef::Provider::Package::Freebsd::PortsHelper

Public Instance Methods

makefile_variable_value(variable, dir = nil) click to toggle source
# File lib/chef/provider/package/freebsd/base.rb, line 59
def makefile_variable_value(variable, dir = nil)
  options = dir ? { cwd: dir } : {}
  options[:env] = nil
  options[:returns] = [0, 1]
  make_v = shell_out!("make", "-V", variable, **options)
  make_v.exitstatus == 0 ? make_v.stdout.strip.split($OUTPUT_RECORD_SEPARATOR).first : nil
end
port_dir(port) click to toggle source
# 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 %r{^/}
    port

  # Otherwise if the package name contains a '/' not at the start (like 'www/wordpress') treat
  # as a relative path from /usr/ports.
  when %r{/}
    "/usr/ports/#{port}"

  # Otherwise look up the path to the ports directory using 'whereis'
  else
    whereis = shell_out!("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?() click to toggle source
# File lib/chef/provider/package/freebsd/base.rb, line 32
def supports_ports?
  ::TargetIO::File.exist?("/usr/ports/Makefile")
end