aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brewkit.rb228
-rw-r--r--Library/Homebrew/extend/ARGV.rb (renamed from Library/Homebrew/ARGV+yeast.rb)2
-rw-r--r--Library/Homebrew/extend/ENV.rb207
-rw-r--r--Library/Homebrew/extend/pathname.rb (renamed from Library/Homebrew/pathname+yeast.rb)0
-rw-r--r--Library/Homebrew/global.rb7
-rwxr-xr-xLibrary/Homebrew/install.rb27
-rwxr-xr-xLibrary/Homebrew/test/formula_test.rb (renamed from Library/Homebrew/formula_test.rb)5
-rw-r--r--Library/Homebrew/test/testball-0.1.tbz (renamed from Library/Homebrew/testball-0.1.tbz)bin1400 -> 1400 bytes
-rwxr-xr-xLibrary/Homebrew/test/unittest.rb (renamed from Library/Homebrew/unittest.rb)9
-rw-r--r--Library/Homebrew/utils.rb14
10 files changed, 248 insertions, 251 deletions
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index 843ac023d..2668889d8 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -1,224 +1,4 @@
-# Copyright 2009 Max Howell and other contributors.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 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.
-#
-# 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.
-#
-
-# TODO
-# 1. Indeed, there should be an option to build 32 or 64 bit binaries
-# 2. Homebrew will not support building 32 and 64 bit lipo'd binaries, I
-# want to, but the simple fact is it is difficult to force most of the
-# build systems we support to do it.
-
-
-ENV['MACOSX_DEPLOYMENT_TARGET']=MACOS_VERSION.to_s
-
-unless HOMEBREW_PREFIX.to_s == '/usr/local'
- # /usr/local is always in the build system path so only add other paths
- ENV['CPPFLAGS'] = "-I#{HOMEBREW_PREFIX}/include"
- ENV['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
-else
- # ignore existing build vars, thus we should have less bugs to deal with
- ENV['CPPFLAGS'] = ''
- ENV['LDFLAGS'] = ''
-end
-
-if MACOS_VERSION >= 10.6 or ENV['HOMEBREW_USE_LLVM']
- # you can install Xcode wherever you like you know.
- prefix = `/usr/bin/xcode-select -print-path`.chomp
- prefix = "/Developer" if prefix.to_s.empty?
-
- ENV['CC'] = "#{prefix}/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2"
- ENV['CXX'] = "#{prefix}/usr/llvm-gcc-4.2/bin/llvm-g++-4.2"
- cflags = ['-O4'] # O4 baby!
-else
- ENV['CC']="gcc-4.2"
- ENV['CXX']="g++-4.2"
- cflags = ['-O3']
-end
-# in rare cases this may break your builds, as the tool for some reason wants
-# to use a specific linker, however doing this in general causes formula to
-# build more successfully because we are changing CC and many build systems
-# don't react properly to that
-ENV['LD']=ENV['CC']
-
-# optimise all the way to eleven, references:
-# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
-# http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
-# http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
-if MACOS_VERSION >= 10.6
- case Hardware.intel_family
- when :penryn, :core2
- # no need to add -mfpmath it happens automatically with 64 bit compiles
- cflags << "-march=core2"
- when :core
- cflags<<"-march=prescott"<<"-mfpmath=sse"
- end
-else
- case Hardware.intel_family
- when :penryn, :core2
- cflags<<"-march=nocona"
- when :core
- cflags<<"-march=prescott"
- end
- cflags<<"-mfpmath=sse"
-end
-cflags<<"-mmmx"
-case Hardware.intel_family
-when :nehalem
- cflags<<"-msse4.2"
-when :penryn
- cflags<<"-msse4.1"
-when :core2, :core
- cflags<<"-msse3"
-end
-
-# -w: keep signal to noise high
-# -fomit-frame-pointer: we are not debugging this software, we are using it
-BREWKIT_SAFE_FLAGS="-w -pipe -fomit-frame-pointer -mmacosx-version-min=#{MACOS_VERSION}"
-ENV['CFLAGS']=ENV['CXXFLAGS']="#{cflags*' '} #{BREWKIT_SAFE_FLAGS}"
-
-# compile faster
-ENV['MAKEFLAGS']="-j#{Hardware.processor_count}"
-
-
-# you can use these functions for packages that have build issues
-module HomebrewEnvExtension
- def deparallelize
- remove 'MAKEFLAGS', /-j\d+/
- end
- alias_method :j1, :deparallelize
- def gcc_4_0_1
- case MACOS_VERSION
- when 10.5
- self['CC']=nil
- self['CXX']=nil
- self['LD']=nil
- when 10.6..11.0
- self['CC']='gcc-4.0'
- self['CXX']='g++-4.0'
- self['LD']=self['CC']
- remove_from_cflags '-march=core2'
- self.O3
- end
- remove_from_cflags '-msse4.1'
- remove_from_cflags '-msse4.2'
- end
- def O3
- # Sometimes O4 just takes fucking forever
- remove_from_cflags '-O4'
- append_to_cflags '-O3'
- end
- def O2
- # Sometimes O3 doesn't work or produces bad binaries
- remove_from_cflags '-O4'
- remove_from_cflags '-O3'
- append_to_cflags '-O2'
- end
- def gcc_4_2
- # Sometimes you want to downgrade from LLVM to GCC 4.2
- self['CC']="gcc-4.2"
- self['CXX']="g++-4.2"
- self['LD']=self['CC']
- self.O3
- end
- def osx_10_4
- self['MACOSX_DEPLOYMENT_TARGET']=nil
- remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
- end
- def minimal_optimization
- self['CFLAGS']=self['CXXFLAGS']="-Os #{BREWKIT_SAFE_FLAGS}"
- end
- def no_optimization
- self['CFLAGS']=self['CXXFLAGS']=BREWKIT_SAFE_FLAGS
- end
- def libxml2
- append_to_cflags ' -I/usr/include/libxml2'
- end
- def x11
- # CPPFLAGS are the C-PreProcessor flags, *not* C++!
- append 'CPPFLAGS', '-I/usr/X11R6/include'
- append 'LDFLAGS', '-L/usr/X11R6/lib'
- end
- alias_method :libpng, :x11
- # we've seen some packages fail to build when warnings are disabled!
- def enable_warnings
- remove_from_cflags '-w'
- end
- # Snow Leopard defines an NCURSES value the opposite of most distros
- # See: http://bugs.python.org/issue6848
- def ncurses_define
- append 'CPPFLAGS', "-DNCURSES_OPAQUE=0"
- end
- # returns the compiler we're using
- def cc
- ENV['CC'] or "gcc"
- end
- def cxx
- ENV['cxx'] or "g++"
- end
- # in case you need it
- def m64
- append_to_cflags '-m64'
- ENV['LDFLAGS'] += '-arch x86_64'
- end
-
-private
- def append key, value
- ref=self[key]
- if ref.nil? or ref.empty?
- self[key]=value
- else
- self[key]=ref+' '+value
- end
- end
- def append_to_cflags f
- append 'CFLAGS', f
- append 'CXXFLAGS', f
- end
- def remove key, value
- return if self[key].nil?
- self[key]=self[key].sub value, '' # can't use sub! on ENV
- self[key]=nil if self[key].empty? # keep things clean
- end
- def remove_from_cflags f
- remove 'CFLAGS', f
- remove 'CXXFLAGS', f
- end
-end
-
-ENV.extend HomebrewEnvExtension
-
-
-# Clear CDPATH to avoid make issues that depend on changing directories
-ENV.delete('CDPATH')
-
-def inreplace(path, before, after)
- before=Regexp.escape before.to_s
- before.gsub! "/", "\\/" # I guess not escaped as delimiter varies
- after=after.to_s
- after.gsub! "\\", "\\\\"
- after.gsub! "/", "\\/"
- after.gsub! "$", "\\$"
-
- # FIXME use proper Ruby for teh exceptions!
- safe_system "/usr/bin/perl", "-pi", "-e", "s/#{before}/#{after}/g", path
-end
+require 'utils'
+opoo "brewkit.rb is deprecated please require 'formula' instead"
+puts "This file will be removed at version 0.7"
+require 'formula'
diff --git a/Library/Homebrew/ARGV+yeast.rb b/Library/Homebrew/extend/ARGV.rb
index 5616039b3..b8ccbda53 100644
--- a/Library/Homebrew/ARGV+yeast.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -114,5 +114,3 @@ private
end
class UsageError <RuntimeError; end
-
-ARGV.extend HomebrewArgvExtension
diff --git a/Library/Homebrew/extend/ENV.rb b/Library/Homebrew/extend/ENV.rb
new file mode 100644
index 000000000..d87825dbe
--- /dev/null
+++ b/Library/Homebrew/extend/ENV.rb
@@ -0,0 +1,207 @@
+# Copyright 2009 Max Howell and other contributors.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 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.
+#
+# 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.
+#
+
+module HomebrewEnvExtension
+ # -w: keep signal to noise high
+ # -fomit-frame-pointer: we are not debugging this software, we are using it
+ SAFE_CFLAGS_FLAGS = "-w -pipe -fomit-frame-pointer -mmacosx-version-min=#{MACOS_VERSION}"
+
+ def setup_build_environment
+ # Clear CDPATH to avoid make issues that depend on changing directories
+ ENV.delete('CDPATH')
+
+ ENV['MACOSX_DEPLOYMENT_TARGET']=MACOS_VERSION.to_s
+ ENV['MAKEFLAGS']="-j#{Hardware.processor_count}"
+
+ unless HOMEBREW_PREFIX.to_s == '/usr/local'
+ # /usr/local is always in the build system path so only add other paths
+ ENV['CPPFLAGS'] = "-I#{HOMEBREW_PREFIX}/include"
+ ENV['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
+ else
+ # ignore existing build vars, thus we should have less bugs to deal with
+ ENV['CPPFLAGS'] = ''
+ ENV['LDFLAGS'] = ''
+ end
+
+ if MACOS_VERSION >= 10.6 or ENV['HOMEBREW_USE_LLVM']
+ # you can install Xcode wherever you like you know.
+ prefix = `/usr/bin/xcode-select -print-path`.chomp
+ prefix = "/Developer" if prefix.to_s.empty?
+
+ ENV['CC'] = "#{prefix}/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2"
+ ENV['CXX'] = "#{prefix}/usr/llvm-gcc-4.2/bin/llvm-g++-4.2"
+ cflags = ['-O4'] # O4 baby!
+ else
+ ENV['CC']="gcc-4.2"
+ ENV['CXX']="g++-4.2"
+ cflags = ['-O3']
+ end
+ # in rare cases this may break your builds, as the tool for some reason wants
+ # to use a specific linker, however doing this in general causes formula to
+ # build more successfully because we are changing CC and many build systems
+ # don't react properly to that
+ ENV['LD']=ENV['CC']
+
+ # optimise all the way to eleven, references:
+ # http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
+ # http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
+ # http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
+ if MACOS_VERSION >= 10.6
+ case Hardware.intel_family
+ when :penryn, :core2
+ # no need to add -mfpmath it happens automatically with 64 bit compiles
+ cflags << "-march=core2"
+ when :core
+ cflags<<"-march=prescott"<<"-mfpmath=sse"
+ end
+ else
+ case Hardware.intel_family
+ when :penryn, :core2
+ cflags<<"-march=nocona"
+ when :core
+ cflags<<"-march=prescott"
+ end
+ cflags<<"-mfpmath=sse"
+ end
+ cflags<<"-mmmx"
+ case Hardware.intel_family
+ when :nehalem
+ cflags<<"-msse4.2"
+ when :penryn
+ cflags<<"-msse4.1"
+ when :core2, :core
+ cflags<<"-msse3"
+ end
+
+ ENV['CFLAGS']=ENV['CXXFLAGS']="#{cflags*' '} #{SAFE_CFLAGS_FLAGS}"
+ end
+
+ def deparallelize
+ remove 'MAKEFLAGS', /-j\d+/
+ end
+ alias_method :j1, :deparallelize
+ def gcc_4_0_1
+ case MACOS_VERSION
+ when 10.5
+ self['CC']=nil
+ self['CXX']=nil
+ self['LD']=nil
+ when 10.6..11.0
+ self['CC']='gcc-4.0'
+ self['CXX']='g++-4.0'
+ self['LD']=self['CC']
+ remove_from_cflags '-march=core2'
+ self.O3
+ end
+ remove_from_cflags '-msse4.1'
+ remove_from_cflags '-msse4.2'
+ end
+ def O3
+ # Sometimes O4 just takes fucking forever
+ remove_from_cflags '-O4'
+ append_to_cflags '-O3'
+ end
+ def O2
+ # Sometimes O3 doesn't work or produces bad binaries
+ remove_from_cflags '-O4'
+ remove_from_cflags '-O3'
+ append_to_cflags '-O2'
+ end
+ def gcc_4_2
+ # Sometimes you want to downgrade from LLVM to GCC 4.2
+ self['CC']="gcc-4.2"
+ self['CXX']="g++-4.2"
+ self['LD']=self['CC']
+ self.O3
+ end
+ def osx_10_4
+ self['MACOSX_DEPLOYMENT_TARGET']=nil
+ remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/)
+ end
+ def minimal_optimization
+ self['CFLAGS']=self['CXXFLAGS']="-Os #{SAFE_CFLAGS_FLAGS}"
+ end
+ def no_optimization
+ self['CFLAGS']=self['CXXFLAGS'] = SAFE_CFLAGS_FLAGS
+ end
+ def libxml2
+ append_to_cflags ' -I/usr/include/libxml2'
+ end
+ def x11
+ # CPPFLAGS are the C-PreProcessor flags, *not* C++!
+ append 'CPPFLAGS', '-I/usr/X11R6/include'
+ append 'LDFLAGS', '-L/usr/X11R6/lib'
+ end
+ alias_method :libpng, :x11
+ # we've seen some packages fail to build when warnings are disabled!
+ def enable_warnings
+ remove_from_cflags '-w'
+ end
+ # Snow Leopard defines an NCURSES value the opposite of most distros
+ # See: http://bugs.python.org/issue6848
+ def ncurses_define
+ append 'CPPFLAGS', "-DNCURSES_OPAQUE=0"
+ end
+ # returns the compiler we're using
+ def cc
+ ENV['CC'] or "gcc"
+ end
+ def cxx
+ ENV['cxx'] or "g++"
+ end
+ # in case you need it
+ def m64
+ append_to_cflags '-m64'
+ ENV['LDFLAGS'] += '-arch x86_64'
+ end
+
+ def prepend key, value, separator = ' '
+ unless self[key].to_s.empty?
+ self[key] = value + separator + self[key]
+ else
+ self[key] = value
+ end
+ end
+ def append key, value
+ ref=self[key]
+ if ref.nil? or ref.empty?
+ self[key]=value
+ else
+ self[key]=ref+' '+value
+ end
+ end
+ def append_to_cflags f
+ append 'CFLAGS', f
+ append 'CXXFLAGS', f
+ end
+ def remove key, value
+ return if self[key].nil?
+ self[key]=self[key].sub value, '' # can't use sub! on ENV
+ self[key]=nil if self[key].empty? # keep things clean
+ end
+ def remove_from_cflags f
+ remove 'CFLAGS', f
+ remove 'CXXFLAGS', f
+ end
+end
diff --git a/Library/Homebrew/pathname+yeast.rb b/Library/Homebrew/extend/pathname.rb
index bfbba61bf..bfbba61bf 100644
--- a/Library/Homebrew/pathname+yeast.rb
+++ b/Library/Homebrew/extend/pathname.rb
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index c4f1bb698..757fb8d74 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -21,11 +21,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-require 'pathname+yeast'
-require 'ARGV+yeast'
+require 'extend/pathname'
+require 'extend/ARGV'
require 'utils'
require 'hardware'
+ARGV.extend(HomebrewArgvExtension)
+
+
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?
diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb
index d9b66d5ac..19fa99b7d 100755
--- a/Library/Homebrew/install.rb
+++ b/Library/Homebrew/install.rb
@@ -2,7 +2,7 @@
require 'global'
require 'brew.h'
-require 'brewkit'
+require 'extend/ENV'
require 'fileutils'
require 'formula'
require 'hardware'
@@ -31,30 +31,25 @@ EOS
end
-def ENV_prepend key, value, separator = ' '
- if ENV[key] and not ENV[key].empty?
- ENV[key] = value+separator+ENV[key]
- else
- ENV[key] = value
- end
-end
-
-
def install f
+ # we deliberately only do this when install is run, although it may be the wrong decision…
+ ENV.extend(HomebrewEnvExtension)
+ ENV.setup_build_environment
+
f.deps.each do |dep|
dep = Formula.factory dep
if dep.keg_only?
- ENV_prepend 'LDFLAGS', "-L#{dep.lib}"
- ENV_prepend 'CPPFLAGS', "-I#{dep.include}"
- ENV_prepend 'PATH', "#{dep.bin}", ':'
- ENV_prepend 'PKG_CONFIG_PATH', dep.lib+'pkgconfig', ':'
+ ENV.prepend 'LDFLAGS', "-L#{dep.lib}"
+ ENV.prepend 'CPPFLAGS', "-I#{dep.include}"
+ ENV.prepend 'PATH', "#{dep.bin}", ':'
+ ENV.prepend 'PKG_CONFIG_PATH', dep.lib+'pkgconfig', ':'
end
end
if ARGV.verbose?
ohai "Build Environment"
- %w[PATH CFLAGS LDFLAGS CPPFLAGS MAKEFLAGS CC CXX MACOSX_DEPLOYMENT_TARGET].each do |f|
- puts "#{f}: #{ENV[f]}" unless ENV[f].to_s.empty?
+ %w[PATH CFLAGS LDFLAGS CPPFLAGS MAKEFLAGS CC CXX MACOSX_DEPLOYMENT_TARGET].each do |env|
+ puts "#{env}: #{ENV[env]}" unless ENV[env].to_s.empty?
end
end
diff --git a/Library/Homebrew/formula_test.rb b/Library/Homebrew/test/formula_test.rb
index e63b183f4..15cafae13 100755
--- a/Library/Homebrew/formula_test.rb
+++ b/Library/Homebrew/test/formula_test.rb
@@ -3,15 +3,12 @@
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
-$:.unshift File.dirname(__FILE__)
+$:.unshift File.dirname(__FILE__)+'/..'
require 'test/unit'
require 'global'
-require 'pathname+yeast'
require 'formula'
require 'utils'
-require 'ARGV+yeast' # needs to be after test/unit to avoid conflict with OptionsParser
-
# NOTE duplicated in unittest.rb (we need to refactor the tests anyway)
def nostdout
diff --git a/Library/Homebrew/testball-0.1.tbz b/Library/Homebrew/test/testball-0.1.tbz
index 2f1e57358..2f1e57358 100644
--- a/Library/Homebrew/testball-0.1.tbz
+++ b/Library/Homebrew/test/testball-0.1.tbz
Binary files differ
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/test/unittest.rb
index dfbf0e101..f14e84e03 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/test/unittest.rb
@@ -5,8 +5,10 @@
ABS__FILE__=File.expand_path(__FILE__)
-$:.unshift File.dirname(ABS__FILE__)
-require 'pathname+yeast'
+$:.unshift File.dirname(ABS__FILE__)+'/..'
+require 'extend/pathname'
+require 'utils'
+require 'hardware'
require 'formula'
require 'download_strategy'
require 'keg'
@@ -29,7 +31,8 @@ Dir.chdir HOMEBREW_PREFIX
at_exit { HOMEBREW_PREFIX.parent.rmtree }
require 'test/unit' # must be after at_exit
-require 'ARGV+yeast' # needs to be after test/unit to avoid conflict with OptionsParser
+require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
+ARGV.extend(HomebrewArgvExtension)
class MockFormula <Formula
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 976adaa3a..6ce87f190 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -122,3 +122,17 @@ def arch_for_command cmd
return archs
end
+
+
+# replaces before with after for the file path
+def inreplace path, before, after
+ before=Regexp.escape before.to_s
+ before.gsub! "/", "\\/" # I guess not escaped as delimiter varies
+ after=after.to_s
+ after.gsub! "\\", "\\\\"
+ after.gsub! "/", "\\/"
+ after.gsub! "$", "\\$"
+
+ # FIXME use proper Ruby for teh exceptions!
+ safe_system "/usr/bin/perl", "-pi", "-e", "s/#{before}/#{after}/g", path
+end