diff --git a/Library/Contributions/examples/brew-fetch.rb b/Library/Contributions/examples/brew-fetch.rb index 28606e3fd0..336dc839f0 100755 --- a/Library/Contributions/examples/brew-fetch.rb +++ b/Library/Contributions/examples/brew-fetch.rb @@ -17,7 +17,6 @@ ARGV.formulae.each do |f| puts "MD5: #{the_tarball.md5}" puts "SHA1: #{the_tarball.sha1}" - puts unless previous_md5.nil? or the_tarball.md5 == previous_md5 opoo "Formula reports different MD5: #{previous_md5}" diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb index f19efc23ba..070f35b811 100644 --- a/Library/Homebrew/cleaner.rb +++ b/Library/Homebrew/cleaner.rb @@ -1,7 +1,7 @@ class Cleaner def initialize f - @f=f - [f.bin, f.sbin, f.lib].select{|d|d.exist?}.each{|d|clean_dir d} + @f = Formula.factory f + [f.bin, f.sbin, f.lib].select{ |d| d.exist? }.each{ |d| clean_dir d } unless ENV['HOMEBREW_KEEP_INFO'].nil? f.info.rmtree if f.info.directory? and not f.skip_clean? f.info @@ -23,7 +23,8 @@ class Cleaner end end -private + private + def strip path, args='' return if @f.skip_clean? path puts "strip #{path}" if ARGV.verbose? @@ -46,18 +47,17 @@ private end def clean_file path - perms=0444 + perms = 0444 case `file -h '#{path}'` when /Mach-O dynamically linked shared library/ - # Stripping libraries is causing no end of trouble - # Lets just give up, and try to do it manually in instances where it - # makes sense + # Stripping libraries is causing no end of trouble. Lets just give up, + # and try to do it manually in instances where it makes sense. #strip path, '-SxX' when /Mach-O [^ ]* ?executable/ strip path - perms=0555 + perms = 0555 when /script text executable/ - perms=0555 + perms = 0555 end path.chmod perms end @@ -68,9 +68,9 @@ private Find.prune if @f.skip_clean? path elsif not path.file? next - elsif path.extname == '.la' and not @f.skip_clean? path + elsif path.extname == '.la' # *.la files are stupid - path.unlink + path.unlink unless @f.skip_clean? path elsif not path.symlink? clean_file path end diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 4096ebff8e..5580eaeebe 100755 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -206,33 +206,33 @@ def audit_formula_instance f end module Homebrew extend self -def audit - ff.each do |f| - problems = [] - problems += audit_formula_instance f - problems += audit_formula_urls f + def audit + ff.each do |f| + problems = [] + problems += audit_formula_instance f + problems += audit_formula_urls f - text = "" - File.open(f.path, "r") { |afile| text = afile.read } + text = "" + File.open(f.path, "r") { |afile| text = afile.read } - # DATA with no __END__ - if (text =~ /\bDATA\b/) and not (text =~ /^\s*__END__\s*$/) - problems << " * 'DATA' was found, but no '__END__'" - end + # DATA with no __END__ + if (text =~ /\bDATA\b/) and not (text =~ /^\s*__END__\s*$/) + problems << " * 'DATA' was found, but no '__END__'" + end - problems += [' * invalid or missing version'] if f.version.to_s.empty? + problems += [' * invalid or missing version'] if f.version.to_s.empty? - # Don't try remaining audits on text in __END__ - text_without_patch = (text.split("__END__")[0]).strip() + # Don't try remaining audits on text in __END__ + text_without_patch = (text.split("__END__")[0]).strip() - problems += audit_formula_text(text_without_patch) - problems += audit_formula_options(f, text_without_patch) + problems += audit_formula_text(text_without_patch) + problems += audit_formula_options(f, text_without_patch) - unless problems.empty? - puts "#{f.name}:" - puts problems * "\n" - puts + unless problems.empty? + puts "#{f.name}:" + puts problems * "\n" + puts + end end end end -end diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb index bad3a5dc07..7ea616d763 100644 --- a/Library/Homebrew/cmd/doctor.rb +++ b/Library/Homebrew/cmd/doctor.rb @@ -584,50 +584,50 @@ def check_for_other_vars end module Homebrew extend self -def doctor - read, write = IO.pipe + def doctor + read, write = IO.pipe - if fork == nil - read.close - $stdout.reopen write + if fork == nil + read.close + $stdout.reopen write - check_usr_bin_ruby - check_homebrew_prefix - check_for_macgpg2 - check_for_stray_dylibs - check_gcc_versions - check_cc_symlink - check_for_other_package_managers - check_for_x11 - check_for_nonstandard_x11 - check_access_share_locale - check_access_share_man - check_access_include - check_access_etc - check_user_path - check_which_pkg_config - check_pkg_config_paths - check_access_pkgconfig - check_for_gettext - check_for_config_scripts - check_for_dyld_vars - check_for_other_vars - check_for_symlinked_cellar - check_for_multiple_volumes - check_for_git - check_for_autoconf - check_for_linked_kegonly_brews + check_usr_bin_ruby + check_homebrew_prefix + check_for_macgpg2 + check_for_stray_dylibs + check_gcc_versions + check_cc_symlink + check_for_other_package_managers + check_for_x11 + check_for_nonstandard_x11 + check_access_share_locale + check_access_share_man + check_access_include + check_access_etc + check_user_path + check_which_pkg_config + check_pkg_config_paths + check_access_pkgconfig + check_for_gettext + check_for_config_scripts + check_for_dyld_vars + check_for_other_vars + check_for_symlinked_cellar + check_for_multiple_volumes + check_for_git + check_for_autoconf + check_for_linked_kegonly_brews - exit! 0 - else - write.close - - unless (out = read.read).chomp.empty? - puts out + exit! 0 else - puts "Your OS X is ripe for brewing." - puts "Any troubles you may be experiencing are likely purely psychosomatic." + write.close + + unless (out = read.read).chomp.empty? + puts out + else + puts "Your OS X is ripe for brewing." + puts "Any troubles you may be experiencing are likely purely psychosomatic." + end end end end -end diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 2102d2182b..d1b4519c67 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -13,15 +13,17 @@ module Homebrew extend self end def check_ppc - case Hardware.cpu_type when :ppc, :dunno - abort "Sorry, Homebrew does not support your computer's CPU architecture.\n"+ - "For PPC support, see: http://github.com/sceaga/homebrew/tree/powerpc" - end + case Hardware.cpu_type when :ppc, :dunno + abort <<-EOS.undent + Sorry, Homebrew does not support your computer's CPU architecture. + For PPC support, see: http://github.com/sceaga/homebrew/tree/powerpc + EOS + end end def check_writable_install_location - raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable? - raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable? + raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable? + raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable? end def check_cc diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 76776c94c8..370035ea61 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -18,7 +18,7 @@ module HomebrewArgvExtension require 'keg' require 'formula' @kegs ||= downcased_unique_named.collect do |name| - d = HOMEBREW_CELLAR + Formula.resolve_alias(name) + d = HOMEBREW_CELLAR/Formula.resolve_alias(name) dirs = d.children.select{ |pn| pn.directory? } rescue [] raise NoSuchKegError.new(name) if not d.directory? or dirs.length == 0 raise MultipleVersionsInstalledError.new(name) if dirs.length > 1 diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 3cc1024e7c..56e4ad4ea8 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -10,12 +10,12 @@ ARGV.extend(HomebrewArgvExtension) HOMEBREW_VERSION = '0.7.1' HOMEBREW_WWW = 'http://mxcl.github.com/homebrew/' -if Process.uid == 0 +HOMEBREW_CACHE = if Process.uid == 0 # technically this is not the correct place, this cache is for *all users* # so in that case, maybe we should always use it, root or not? - HOMEBREW_CACHE=Pathname.new("/Library/Caches/Homebrew") + Pathname.new("/Library/Caches/Homebrew") else - HOMEBREW_CACHE=Pathname.new("~/Library/Caches/Homebrew").expand_path + Pathname.new("~/Library/Caches/Homebrew").expand_path end if not defined? HOMEBREW_BREW_FILE @@ -27,10 +27,10 @@ HOMEBREW_REPOSITORY = Pathname.new(HOMEBREW_BREW_FILE).realpath.dirname.parent # # Where we store built products; /usr/local/Cellar if it exists, # otherwise a Cellar relative to the Repository. -if (HOMEBREW_PREFIX+'Cellar').exist? - HOMEBREW_CELLAR = HOMEBREW_PREFIX+'Cellar' +HOMEBREW_CELLAR = if (HOMEBREW_PREFIX/"Cellar").exist? + HOMEBREW_PREFIX/"Cellar" else - HOMEBREW_CELLAR = HOMEBREW_REPOSITORY+'Cellar' + HOMEBREW_REPOSITORY/"Cellar" end MACOS_FULL_VERSION = `/usr/bin/sw_vers -productVersion`.chomp diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 6b338ea836..880d9081f9 100755 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -10,7 +10,7 @@ def text_for_keg_only_formula f rationale = "The formula didn't provide any rationale for this." end <<-EOS -This formula is keg-only, so it is not symlinked into Homebrew's prefix. +This formula is keg-only. This means it is not symlinked into #{HOMEBREW_PREFIX}. #{rationale} Generally there are no consequences of this for you, however if you build @@ -137,10 +137,10 @@ def install f show_summary_heading = true else # warn the user if stuff was installed outside of their PATH - paths = ENV['PATH'].split(':').collect{|p| File.expand_path p} + paths = ENV['PATH'].split(':').map{ |p| File.expand_path p } [f.bin, f.sbin].each do |bin| if bin.directory? - rootbin = (HOMEBREW_PREFIX+bin.basename).to_s + rootbin = (HOMEBREW_PREFIX/bin.basename).to_s bin = File.expand_path bin unless paths.include? rootbin opoo "#{rootbin} is not in your PATH" @@ -151,7 +151,7 @@ def install f end # Check for man pages that aren't in share/man - if (f.prefix+'man').exist? + if (f.prefix/:man).exist? opoo 'A top-level "man" folder was found.' puts "Homebrew requires that man pages live under share." puts 'This can often be fixed by passing "--mandir=#{man}" to configure.' diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb index 086297dd25..010c06761d 100644 --- a/Library/Homebrew/test/test_bucket.rb +++ b/Library/Homebrew/test/test_bucket.rb @@ -173,7 +173,7 @@ class BeerTasting < Test::Unit::TestCase end def test_pathname_properties - foo1=HOMEBREW_CACHE+'foo-0.1.tar.gz' + foo1 = HOMEBREW_CACHE/'foo-0.1.tar.gz' assert_equal '.tar.gz', foo1.extname assert_equal 'foo-0.1', foo1.stem diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index e478670fb4..f1d62ffe1e 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -1,4 +1,3 @@ - class Tty class < e formula_name = $1 error_line = $2 - puts "Exit status: #{e.exit_status}" - puts + ohai "Exit Status: #{e.exit_status}" puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{error_line}" - puts ohai "Environment" puts Homebrew.config_s - puts ohai "Build Flags" Homebrew.dump_build_env e.env + puts onoe e puts PLEASE_REPORT_BUG # this feature can be slow (depends on network conditions and if github is up)