2009-08-31 16:01:36 +01:00
|
|
|
# Copyright 2009 Max Howell and other contributors.
|
2009-08-10 16:48:30 +01:00
|
|
|
#
|
2009-08-31 16:01:36 +01:00
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
2009-08-10 16:48:30 +01:00
|
|
|
#
|
2009-08-31 16:01:36 +01:00
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
2009-08-10 16:48:30 +01:00
|
|
|
#
|
2009-08-31 16:01:36 +01:00
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2009-08-10 16:48:30 +01:00
|
|
|
#
|
2009-09-30 17:45:14 +01:00
|
|
|
FORMULA_META_FILES = %w[README ChangeLog COPYING LICENSE COPYRIGHT AUTHORS]
|
2009-11-12 01:33:14 +00:00
|
|
|
PLEASE_REPORT_BUG = "#{Tty.white}Please report this bug to #{Tty.em}#{HOMEBREW_WWW}#{Tty.reset}"
|
2009-09-30 17:45:14 +01:00
|
|
|
|
2009-09-28 17:01:44 +01:00
|
|
|
def __make url, name
|
2009-08-10 16:48:30 +01:00
|
|
|
require 'formula'
|
|
|
|
|
2009-09-28 17:01:44 +01:00
|
|
|
path = Formula.path name
|
2009-08-10 16:48:30 +01:00
|
|
|
raise "#{path} already exists" if path.exist?
|
2009-11-16 15:31:15 -08:00
|
|
|
|
|
|
|
# Check if a formula aliased to this name exists.
|
|
|
|
already_aka = Formulary.find_alias name
|
|
|
|
if already_aka != nil
|
|
|
|
opoo "Formula #{already_aka} is aliased to #{name}."
|
|
|
|
puts "Please check if you are creating a duplicate."
|
|
|
|
end
|
2009-08-10 16:48:30 +01:00
|
|
|
|
|
|
|
template=<<-EOS
|
2009-10-15 09:07:12 +01:00
|
|
|
require 'formula'
|
2009-08-10 16:48:30 +01:00
|
|
|
|
2009-09-28 17:01:44 +01:00
|
|
|
class #{Formula.class_s name} <Formula
|
2009-09-24 18:49:49 +01:00
|
|
|
url '#{url}'
|
2009-10-07 14:17:16 +01:00
|
|
|
homepage ''
|
2009-09-24 18:49:49 +01:00
|
|
|
md5 ''
|
|
|
|
|
|
|
|
cmake depends_on 'cmake'
|
2009-08-10 16:48:30 +01:00
|
|
|
|
|
|
|
def install
|
2009-08-31 22:05:42 +01:00
|
|
|
autotools system "./configure", "--prefix=\#{prefix}", "--disable-debug", "--disable-dependency-tracking"
|
2009-09-24 18:49:49 +01:00
|
|
|
cmake system "cmake . \#{std_cmake_parameters}"
|
2009-08-10 16:48:30 +01:00
|
|
|
system "make install"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
|
|
|
|
mode=nil
|
|
|
|
if ARGV.include? '--cmake'
|
|
|
|
mode= :cmake
|
|
|
|
elsif ARGV.include? '--autotools'
|
|
|
|
mode= :autotools
|
|
|
|
end
|
|
|
|
|
|
|
|
f=File.new path, 'w'
|
|
|
|
template.each_line do |s|
|
|
|
|
if s.strip.empty?
|
|
|
|
f.puts
|
|
|
|
next
|
|
|
|
end
|
|
|
|
cmd=s[0..11].strip
|
|
|
|
if cmd.empty?
|
|
|
|
cmd=nil
|
|
|
|
else
|
|
|
|
cmd=cmd.to_sym
|
|
|
|
end
|
|
|
|
out=s[12..-1] || ''
|
|
|
|
|
|
|
|
if mode.nil?
|
|
|
|
# we show both but comment out cmake as it is less common
|
|
|
|
# the implication being the pacakger should remove whichever is not needed
|
|
|
|
if cmd == :cmake and not out.empty?
|
|
|
|
f.print '#'
|
|
|
|
out = out[1..-1]
|
|
|
|
end
|
|
|
|
elsif cmd != mode and not cmd.nil?
|
|
|
|
next
|
|
|
|
end
|
|
|
|
f.puts out
|
|
|
|
end
|
|
|
|
f.close
|
|
|
|
|
|
|
|
return path
|
|
|
|
end
|
|
|
|
|
2009-09-28 17:01:44 +01:00
|
|
|
def make url
|
|
|
|
path = Pathname.new url
|
|
|
|
|
|
|
|
/(.*?)[-_.]?#{path.version}/.match path.basename
|
|
|
|
|
|
|
|
unless $1.to_s.empty?
|
|
|
|
name = $1
|
|
|
|
else
|
|
|
|
print "Formula name [#{path.stem}]: "
|
|
|
|
gots = $stdin.gets.chomp
|
|
|
|
if gots.empty?
|
|
|
|
name = path.stem
|
|
|
|
else
|
|
|
|
name = gots
|
|
|
|
end
|
|
|
|
end
|
2009-10-01 15:42:36 +01:00
|
|
|
|
2009-10-15 16:34:23 +01:00
|
|
|
force_text = "If you really want to make this formula use --force."
|
|
|
|
|
|
|
|
case name.downcase
|
2009-10-23 14:50:41 +01:00
|
|
|
when /libxml/, /libxlst/, /freetype/, /libpng/, /wxwidgets/
|
2009-10-01 15:42:36 +01:00
|
|
|
raise <<-EOS
|
|
|
|
#{name} is blacklisted for creation
|
|
|
|
Apple distributes this library with OS X, you can find it in /usr/X11/lib.
|
|
|
|
However not all build scripts look here, so you may need to call ENV.x11 or
|
|
|
|
ENV.libxml2 in your formula's install function.
|
2009-10-15 16:34:23 +01:00
|
|
|
|
|
|
|
#{force_text}
|
2009-10-01 15:42:36 +01:00
|
|
|
EOS
|
2009-11-06 15:06:42 +00:00
|
|
|
when /rubygem/
|
|
|
|
raise "Sorry RubyGems comes with OS X so we don't package it.\n\n#{force_text}"
|
2009-10-15 16:34:23 +01:00
|
|
|
end unless ARGV.force?
|
2009-10-01 15:42:36 +01:00
|
|
|
|
2009-09-28 17:01:44 +01:00
|
|
|
__make url, name
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
def info name
|
|
|
|
require 'formula'
|
|
|
|
|
2009-09-02 10:42:57 +01:00
|
|
|
user=''
|
2009-09-23 16:44:10 +01:00
|
|
|
user=`git config --global github.user`.chomp if system "/usr/bin/which -s git"
|
2009-08-31 18:33:40 +02:00
|
|
|
user='mxcl' if user.empty?
|
2009-09-18 14:32:21 +01:00
|
|
|
# FIXME it would be nice if we didn't assume the default branch is master
|
|
|
|
history="http://github.com/#{user}/homebrew/commits/master/Library/Formula/#{Formula.path(name).basename}"
|
2009-08-31 18:33:40 +02:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
exec 'open', history if ARGV.flag? '--github'
|
|
|
|
|
|
|
|
f=Formula.factory name
|
|
|
|
puts "#{f.name} #{f.version}"
|
|
|
|
puts f.homepage
|
|
|
|
|
2009-10-17 02:46:39 -04:00
|
|
|
if not f.deps.empty?
|
|
|
|
puts "Depends on: #{f.deps.join(', ')}"
|
|
|
|
end
|
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
if f.prefix.parent.directory?
|
|
|
|
kids=f.prefix.parent.children
|
|
|
|
kids.each do |keg|
|
|
|
|
print "#{keg} (#{keg.abv})"
|
|
|
|
print " *" if f.prefix == keg and kids.length > 1
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
else
|
|
|
|
puts "Not installed"
|
|
|
|
end
|
|
|
|
|
|
|
|
if f.caveats
|
|
|
|
puts
|
|
|
|
puts f.caveats
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
|
|
|
|
puts history
|
|
|
|
|
|
|
|
rescue FormulaUnavailableError
|
|
|
|
# check for DIY installation
|
|
|
|
d=HOMEBREW_PREFIX+name
|
|
|
|
if d.directory?
|
|
|
|
ohai "DIY Installation"
|
|
|
|
d.children.each {|keg| puts "#{keg} (#{keg.abv})"}
|
|
|
|
else
|
|
|
|
raise "No such formula or keg"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def clean f
|
|
|
|
Cleaner.new f
|
2009-09-21 16:12:01 -07:00
|
|
|
|
|
|
|
# Hunt for empty folders and nuke them unless they are
|
2009-09-22 11:38:22 +01:00
|
|
|
# protected by f.skip_clean?
|
2009-09-21 16:12:01 -07:00
|
|
|
# We want post-order traversal, so put the dirs in a stack
|
|
|
|
# and then pop them off later.
|
2009-09-22 11:38:22 +01:00
|
|
|
paths = []
|
|
|
|
f.prefix.find do |path|
|
|
|
|
paths << path if path.directory?
|
2009-09-21 16:12:01 -07:00
|
|
|
end
|
2009-09-22 11:38:22 +01:00
|
|
|
|
2009-09-21 16:12:01 -07:00
|
|
|
until paths.empty? do
|
2009-09-22 11:38:22 +01:00
|
|
|
d = paths.pop
|
|
|
|
if d.children.empty? and not f.skip_clean? d
|
|
|
|
puts "rmdir: #{d} (empty)" if ARGV.verbose?
|
|
|
|
d.rmdir
|
2009-09-21 16:12:01 -07:00
|
|
|
end
|
|
|
|
end
|
2009-08-10 16:48:30 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-09-18 19:16:39 +01:00
|
|
|
def expand_deps ff
|
Dependency resolution
Specify dependencies in your formula's deps function. You can return an Array,
String or Hash, eg:
def deps
{ :optional => 'libogg', :required => %w[flac sdl], :recommended => 'cmake' }
end
Note currently the Hash is flattened and qualifications are ignored. If you
only return an Array or String, the qualification is assumed to be :required.
Other packaging systems have problems when it comes to packages requiring a
specific version of a package, or some patches that may not work well with
other software. With Homebrew we have some options:
1. If the formula is vanilla but an older version we can cherry-pick the old
version and install it in the Cellar in parallel, but just not symlink it
into /usr/local while forcing the formula that depends on it to link to
that one and not any other versions of it.
2. If the dependency requires patches then we shouldn't install this for use
by any other tools, (I guess this needs to be decided on a per-situation
basis). It can be installed into the parent formula's prefix, and not
symlinked into /usr/local. In this case the dependency's Formula
derivation should be saved in the parent formula's file (check git or
flac for an example of this).
Both the above can be done currently with hacks, so I'll flesh out a proper
way sometime this week.
2009-09-07 01:06:08 +01:00
|
|
|
deps = []
|
2009-09-18 19:16:39 +01:00
|
|
|
ff.deps.collect do |f|
|
|
|
|
deps += expand_deps(Formula.factory(f))
|
Dependency resolution
Specify dependencies in your formula's deps function. You can return an Array,
String or Hash, eg:
def deps
{ :optional => 'libogg', :required => %w[flac sdl], :recommended => 'cmake' }
end
Note currently the Hash is flattened and qualifications are ignored. If you
only return an Array or String, the qualification is assumed to be :required.
Other packaging systems have problems when it comes to packages requiring a
specific version of a package, or some patches that may not work well with
other software. With Homebrew we have some options:
1. If the formula is vanilla but an older version we can cherry-pick the old
version and install it in the Cellar in parallel, but just not symlink it
into /usr/local while forcing the formula that depends on it to link to
that one and not any other versions of it.
2. If the dependency requires patches then we shouldn't install this for use
by any other tools, (I guess this needs to be decided on a per-situation
basis). It can be installed into the parent formula's prefix, and not
symlinked into /usr/local. In this case the dependency's Formula
derivation should be saved in the parent formula's file (check git or
flac for an example of this).
Both the above can be done currently with hacks, so I'll flesh out a proper
way sometime this week.
2009-09-07 01:06:08 +01:00
|
|
|
end
|
2009-09-18 19:16:39 +01:00
|
|
|
deps << ff
|
Dependency resolution
Specify dependencies in your formula's deps function. You can return an Array,
String or Hash, eg:
def deps
{ :optional => 'libogg', :required => %w[flac sdl], :recommended => 'cmake' }
end
Note currently the Hash is flattened and qualifications are ignored. If you
only return an Array or String, the qualification is assumed to be :required.
Other packaging systems have problems when it comes to packages requiring a
specific version of a package, or some patches that may not work well with
other software. With Homebrew we have some options:
1. If the formula is vanilla but an older version we can cherry-pick the old
version and install it in the Cellar in parallel, but just not symlink it
into /usr/local while forcing the formula that depends on it to link to
that one and not any other versions of it.
2. If the dependency requires patches then we shouldn't install this for use
by any other tools, (I guess this needs to be decided on a per-situation
basis). It can be installed into the parent formula's prefix, and not
symlinked into /usr/local. In this case the dependency's Formula
derivation should be saved in the parent formula's file (check git or
flac for an example of this).
Both the above can be done currently with hacks, so I'll flesh out a proper
way sometime this week.
2009-09-07 01:06:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
def prune
|
|
|
|
$n=0
|
|
|
|
$d=0
|
|
|
|
|
|
|
|
dirs=Array.new
|
2009-08-12 09:43:16 +08:00
|
|
|
paths=%w[bin sbin etc lib include share].collect {|d| HOMEBREW_PREFIX+d}
|
2009-08-10 16:48:30 +01:00
|
|
|
|
|
|
|
paths.each do |path|
|
|
|
|
path.find do |path|
|
|
|
|
path.extend ObserverPathnameExtension
|
|
|
|
if path.symlink?
|
|
|
|
path.unlink unless path.resolved_path_exists?
|
|
|
|
elsif path.directory?
|
|
|
|
dirs<<path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
dirs.sort.reverse_each {|d| d.rmdir_if_possible}
|
|
|
|
|
|
|
|
if $n == 0 and $d == 0
|
|
|
|
puts "Nothing pruned" if ARGV.verbose?
|
|
|
|
else
|
|
|
|
# always showing symlinks text is deliberate
|
|
|
|
print "Pruned #{$n} symbolic links "
|
2009-08-08 14:10:32 +01:00
|
|
|
print "and #{$d} directories " if $d > 0
|
2009-08-10 16:48:30 +01:00
|
|
|
puts "from #{HOMEBREW_PREFIX}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-12 13:43:51 +01:00
|
|
|
def diy
|
|
|
|
path=Pathname.getwd
|
|
|
|
|
2009-08-22 17:09:42 +01:00
|
|
|
if ARGV.include? '--set-version'
|
|
|
|
version=ARGV.next
|
|
|
|
else
|
|
|
|
version=path.version
|
|
|
|
raise "Couldn't determine version, try --set-version" if version.nil? or version.empty?
|
|
|
|
end
|
|
|
|
|
|
|
|
if ARGV.include? '--set-name'
|
|
|
|
name=ARGV.next
|
|
|
|
else
|
|
|
|
path.basename.to_s =~ /(.*?)-?#{version}/
|
|
|
|
if $1.nil? or $1.empty?
|
|
|
|
name=path.basename
|
|
|
|
else
|
|
|
|
name=$1
|
|
|
|
end
|
|
|
|
end
|
2009-08-12 13:43:51 +01:00
|
|
|
|
|
|
|
prefix=HOMEBREW_CELLAR+name+version
|
|
|
|
|
|
|
|
if File.file? 'CMakeLists.txt'
|
|
|
|
"-DCMAKE_INSTALL_PREFIX=#{prefix}"
|
|
|
|
elsif File.file? 'Makefile.am'
|
|
|
|
"--prefix=#{prefix}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-10-26 18:14:39 +00:00
|
|
|
def macports_or_fink_installed?
|
2009-09-27 23:55:40 +01:00
|
|
|
# See these issues for some history:
|
|
|
|
# http://github.com/mxcl/homebrew/issues/#issue/13
|
2009-09-28 12:53:10 +13:00
|
|
|
# http://github.com/mxcl/homebrew/issues/#issue/41
|
2009-09-27 23:55:40 +01:00
|
|
|
# http://github.com/mxcl/homebrew/issues/#issue/48
|
2009-10-26 18:14:39 +00:00
|
|
|
|
2009-09-27 23:55:40 +01:00
|
|
|
%w[port fink].each do |ponk|
|
|
|
|
path = `/usr/bin/which -s #{ponk}`
|
2009-10-26 18:14:39 +00:00
|
|
|
return ponk unless path.empty?
|
2009-09-23 16:41:47 +01:00
|
|
|
end
|
2009-10-26 18:14:39 +00:00
|
|
|
|
2009-09-27 23:55:40 +01:00
|
|
|
# we do the above check because macports can be relocated and fink may be
|
|
|
|
# able to be relocated in the future. This following check is because if
|
|
|
|
# fink and macports are not in the PATH but are still installed it can
|
|
|
|
# *still* break the build -- because some build scripts hardcode these paths:
|
|
|
|
%w[/sw/bin/fink /opt/local/bin/port].each do |ponk|
|
2009-10-26 18:14:39 +00:00
|
|
|
return ponk if File.exist? ponk
|
2009-09-27 23:55:40 +01:00
|
|
|
end
|
2009-10-26 18:14:39 +00:00
|
|
|
|
|
|
|
# finally, sometimes people make their MacPorts or Fink read-only so they
|
2009-09-27 23:55:40 +01:00
|
|
|
# can quickly test Homebrew out, but still in theory obey the README's
|
|
|
|
# advise to rename the root directory. This doesn't work, many build scripts
|
|
|
|
# error out when they try to read from these now unreadable directories.
|
|
|
|
%w[/sw /opt/local].each do |path|
|
2009-10-26 18:14:39 +00:00
|
|
|
path = Pathname.new(path)
|
|
|
|
return path if path.exist? and not path.readable?
|
2009-09-23 16:41:47 +01:00
|
|
|
end
|
2009-10-26 18:14:39 +00:00
|
|
|
|
|
|
|
false
|
2009-09-23 16:41:47 +01:00
|
|
|
end
|
2009-09-24 21:46:04 +01:00
|
|
|
|
2009-09-25 19:04:34 +12:00
|
|
|
def versions_of(keg_name)
|
|
|
|
`ls #{HOMEBREW_CELLAR}/#{keg_name}`.collect { |version| version.strip }.reverse
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-09-24 21:46:04 +01:00
|
|
|
########################################################## class PrettyListing
|
|
|
|
class PrettyListing
|
|
|
|
def initialize path
|
|
|
|
Pathname.new(path).children.sort{ |a,b| a.to_s.downcase <=> b.to_s.downcase }.each do |pn|
|
|
|
|
case pn.basename.to_s
|
|
|
|
when 'bin', 'sbin'
|
|
|
|
pn.find { |pnn| puts pnn unless pnn.directory? }
|
|
|
|
when 'lib'
|
|
|
|
print_dir pn do |pnn|
|
|
|
|
# dylibs have multiple symlinks and we don't care about them
|
|
|
|
(pnn.extname == '.dylib' or pnn.extname == '.pc') and not pnn.symlink?
|
|
|
|
end
|
|
|
|
else
|
2009-09-30 17:45:14 +01:00
|
|
|
if pn.directory?
|
|
|
|
print_dir pn
|
|
|
|
elsif not FORMULA_META_FILES.include? pn.basename.to_s
|
|
|
|
puts pn
|
|
|
|
end
|
2009-09-24 21:46:04 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def print_dir root
|
|
|
|
dirs = []
|
|
|
|
remaining_root_files = []
|
|
|
|
other = ''
|
|
|
|
|
|
|
|
root.children.sort.each do |pn|
|
|
|
|
if pn.directory?
|
|
|
|
dirs << pn
|
|
|
|
elsif block_given? and yield pn
|
|
|
|
puts pn
|
|
|
|
other = 'other '
|
|
|
|
else
|
|
|
|
remaining_root_files << pn
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
dirs.each do |d|
|
|
|
|
files = []
|
|
|
|
d.find { |pn| files << pn unless pn.directory? }
|
|
|
|
print_remaining_files files, d
|
|
|
|
end
|
|
|
|
|
|
|
|
print_remaining_files remaining_root_files, root, other
|
|
|
|
end
|
|
|
|
|
|
|
|
def print_remaining_files files, root, other = ''
|
|
|
|
case files.length
|
|
|
|
when 0
|
|
|
|
# noop
|
|
|
|
when 1
|
|
|
|
puts *files
|
|
|
|
else
|
2009-09-30 00:27:15 +01:00
|
|
|
puts "#{root}/ (#{files.length} #{other}files)"
|
2009-09-24 21:46:04 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
################################################################ class Cleaner
|
|
|
|
class Cleaner
|
|
|
|
def initialize f
|
|
|
|
@f=f
|
2009-08-10 11:16:03 +01:00
|
|
|
|
|
|
|
# correct common issues
|
|
|
|
share=f.prefix+'share'
|
|
|
|
(f.prefix+'man').mv share rescue nil
|
|
|
|
|
2009-08-12 09:43:16 +08:00
|
|
|
[f.bin, f.sbin, f.lib].each {|d| clean_dir d}
|
2009-08-08 14:02:22 +01:00
|
|
|
|
2009-08-31 18:23:41 +01:00
|
|
|
# you can read all of this stuff online nowadays, save the space
|
|
|
|
# info pages are pants, everyone agrees apart from Richard Stallman
|
|
|
|
# feel free to ask for build options though! http://bit.ly/Homebrew
|
2009-08-08 14:02:22 +01:00
|
|
|
(f.prefix+'share'+'doc').rmtree rescue nil
|
|
|
|
(f.prefix+'share'+'info').rmtree rescue nil
|
2009-08-10 11:16:03 +01:00
|
|
|
(f.prefix+'doc').rmtree rescue nil
|
2009-08-31 18:23:41 +01:00
|
|
|
(f.prefix+'docs').rmtree rescue nil
|
2009-08-10 11:16:03 +01:00
|
|
|
(f.prefix+'info').rmtree rescue nil
|
2009-08-10 16:48:30 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def strip path, args=''
|
|
|
|
return if @f.skip_clean? path
|
|
|
|
puts "strip #{path}" if ARGV.verbose?
|
|
|
|
path.chmod 0644 # so we can strip
|
|
|
|
unless path.stat.nlink > 1
|
|
|
|
`strip #{args} #{path}`
|
|
|
|
else
|
|
|
|
# strip unlinks the file and recreates it, thus breaking hard links!
|
2009-09-03 20:58:33 +01:00
|
|
|
# is this expected behaviour? patch does it too… still, this fixes it
|
2009-08-10 16:48:30 +01:00
|
|
|
tmp=`mktemp -t #{path.basename}`.strip
|
|
|
|
`strip #{args} -o #{tmp} #{path}`
|
|
|
|
`cat #{tmp} > #{path}`
|
|
|
|
File.unlink tmp
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def clean_file path
|
|
|
|
perms=0444
|
2009-09-27 20:18:06 +01:00
|
|
|
case `file -h '#{path}'`
|
2009-09-03 20:58:33 +01:00
|
|
|
when /Mach-O dynamically linked shared library/
|
|
|
|
strip path, '-SxX'
|
|
|
|
when /Mach-O [^ ]* ?executable/
|
|
|
|
strip path
|
|
|
|
perms=0555
|
|
|
|
when /script text executable/
|
|
|
|
perms=0555
|
2009-08-10 16:48:30 +01:00
|
|
|
end
|
|
|
|
path.chmod perms
|
|
|
|
end
|
|
|
|
|
|
|
|
def clean_dir d
|
|
|
|
d.find do |path|
|
2009-08-10 11:45:25 +01:00
|
|
|
if path.directory?
|
|
|
|
Find.prune if @f.skip_clean? path
|
|
|
|
elsif not path.file?
|
2009-08-10 16:48:30 +01:00
|
|
|
next
|
|
|
|
elsif path.extname == '.la' and not @f.skip_clean? path
|
|
|
|
# *.la files are stupid
|
|
|
|
path.unlink
|
2009-09-27 20:18:06 +01:00
|
|
|
elsif not path.symlink?
|
2009-08-10 16:48:30 +01:00
|
|
|
clean_file path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-11-09 18:47:26 +00:00
|
|
|
|
|
|
|
def gcc_build
|
|
|
|
`/usr/bin/gcc-4.2 -v 2>&1` =~ /build (\d{4,})/
|
|
|
|
$1.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def llvm_build
|
|
|
|
if MACOS_VERSION >= 10.6
|
|
|
|
`/Developer/usr/bin/llvm-gcc-4.2 -v 2>&1` =~ /LLVM build (\d{4,})/
|
|
|
|
$1.to_i
|
|
|
|
end
|
|
|
|
end
|