2011-03-12 23:06:45 -08:00
|
|
|
class UsageError < RuntimeError; end
|
|
|
|
class FormulaUnspecifiedError < UsageError; end
|
|
|
|
class KegUnspecifiedError < UsageError; end
|
2010-09-11 20:22:54 +01:00
|
|
|
|
2011-03-12 23:06:45 -08:00
|
|
|
class MultipleVersionsInstalledError < RuntimeError
|
2010-11-12 20:59:53 -08:00
|
|
|
attr :name
|
|
|
|
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "#{name} has multiple installed versions"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NotAKegError < RuntimeError; end
|
|
|
|
|
2011-03-12 23:06:45 -08:00
|
|
|
class NoSuchKegError < RuntimeError
|
2010-11-12 20:59:53 -08:00
|
|
|
attr :name
|
|
|
|
|
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "No such keg: #{HOMEBREW_CELLAR}/#{name}"
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaUnavailableError < RuntimeError
|
|
|
|
attr :name
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def initialize name
|
|
|
|
@name = name
|
|
|
|
super "No available formula for #{name}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
class InstallationError < RuntimeError
|
|
|
|
attr :formula
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2011-03-09 21:01:23 -08:00
|
|
|
def initialize formula, message=""
|
2010-09-11 20:22:54 +01:00
|
|
|
super message
|
|
|
|
@formula = formula
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaAlreadyInstalledError < Homebrew::InstallationError
|
|
|
|
def message
|
|
|
|
"Formula already installed: #{formula}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
|
|
|
|
def message
|
|
|
|
"Formula installation already attempted: #{formula}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class UnsatisfiedExternalDependencyError < Homebrew::InstallationError
|
|
|
|
attr :type
|
2011-03-26 10:19:03 -07:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def initialize formula, type
|
|
|
|
@type = type
|
2011-09-08 07:16:32 -07:00
|
|
|
super formula, get_message(formula)
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
2011-09-08 07:16:32 -07:00
|
|
|
def get_message formula
|
2010-09-11 20:22:54 +01:00
|
|
|
<<-EOS.undent
|
2011-09-08 07:16:32 -07:00
|
|
|
Unsatisfied external dependency: #{formula}
|
2010-09-11 20:22:54 +01:00
|
|
|
Homebrew does not provide #{type.to_s.capitalize} dependencies, #{tool} does:
|
|
|
|
|
|
|
|
#{command_line} #{formula}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tool
|
|
|
|
case type
|
2011-04-25 13:08:43 -07:00
|
|
|
when :python then 'easy_install'
|
2010-09-11 20:22:54 +01:00
|
|
|
when :ruby, :jruby then 'rubygems'
|
|
|
|
when :perl then 'cpan'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def command_line
|
|
|
|
case type
|
|
|
|
when :python
|
2011-09-07 12:56:23 -07:00
|
|
|
"easy_install"
|
2010-09-11 20:22:54 +01:00
|
|
|
when :ruby
|
|
|
|
"gem install"
|
|
|
|
when :perl
|
|
|
|
"cpan -i"
|
|
|
|
when :jruby
|
|
|
|
"jruby -S gem install"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BuildError < Homebrew::InstallationError
|
|
|
|
attr :exit_status
|
|
|
|
attr :command
|
|
|
|
attr :env
|
|
|
|
|
|
|
|
def initialize formula, cmd, args, es
|
|
|
|
@command = cmd
|
|
|
|
@env = ENV.to_hash
|
|
|
|
@exit_status = es.exitstatus rescue 1
|
2011-03-14 15:48:35 -07:00
|
|
|
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
|
2010-09-11 20:22:54 +01:00
|
|
|
super formula, "Failed executing: #{command} #{args}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def was_running_configure?
|
|
|
|
@command == './configure'
|
|
|
|
end
|
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
|
|
|
class DownloadError < RuntimeError
|
|
|
|
attr :command
|
|
|
|
attr :args
|
|
|
|
attr :exit_status
|
|
|
|
|
|
|
|
def initialize cmd, args, status
|
|
|
|
@command = cmd
|
|
|
|
@args = args
|
|
|
|
args.map!{ |arg| arg.to_s.gsub " ", "\\ " }
|
|
|
|
super "#{cmd} #{args.join ' '}\nDownloader failed with exit status #{status}"
|
|
|
|
@exit_status = status
|
|
|
|
end
|
|
|
|
end
|