module Pkg::Util::Tool

Utility methods for handling system binaries

Constants

GIT

Set up paths to system tools we use in the packaging repo no matter what distribution we're packaging for.

Public Class Methods

check_tool(tool) click to toggle source
# File lib/packaging/util/tool.rb, line 8
def check_tool(tool)
  find_tool(tool, :required => true)
end
find_tool(tool, args = { :required => false }) click to toggle source
# File lib/packaging/util/tool.rb, line 12
def find_tool(tool, args = { :required => false })
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |root|
    location = File.join(root, tool)

    if Pkg::Util::OS.windows? && File.extname(location).empty?
      exts = ENV['PATHEXT']
      exts = exts ? exts.split(File::PATH_SEPARATOR) : %w(.EXE .BAT .CMD .COM)
      exts.each do |ext|
        locationext = File.expand_path(location + ext)

        return '"' + locationext + '"' if FileTest.executable?(locationext)
      end
    end

    return location if FileTest.executable? location
  end
  fail "#{tool} tool not found...exiting" if args[:required]
  return nil
end
Also aliased as: has_tool
has_tool(tool, args = { :required => false })
Alias for: find_tool