aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLibrary/Contributions/examples/brew-fetch.rb1
-rw-r--r--Library/Homebrew/cleaner.rb22
-rwxr-xr-xLibrary/Homebrew/cmd/audit.rb46
-rw-r--r--Library/Homebrew/cmd/doctor.rb86
-rw-r--r--Library/Homebrew/cmd/install.rb14
-rw-r--r--Library/Homebrew/extend/ARGV.rb2
-rw-r--r--Library/Homebrew/global.rb12
-rwxr-xr-xLibrary/Homebrew/install.rb8
-rw-r--r--Library/Homebrew/test/test_bucket.rb2
-rw-r--r--Library/Homebrew/utils.rb25
-rwxr-xr-xbin/brew13
11 files changed, 115 insertions, 116 deletions
diff --git a/Library/Contributions/examples/brew-fetch.rb b/Library/Contributions/examples/brew-fetch.rb
index 28606e3fd..336dc839f 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 f19efc23b..070f35b81 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 4096ebff8..5580eaeeb 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
-
- 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
+ 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 }
- problems += [' * invalid or missing version'] if f.version.to_s.empty?
+ # DATA with no __END__
+ if (text =~ /\bDATA\b/) and not (text =~ /^\s*__END__\s*$/)
+ problems << " * 'DATA' was found, but no '__END__'"
+ end
- # Don't try remaining audits on text in __END__
- text_without_patch = (text.split("__END__")[0]).strip()
+ problems += [' * invalid or missing version'] if f.version.to_s.empty?
- problems += audit_formula_text(text_without_patch)
- problems += audit_formula_options(f, text_without_patch)
+ # Don't try remaining audits on text in __END__
+ text_without_patch = (text.split("__END__")[0]).strip()
- unless problems.empty?
- puts "#{f.name}:"
- puts problems * "\n"
- puts
+ 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
+ end
end
end
end
-end
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index bad3a5dc0..7ea616d76 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
-
- 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
-
- exit! 0
- else
- write.close
-
- unless (out = read.read).chomp.empty?
- puts out
+ def doctor
+ read, write = IO.pipe
+
+ 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
+
+ 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 2102d2182..d1b4519c6 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 76776c94c..370035ea6 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 3cc1024e7..56e4ad4ea 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 6b338ea83..880d9081f 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 086297dd2..010c06761 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 e478670fb..f1d62ffe1 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -1,4 +1,3 @@
-
class Tty
class <<self
def blue; bold 34; end
@@ -41,6 +40,7 @@ def onoe error
puts lines unless lines.empty?
end
+
def pretty_duration s
return "2 seconds" if s < 3 # avoids the plural problem ;)
return "#{s.to_i} seconds" if s < 120
@@ -115,28 +115,25 @@ end
def exec_editor *args
editor = ENV['HOMEBREW_EDITOR'] || ENV['EDITOR']
if editor.nil?
- if system "/usr/bin/which -s mate"
- # TextMate
- editor='mate'
+ editor = if system "/usr/bin/which -s mate"
+ 'mate'
elsif system "/usr/bin/which -s edit"
- # BBEdit / TextWrangler
- editor='edit'
+ 'edit' # BBEdit / TextWrangler
else
- # Default to vim
- editor='/usr/bin/vim'
+ '/usr/bin/vim' # Default to vim
end
end
# we split the editor because especially on mac "mate -w" is common
# but we still want to use the comma-delimited version of exec because then
# we don't have to escape args, and escaping 100% is tricky
- exec(*(editor.split+args))
+ exec *(editor.split + args) unless args.empty?
end
-# GZips the given path, and returns the gzipped file
+# GZips the given paths, and returns the gzipped paths
def gzip *paths
paths.collect do |path|
system "/usr/bin/gzip", path
- Pathname.new(path+".gz")
+ Pathname.new("#{path}.gz")
end
end
@@ -242,9 +239,9 @@ module MacOS extend self
end
end
-def x11_installed?
- Pathname.new('/usr/X11/lib/libpng.dylib').exist?
-end
+ def x11_installed?
+ Pathname.new('/usr/X11/lib/libpng.dylib').exist?
+ end
def macports_or_fink_installed?
# See these issues for some history:
diff --git a/bin/brew b/bin/brew
index 645e933e4..e4fa968e5 100755
--- a/bin/brew
+++ b/bin/brew
@@ -8,7 +8,7 @@ Dir.getwd rescue abort "The current working directory doesn't exist, cannot proc
HOMEBREW_BREW_FILE = ENV['HOMEBREW_BREW_FILE'] = File.expand_path(__FILE__)
require 'pathname'
-HOMEBREW_LIBRARY_PATH = (Pathname.new(__FILE__).realpath.dirname.parent+"Library/Homebrew").to_s
+HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.dirname.parent.join("Library/Homebrew").to_s
$:.unshift(HOMEBREW_LIBRARY_PATH)
require 'global'
@@ -35,7 +35,10 @@ case HOMEBREW_PREFIX.to_s when '/', '/usr'
abort "Cowardly refusing to continue at this prefix: #{HOMEBREW_PREFIX}"
end
if MACOS_VERSION < 10.5
- abort "Homebrew requires Leopard or higher. For Tiger support, see:\nhttp://github.com/sceaga/homebrew/tree/tiger"
+ abort <<-EOABORT.undent
+ Homebrew requires Leopard or higher. For Tiger support, see:
+ http://github.com/sceaga/homebrew/tree/tiger
+ EOABORT
end
def require? path
@@ -104,15 +107,13 @@ rescue BuildError => 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)