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,6 +1,6 @@
class Cleaner
def initialize f
@f=f
@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?
@ -24,6 +24,7 @@ class Cleaner
end
private
def strip path, args=''
return if @f.skip_clean? path
puts "strip #{path}" if ARGV.verbose?
@ -49,9 +50,8 @@ private
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
@ -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

@ -14,8 +14,10 @@ module Homebrew extend self
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"
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

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

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)