Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 375 lines (337 sloc) 11.719 kb
84c5c3e @mxcl The core tree, and some formulae
mxcl authored
1 #!/usr/bin/ruby
b539e96 @bmaland Sort the output from `brew install`
bmaland authored
2 # -*- coding: utf-8 -*-
725a699 @imbriaco Fix brew if it's symlinked from elsewhere
imbriaco authored
3
7be9788 @mxcl Don't look broken if CWD doesn't exist
mxcl authored
4 # Many Pathname operations use getwd when they shouldn't, and then throw
5 # odd exceptions. Reduce our support burden by showing a user-friendly error.
6 Dir.getwd rescue abort "The current working directory doesn't exist, cannot proceed."
7
d81a8e6 @mxcl Simplify the library path determination code a little
mxcl authored
8 HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] = File.expand_path(__FILE__)
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
9
d81a8e6 @mxcl Simplify the library path determination code a little
mxcl authored
10 require 'pathname'
5e15e92 @adamv Remove silly concatenation.
adamv authored
11 HOMEBREW_LIBRARY_PATH = (Pathname.new(__FILE__).realpath.dirname.parent+"Library/Homebrew").to_s
b5d132e @mxcl We can't rely on the $: order
mxcl authored
12 $:.unshift(HOMEBREW_LIBRARY_PATH)
2b22c47 @mxcl Allow formulae to use __END__
mxcl authored
13 require 'global'
6b6d369 @mxcl Refactor
mxcl authored
14
629c4e3 @mxcl Handle certain ARGV parameters before certain error checks
mxcl authored
15 case ARGV.first
246f44d @adamv Also allow 'brew help'.
adamv authored
16 when '-h', '--help', '--usage', '-?', 'help', nil
629c4e3 @mxcl Handle certain ARGV parameters before certain error checks
mxcl authored
17 puts ARGV.usage
18 exit 0
19 when '--version'
20 puts HOMEBREW_VERSION
21 exit 0
22 when '-v'
23 if ARGV.length > 1
24 puts "Homebrew #{HOMEBREW_VERSION}"
25 # continue in verbose mode
26 ARGV << ARGV.shift
27 else
28 puts HOMEBREW_VERSION
29 exit 0
30 end
31 end
32
33 case HOMEBREW_PREFIX.to_s when '/', '/usr'
34 # it may work, but I only see pain this route and don't want to support it
35 abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
d614113 @mxcl Refactor Formulae
mxcl authored
36 end
deeb33a @mxcl Use MACOS_VERSION in bin/brew
mxcl authored
37 if MACOS_VERSION < 10.5
8101b09 @adamv Link to pcc and tiger branches.
adamv authored
38 abort "Homebrew requires Leopard or higher. For Tiger support, see:\nhttp://github.com/sceaga/homebrew/tree/tiger"
ed1fed4 @mxcl Error out if the host OS X is too old
mxcl authored
39 end
68108e1 @mxcl Dependency resolution with fancy syntax
mxcl authored
40
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
41 def dump_config
de1ebbe @adamv Add OS X, Ruby, compiler & hardware info to --config
adamv authored
42 require 'hardware'
ef39ada @adamv Move some helper functions into Hardware
adamv authored
43 bits = Hardware.bits
44 cores = Hardware.cores_as_words
709dcb9 @mxcl My idea of tidy, sorry Adam…
mxcl authored
45 llvm = llvm_build
74fa194 Add GCC 4.0 info to --config output.
Robert Shaw authored
46 gcc_42 = gcc_42_build
47 gcc_40 = gcc_40_build
fb9c8cc @mxcl cd HOMEBREW_REPOSITORY before trying to git info it
mxcl authored
48 sha = `cd #{HOMEBREW_REPOSITORY} && git rev-parse --verify HEAD 2> /dev/null`.chomp
c078840 @mxcl Show kernel architecture in brew --config output
mxcl authored
49 kernel_arch = `uname -m`.chomp
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
50
de1ebbe @adamv Add OS X, Ruby, compiler & hardware info to --config
adamv authored
51 puts <<-EOS
52 HOMEBREW_VERSION: #{HOMEBREW_VERSION}
0c550e1 @mxcl Include HEAD SHA with brew --config
mxcl authored
53 HEAD: #{sha}
709dcb9 @mxcl My idea of tidy, sorry Adam…
mxcl authored
54 HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}
55 HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}
56 HOMEBREW_CACHE: #{HOMEBREW_CACHE}
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
57 HOMEBREW_REPOSITORY: #{HOMEBREW_REPOSITORY}
b5d132e @mxcl We can't rely on the $: order
mxcl authored
58 HOMEBREW_LIBRARY_PATH: #{HOMEBREW_LIBRARY_PATH}
709dcb9 @mxcl My idea of tidy, sorry Adam…
mxcl authored
59 Hardware: #{cores}-core #{bits}-bit #{Hardware.intel_family}
de1ebbe @adamv Add OS X, Ruby, compiler & hardware info to --config
adamv authored
60 OS X: #{MACOS_FULL_VERSION}
c078840 @mxcl Show kernel architecture in brew --config output
mxcl authored
61 Kernel Architecture: #{kernel_arch}
de1ebbe @adamv Add OS X, Ruby, compiler & hardware info to --config
adamv authored
62 Ruby: #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}
9afb7a3 @adamv Move recommended compiler versions into constants.
adamv authored
63 GCC-4.0: #{gcc_40 ? "build #{gcc_40}" : "N/A"} (#{RECOMMENDED_GCC_40} or newer recommended)
64 GCC-4.2: #{gcc_42 ? "build #{gcc_42}" : "N/A"} (#{RECOMMENDED_GCC_42} or newer recommended)
65 LLVM: #{llvm ? "build #{llvm}" : "N/A" } #{llvm ? "(#{RECOMMENDED_LLVM} or newer recommended)" : "" }
a905313 @mxcl Include macports or fink info with brew --config
mxcl authored
66 MacPorts or Fink? #{macports_or_fink_installed?}
79766ed @adamv Detect X11 when ENV.x11 is requested; dump in --config.
adamv authored
67 X11 installed? #{x11_installed?}
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
68 EOS
69 end
70
d614113 @mxcl Refactor Formulae
mxcl authored
71 begin
629c4e3 @mxcl Handle certain ARGV parameters before certain error checks
mxcl authored
72 require 'brew.h'
73
72edfbf @mxcl brew install improvements
mxcl authored
74 case arg = ARGV.shift
d55635a @adamv Move --cache command down near --prefix and use AGRV.formulae.
adamv authored
75 when '--cache'
76 if ARGV.named.empty?
77 puts HOMEBREW_CACHE
78 else
79 puts *ARGV.formulae.collect {|f| f.cached_download rescue '(built from source control)'}
80 end
629c4e3 @mxcl Handle certain ARGV parameters before certain error checks
mxcl authored
81 when '--prefix'
b063279 @mkhl Add support for `brew --prefix [formula ...]`.
mkhl authored
82 if ARGV.named.empty?
83 puts HOMEBREW_PREFIX
84 else
85 puts *ARGV.formulae.collect {|f| f.prefix}
86 end
75b8a06 @adamv Some bulletproofing for bash completion script.
adamv authored
87 when '--repository'
88 puts HOMEBREW_REPOSITORY
0887360 @adamv Add `brew --cellar` command.
adamv authored
89 when '--cellar'
52e46c8 @adamv Add "brew --cellar (formula)"
adamv authored
90 if ARGV.named.empty?
91 puts HOMEBREW_CELLAR
92 else
93 puts *ARGV.formulae.collect {|f| HOMEBREW_CELLAR+f.name}
94 end
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
95 when '--config'
96 dump_config
a22bf17 @adamv Add command "brew --env"
adamv authored
97 when '--env'
98 require 'hardware'
99 require 'extend/ENV'
100 ENV.extend(HomebrewEnvExtension)
101 ENV.setup_build_environment
102 dump_build_env ENV
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
103
df793f7 @adamv brew home foo open's foo's homepage in default web-browser
adamv authored
104 when 'home', 'homepage'
39b392d @mxcl Don't throw if named.empty?
mxcl authored
105 if ARGV.named.empty?
6b6d369 @mxcl Refactor
mxcl authored
106 exec "open", HOMEBREW_WWW
107 else
108 exec "open", *ARGV.formulae.collect {|f| f.homepage}
109 end
df793f7 @adamv brew home foo open's foo's homepage in default web-browser
adamv authored
110
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
111 when 'ls', 'list'
61b3aea brew list --unbrewed
Kieran Pilkington authored
112 if ARGV.flag? '--unbrewed'
a18bc0f @mxcl brew list --unbrewed fix
mxcl authored
113 dirs = HOMEBREW_PREFIX.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
114 dirs -= ['Library', 'Cellar', '.git']
115 Dir.chdir HOMEBREW_PREFIX
116 exec 'find', *dirs + %w[-type f ( ! -iname .ds_store ! -iname brew )]
083e2a4 @adamv `brew list --versions [formulae]`
adamv authored
117 elsif ARGV.flag? '--versions'
118 if ARGV.named.empty?
119 to_list = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }
120 else
121 to_list = ARGV.named.collect { |n| HOMEBREW_CELLAR+n }.select { |pn| pn.exist? }
122 end
123 to_list.each do |d|
124 versions = d.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
125 puts "#{d.basename} #{versions *' '}"
126 end
39b392d @mxcl Don't throw if named.empty?
mxcl authored
127 elsif ARGV.named.empty?
e3cd5d6 @mxcl brew ls with no further ARGV lists all installed kegs
mxcl authored
128 ENV['CLICOLOR']=nil
87d770d @mxcl Fixes #78
mxcl authored
129 exec 'ls', *ARGV.options<<HOMEBREW_CELLAR if HOMEBREW_CELLAR.exist?
36aacf7 @mxcl Don't summarize brew list if piped to another command
mxcl authored
130 elsif ARGV.verbose? or not $stdout.tty?
e3cd5d6 @mxcl brew ls with no further ARGV lists all installed kegs
mxcl authored
131 exec "find", *ARGV.kegs+%w[-not -type d -print]
e698609 @mxcl Summarised listings with brew list
mxcl authored
132 else
133 ARGV.kegs.each { |keg| PrettyListing.new keg }
e3cd5d6 @mxcl brew ls with no further ARGV lists all installed kegs
mxcl authored
134 end
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
135
c853b5f @indirect `brew search' command
indirect authored
136 when 'search', '-S'
bd57166 @adamv Add fink/macports support to 'brew search'.
adamv authored
137 if ARGV.include? '--macports'
138 exec "open", "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
139 elsif ARGV.include? '--fink'
140 exec "open", "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
141 end
142
d9820d9 @mxcl Prompt user to use pip for Hg and Bzr
mxcl authored
143 check_for_blacklisted_formula(ARGV.named)
66a98d9 @adamv Extract search_brews method
adamv authored
144 puts_columns search_brews(ARGV.first)
c853b5f @indirect `brew search' command
indirect authored
145
7dfe55d @mxcl brew edit and brew macports commmands
mxcl authored
146 when 'edit'
39b392d @mxcl Don't throw if named.empty?
mxcl authored
147 if ARGV.named.empty?
e23a612 @scoates Use ENV[EDITOR] if possible
scoates authored
148 # EDITOR isn't a good fit here, we need a GUI client that actually has
149 # a UI for projects, so apologies if this wasn't what you expected,
150 # please improve it! :)
ce01313 @adamv Rewrite of HOMEBREW_ folder locations
adamv authored
151 exec 'mate', *Dir["#{HOMEBREW_REPOSITORY}/Library/*"]<<
152 "#{HOMEBREW_REPOSITORY}/bin/brew"<<
153 "#{HOMEBREW_REPOSITORY}/README.md"
8f3ff69 @adamv Fix when 'edit' if/else indentation
adamv authored
154 else
155 # we don't use ARGV.formulae as that will throw if the file doesn't parse
156 paths = ARGV.named.collect do |name|
157 unless File.exist? path = "#{HOMEBREW_REPOSITORY}/Library/Formula/#{name}.rb"
158 require 'formula'
159 raise FormulaUnavailableError, name
160 else
161 path
162 end
8e676a3 @mxcl brew edit works if the file in question won't parse
mxcl authored
163 end
8f3ff69 @adamv Fix when 'edit' if/else indentation
adamv authored
164 exec_editor *paths
7dfe55d @mxcl brew edit and brew macports commmands
mxcl authored
165 end
166
b2fd885 @mxcl Brew update will git init if required
mxcl authored
167 when 'up', 'update'
8f0261a @adamv Reduce nesting in 'brew up'.
adamv authored
168 abort "Please `brew install git' first." unless system "/usr/bin/which -s git"
169
170 require 'update'
171 updater = RefreshBrew.new
172 unless updater.update_from_masterbrew!
173 puts "Already up-to-date."
174 else
ebd958b @adamv Show changed examples on update [telemachus]
adamv authored
175 updater.report
b2fd885 @mxcl Brew update will git init if required
mxcl authored
176 end
871b25c @alloy Update Homebrew and list the updated formulae.
alloy authored
177
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
178 when 'ln', 'link'
6b6d369 @mxcl Refactor
mxcl authored
179 ARGV.kegs.each {|keg| puts "#{keg.link} links created for #{keg}"}
180
181 when 'unlink'
182 ARGV.kegs.each {|keg| puts "#{keg.unlink} links removed for #{keg}"}
cc611b1 @mxcl Fix typos
mxcl authored
183
6b6d369 @mxcl Refactor
mxcl authored
184 when 'rm', 'uninstall', 'remove'
185 ARGV.kegs.each do |keg|
186 puts "Uninstalling #{keg}..."
bc9ab14 @mxcl Faster uninstall
mxcl authored
187 keg.unlink
d83fe25 @mxcl Unlink before uninstalling
mxcl authored
188 keg.uninstall
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
189 end
6b6d369 @mxcl Refactor
mxcl authored
190
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
191 when 'prune'
6b6d369 @mxcl Refactor
mxcl authored
192 prune
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
193
f414bc8 @mxcl `brew make' becomes `brew create'
mxcl authored
194 # 'make' supported until 0.7 for historic reasons
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
195 when 'mk', 'make'
f414bc8 @mxcl `brew make' becomes `brew create'
mxcl authored
196 opoo "`brew make' has changed to `brew create'"
197 puts "This is because make can be confused with the `make' tool."
198 puts "brew make will continue working until Homebrew 0.7"
199 exec __FILE__, "create", *ARGV
200
201 when 'create'
6b6d369 @mxcl Refactor
mxcl authored
202 if ARGV.include? '--macports'
203 exec "open", "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
03269c6 @adamv Add "brew create --fink"
adamv authored
204 elsif ARGV.include? '--fink'
205 exec "open", "http://pdb.finkproject.org/pdb/browse.php?summary=#{ARGV.next}"
39b392d @mxcl Don't throw if named.empty?
mxcl authored
206 elsif ARGV.named.empty?
207 raise UsageError
616ab25 @mxcl With brew mk, open with mate if available
mxcl authored
208 else
ecf4d95 @mxcl Only create named arguments
mxcl authored
209 exec_editor *ARGV.named.collect {|name| make name}
616ab25 @mxcl With brew mk, open with mate if available
mxcl authored
210 end
211
50453ee @mxcl Allow configure alias for diy
mxcl authored
212 when 'diy', 'configure'
bfbcdb2 @mxcl brew diy command
mxcl authored
213 puts diy
214
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
215 when 'info', 'abv'
39b392d @mxcl Don't throw if named.empty?
mxcl authored
216 if ARGV.named.empty?
c1d91ef @adamv Add command 'brew info --all'.
adamv authored
217 if ARGV.include? "--all"
218 require 'formula'
219 Formulary.names.each do |name|
b460166 @adamv Fix brew info --all
adamv authored
220 info Formula.factory(name)
c1d91ef @adamv Add command 'brew info --all'.
adamv authored
221 puts '---'
222 end
223 else
224 puts `ls #{HOMEBREW_CELLAR} | wc -l`.strip+" kegs, "+HOMEBREW_CELLAR.abv
225 end
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
226 elsif ARGV[0][0..6] == 'http://'
d458df7 @adamv Add name to brew info url and remove external script
adamv authored
227 path = Pathname.new(ARGV.shift)
228 /(.*?)[-_.]?#{path.version}/.match path.basename
229 unless $1.to_s.empty?
230 name = $1
231 else
232 name = path.stem
233 end
234 puts "#{name} #{path.version}"
23f9fad @mxcl brew info provides installation status
mxcl authored
235 else
12db100 @mxcl brew.h info takes a formula parameter rather than a string
mxcl authored
236 ARGV.formulae.each{ |f| info f }
dac062e @mxcl Handle -- args properly
mxcl authored
237 end
3cf1226 @mxcl Refactor--object orientate where sensible
mxcl authored
238
ffd3983 @josh Add cleanup command
josh authored
239 when 'cleanup'
240 if ARGV.named.empty?
241 require 'formula'
f5960cc @mxcl Use Ruby rather than external commands
mxcl authored
242 HOMEBREW_CELLAR.children.each do |rack|
c1679de @indirect Don't abort cleanup if formulae are missing
indirect authored
243 begin
244 cleanup(rack.basename.to_s) if rack.directory?
245 rescue FormulaUnavailableError => e
246 opoo "Formula not found for #{e.name}"
247 end
ffd3983 @josh Add cleanup command
josh authored
248 end
73264f4 @mkhl Fix `brew cleanup`: less pruning
mkhl authored
249 prune # seems like a good time to do some additional cleanup
ffd3983 @josh Add cleanup command
josh authored
250 else
251 ARGV.named.each { |name| cleanup name}
252 end
253
72edfbf @mxcl brew install improvements
mxcl authored
254 when 'install'
d9820d9 @mxcl Prompt user to use pip for Hg and Bzr
mxcl authored
255 check_for_blacklisted_formula(ARGV.named)
9670e0e @adamv Extract "brew_install".
adamv authored
256 brew_install
72edfbf @mxcl brew install improvements
mxcl authored
257
f2a6979 @mxcl brew log command
mxcl authored
258 when 'log'
a772101 @mxcl Use HOMEBREW_REPOSITORY for brew log
mxcl authored
259 Dir.chdir HOMEBREW_REPOSITORY
2988f1e @mxcl Plain `brew log` shows the entire Homebrew git log
mxcl authored
260 args = ARGV.options
261 args.unshift ARGV.formulae.first.path unless ARGV.named.empty?
262 exec "git", "log", *args
c6ce363 @mxcl Significantly simpler `brew uses` and `brew deps`
mxcl authored
263
264 # For each formula given, show which other formulas depend on it.
265 # We only go one level up, ie. direct dependencies.
62cef23 @adamv Add brew command 'uses'
adamv authored
266 when 'uses'
c6ce363 @mxcl Significantly simpler `brew uses` and `brew deps`
mxcl authored
267 puts *ARGV.formulae.map{ |f| Formula.all.select{ |ff| ff.deps.include? f.name }.map(&:name) }.flatten.uniq.sort
268
b6ca4dc @adamv New command 'brew deps [formula]'
adamv authored
269 when 'deps'
c6ce363 @mxcl Significantly simpler `brew uses` and `brew deps`
mxcl authored
270 require 'formula_installer'
271 if ARGV.include?("-1") or ARGV.include?("--1")
272 puts *ARGV.formulae.map{ |f| f.deps or [] }.flatten.uniq.sort
273 else
274 puts *ARGV.formulae.map{ |f| FormulaInstaller.expand_deps(f).map(&:name) }.flatten.uniq.sort
b6ca4dc @adamv New command 'brew deps [formula]'
adamv authored
275 end
c6ce363 @mxcl Significantly simpler `brew uses` and `brew deps`
mxcl authored
276
c477846 brew: add 'cat' command
Alexander Solovyov authored
277 when 'cat'
278 Dir.chdir HOMEBREW_REPOSITORY
279 exec "cat", ARGV.formulae.first.path, *ARGV.options
280
9cf6840 @mxcl brew outdated
mxcl authored
281 when 'outdated'
14946db @adamv Move code to find outdated brew list
adamv authored
282 outdated_brews.each do |keg, name, version|
283 if $stdout.tty? and not ARGV.flag? '--quiet'
284 versions = keg.cd{ Dir['*'] }.join(', ')
285 puts "#{name} (#{versions} < #{version})"
286 else
287 puts name
9cf6840 @mxcl brew outdated
mxcl authored
288 end
289 end
290
60796b7 @mxcl `brew doctor`
mxcl authored
291 when 'doctor'
5b83d26 @adamv Move brew doctor to its own source file; will get bigger.
adamv authored
292 require 'brew_doctor'
60796b7 @mxcl `brew doctor`
mxcl authored
293 brew_doctor
294
f2a6979 @mxcl brew log command
mxcl authored
295 else
2e8d07b @mkhl Automatically enable external `brew` commands.
mkhl authored
296 # Add example external commands to PATH before checking.
297 ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/examples"
298
fafcaae @adamv Support external commands
adamv authored
299 # Check for an external shell command
300 if system "/usr/bin/which -s brew-#{arg}"
301 # Add some Homebrew vars to the ENV
302 ['CACHE', 'CELLAR', 'LIBRARY_PATH', 'PREFIX', 'REPOSITORY'].each do |e|
303 ENV["HOMEBREW_#{e}"] = eval("HOMEBREW_#{e}")
304 end
305 exec("brew-#{arg}", *ARGV)
306 end
307
308 # Check for an external ruby command
309 external_rb = `/usr/bin/which brew-#{arg}.rb`.chomp
310 unless external_rb.empty?
311 require external_rb
312 exit 0
313 end
314
315 # Check for git commands
70d984b @adamv Tweak the bin/brew command selector a bit.
adamv authored
316 if ['branch', 'checkout', 'pull', 'push', 'rebase', 'reset'].include? arg
317 onoe "Unknown command: #{arg} (did you mean 'git #{arg}'?)"
318 else
319 onoe "Unknown command: #{arg}"
320 end
d614113 @mxcl Refactor Formulae
mxcl authored
321 end
2a5a754 @mxcl brew prefix command
mxcl authored
322
1b066d7 @mxcl Better errors if missing keg or formula arguments
mxcl authored
323 rescue FormulaUnspecifiedError
a785a5e @mxcl dump_config for certain exceptions
mxcl authored
324 abort "This command requires a formula argument"
1b066d7 @mxcl Better errors if missing keg or formula arguments
mxcl authored
325 rescue KegUnspecifiedError
a785a5e @mxcl dump_config for certain exceptions
mxcl authored
326 abort "This command requires a keg argument"
ea7c891 @mxcl Raise if ARGV.named and no named arguments
mxcl authored
327 rescue UsageError
328 onoe "Invalid usage"
a785a5e @mxcl dump_config for certain exceptions
mxcl authored
329 abort ARGV.usage
6b6d369 @mxcl Refactor
mxcl authored
330 rescue SystemExit
f0eb547 @mxcl Fixed SIGINT handling, so we can have our newline
mxcl authored
331 puts "Kernel.exit" if ARGV.verbose?
1912cbb @mxcl Re-raise SystemExit so the correct exit code is set
mxcl authored
332 raise
6b6d369 @mxcl Refactor
mxcl authored
333 rescue Interrupt => e
f0eb547 @mxcl Fixed SIGINT handling, so we can have our newline
mxcl authored
334 puts # seemingly a newline is typical
6b6d369 @mxcl Refactor
mxcl authored
335 exit 130
70bed07 @mxcl More tweaking of main exception handler output
mxcl authored
336 rescue BuildError => e
5bae3b5 @mxcl Puts URL for failed build line
mxcl authored
337 e.backtrace[1] =~ %r{Library/Formula/(.+)\.rb:(\d+)}
d9dc06a @mxcl Check GitHub for issues relating to build failures
mxcl authored
338 formula_name = $1
7d83880 @adamv Add a snapshot of ENV to BuildError and show some flags with the stack t...
adamv authored
339 error_line = $2
340 puts "Exit status: #{e.exit_status}"
341 puts
342 puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{error_line}"
343 puts
70bed07 @mxcl More tweaking of main exception handler output
mxcl authored
344 ohai "Environment"
345 dump_config
7d83880 @adamv Add a snapshot of ENV to BuildError and show some flags with the stack t...
adamv authored
346 puts
347 ohai "Build Flags"
348 dump_build_env e.env
70bed07 @mxcl More tweaking of main exception handler output
mxcl authored
349 onoe e
350 puts PLEASE_REPORT_BUG
d9dc06a @mxcl Check GitHub for issues relating to build failures
mxcl authored
351 # this feature can be slow (depends on network conditions and if github is up)
aee8618 @adamv Fix typo in comment.
adamv authored
352 # so ideally we'd show feedback, eg. "checking for existing issues..." and
d9dc06a @mxcl Check GitHub for issues relating to build failures
mxcl authored
353 # then replace that string with the following when the github api returns
354 issues = issues_for_formula(formula_name)
355 puts "These existing issues may help you:", *issues unless issues.empty?
7a12e2c @adamv Failures during ./configure should mention config.log.
adamv authored
356 if e.was_running_configure?
357 puts "It looks like an autotools configure failed."
358 puts "Consider re-running the install with '-vd' to keep 'config.log' around:"
8011f97 @kylef When outputting a `brew install -vd` insert the formula name
kylef authored
359 puts " brew install -vd #{formula_name}"
7a12e2c @adamv Failures during ./configure should mention config.log.
adamv authored
360 puts "Gist 'config.log' and any error output when reporting an issue."
361 end
362 puts
59c2fb4 @adamv Publicize 'brew doctor' in build failure message.
adamv authored
363 puts "Consider running `brew doctor` if a large number of installs are failing."
70bed07 @mxcl More tweaking of main exception handler output
mxcl authored
364 exit 1
365 rescue RuntimeError, SystemCallError => e
366 onoe e
367 puts e.backtrace if ARGV.debug?
368 exit 1
6b6d369 @mxcl Refactor
mxcl authored
369 rescue Exception => e
a785a5e @mxcl dump_config for certain exceptions
mxcl authored
370 onoe e
70bed07 @mxcl More tweaking of main exception handler output
mxcl authored
371 puts PLEASE_REPORT_BUG
372 puts e.backtrace
419cf71 @mxcl Return non-zero error code on errors
mxcl authored
373 exit 1
118b41b @mxcl Refactor $foo into HOMEBREW_FOO
mxcl authored
374 end
Something went wrong with that request. Please try again.