Sha256: 331e34e56bee31abac7a5de06fac2ac371c1e238c3d3646822f93e5e3ec4d3ac

Contents?: true

Size: 1.1 KB

Versions: 83

Compression:

Stored size: 1.1 KB

Contents

# Utility methods for handling system binaries

module Pkg::Util::Tool

  #   Set up utility methods for handling system binaries
  #
  class << self
    def check_tool(tool)
      find_tool(tool, :required => true)
    end

    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

    alias :has_tool :find_tool

  end

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

  GIT = Pkg::Util::Tool.check_tool('git')

end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
packaging-0.99.10.2.gfa4c366 lib/packaging/util/tool.rb
packaging-0.99.10 lib/packaging/util/tool.rb
packaging-0.99.9.5.g5811fb8 lib/packaging/util/tool.rb