Sha256: 96072c144b9395971058991d1f58763fd5b5f7f4312bd8da3d6fc1cb2e0c11bd

Contents?: true

Size: 1.09 KB

Versions: 10

Compression:

Stored size: 1.09 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

10 entries across 10 versions & 1 rubygems

Version Path
packaging-0.99.9 lib/packaging/util/tool.rb
packaging-0.99.8 lib/packaging/util/tool.rb
packaging-0.99.7 lib/packaging/util/tool.rb
packaging-0.99.6 lib/packaging/util/tool.rb
packaging-0.99.5 lib/packaging/util/tool.rb
packaging-0.99.4 lib/packaging/util/tool.rb
packaging-0.99.3 lib/packaging/util/tool.rb
packaging-0.99.2 lib/packaging/util/tool.rb
packaging-0.99.1 lib/packaging/util/tool.rb
packaging-0.99.0 lib/packaging/util/tool.rb