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.106.0 lib/packaging/util/tool.rb
packaging-0.105.0 lib/packaging/util/tool.rb
packaging-0.104.0 lib/packaging/util/tool.rb
packaging-0.103.0 lib/packaging/util/tool.rb
packaging-0.102.0 lib/packaging/util/tool.rb
packaging-0.101.0 lib/packaging/util/tool.rb
packaging-0.99.82 lib/packaging/util/tool.rb
packaging-0.99.81 lib/packaging/util/tool.rb
packaging-0.99.80 lib/packaging/util/tool.rb
packaging-0.99.79 lib/packaging/util/tool.rb
packaging-0.99.78 lib/packaging/util/tool.rb
packaging-0.99.77 lib/packaging/util/tool.rb
packaging-0.88.77 lib/packaging/util/tool.rb
packaging-0.99.76 lib/packaging/util/tool.rb
packaging-0.99.75 lib/packaging/util/tool.rb
packaging-0.99.74 lib/packaging/util/tool.rb
packaging-0.99.73 lib/packaging/util/tool.rb
packaging-0.99.72 lib/packaging/util/tool.rb
packaging-0.99.71 lib/packaging/util/tool.rb
packaging-0.99.70 lib/packaging/util/tool.rb