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
|
2012-03-16 11:55:30 +00:00
|
|
|
attr :dependent, true
|
|
|
|
|
|
|
|
def dependent_s
|
|
|
|
"(dependency of #{dependent})" if dependent and dependent != name
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2012-03-17 00:20:37 +00:00
|
|
|
if name =~ %r{(\w+)/(\w+)/([^/]+)} then <<-EOS.undent
|
2012-03-16 11:55:30 +00:00
|
|
|
No available formula for #$3 #{dependent_s}
|
|
|
|
Please tap it and then try again: brew tap #$1/#$2
|
|
|
|
EOS
|
|
|
|
else
|
|
|
|
"No available formula for #{name} #{dependent_s}"
|
|
|
|
end
|
|
|
|
end
|
2010-11-12 20:59:53 -08:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
def initialize name
|
|
|
|
@name = 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
|
|
|
|
|
2012-03-07 11:16:27 +00:00
|
|
|
class CannotInstallFormulaError < RuntimeError
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
|
|
|
|
def message
|
|
|
|
"Formula installation already attempted: #{formula}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-23 17:06:38 -07:00
|
|
|
class UnsatisfiedRequirements < Homebrew::InstallationError
|
|
|
|
attr :reqs
|
|
|
|
|
|
|
|
def initialize formula, reqs
|
|
|
|
@reqs = reqs
|
|
|
|
message = (reqs.length == 1) \
|
|
|
|
? "An unsatisfied requirement failed this build." \
|
|
|
|
: "Unsatisifed requirements failed this build."
|
|
|
|
super formula, message
|
2010-09-11 20:22:54 +01:00
|
|
|
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
|
2012-03-07 11:11:05 +00:00
|
|
|
|
|
|
|
def dump
|
2012-09-11 20:59:59 -04:00
|
|
|
logs = "#{ENV['HOME']}/Library/Logs/Homebrew/#{formula}/"
|
2012-09-27 15:39:16 -04:00
|
|
|
if ARGV.verbose?
|
|
|
|
require 'cmd/--config'
|
|
|
|
require 'cmd/--env'
|
|
|
|
ohai "Configuration"
|
|
|
|
Homebrew.dump_build_config
|
|
|
|
ohai "ENV"
|
|
|
|
Homebrew.dump_build_env(env)
|
|
|
|
end
|
2012-08-13 09:50:15 -04:00
|
|
|
puts
|
2012-09-11 20:59:59 -04:00
|
|
|
onoe "#{formula.name} did not build"
|
|
|
|
puts "Logs: #{logs}" unless Dir["#{logs}/*"].empty?
|
2012-09-28 19:20:34 +01:00
|
|
|
puts "Help: #{Tty.em}#{ISSUES_URL}#{Tty.reset}"
|
2012-09-11 20:59:59 -04:00
|
|
|
issues = GitHub.issues_for_formula(formula.name)
|
|
|
|
puts *issues.map{ |s| " #{Tty.em}#{s}#{Tty.reset}" } unless issues.empty?
|
2012-03-07 11:11:05 +00:00
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised in CurlDownloadStrategy.fetch
|
|
|
|
class CurlDownloadStrategyError < RuntimeError
|
|
|
|
end
|
2011-09-14 12:18:35 -07:00
|
|
|
|
2011-09-19 23:29:07 +01:00
|
|
|
# raised by safe_system in utils.rb
|
|
|
|
class ErrorDuringExecution < RuntimeError
|
2011-09-14 12:18:35 -07:00
|
|
|
end
|
2012-06-18 19:58:35 -05:00
|
|
|
|
2012-07-17 11:31:53 -05:00
|
|
|
# raised by Pathname#verify_checksum when "expected" is nil or empty
|
2012-06-18 19:58:35 -05:00
|
|
|
class ChecksumMissingError < ArgumentError
|
|
|
|
end
|
|
|
|
|
|
|
|
# raised by Pathname#verify_checksum when verification fails
|
|
|
|
class ChecksumMismatchError < RuntimeError
|
|
|
|
attr :advice, true
|
|
|
|
attr :expected
|
|
|
|
attr :actual
|
2012-06-26 00:51:02 -05:00
|
|
|
attr :hash_type
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
def initialize expected, actual
|
|
|
|
@expected = expected
|
|
|
|
@actual = actual
|
2012-06-26 00:51:02 -05:00
|
|
|
@hash_type = expected.hash_type.to_s.upcase
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
super <<-EOS.undent
|
2012-06-26 00:51:02 -05:00
|
|
|
#{@hash_type} mismatch
|
|
|
|
Expected: #{@expected}
|
|
|
|
Actual: #{@actual}
|
2012-06-18 19:58:35 -05:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
2012-07-17 11:30:28 -05:00
|
|
|
super + advice.to_s
|
2012-06-18 19:58:35 -05:00
|
|
|
end
|
|
|
|
end
|
2012-08-10 09:33:33 -04:00
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
SUDO_BAD_ERRMSG = <<-EOS.undent
|
|
|
|
You can use brew with sudo, but only if the brew executable is owned by root.
|
|
|
|
However, this is both not recommended and completely unsupported so do so at
|
|
|
|
your own risk.
|
|
|
|
EOS
|
|
|
|
end
|