Some Cleanup

This commit is contained in:
Max Howell 2010-11-09 13:00:33 +00:00 committed by Adam Vandenberg
parent b13baedfd8
commit c1a3b724fd
11 changed files with 110 additions and 111 deletions

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.'

View File

@ -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

View File

@ -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:

View File

@ -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)