mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
88 lines
2.8 KiB
Ruby
88 lines
2.8 KiB
Ruby
![]() |
require 'formula_installer'
|
||
|
require 'hardware'
|
||
|
|
||
|
module Homebrew extend self
|
||
|
def install
|
||
|
brew_install
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def brew_install
|
||
|
############################################################ sanity checks
|
||
|
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
|
||
|
|
||
|
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?
|
||
|
|
||
|
################################################################# warnings
|
||
|
begin
|
||
|
if MACOS_VERSION >= 10.6
|
||
|
opoo "You should upgrade to Xcode 3.2.3" if llvm_build < RECOMMENDED_LLVM
|
||
|
else
|
||
|
opoo "You should upgrade to Xcode 3.1.4" if (gcc_40_build < RECOMMENDED_GCC_40) or (gcc_42_build < RECOMMENDED_GCC_42)
|
||
|
end
|
||
|
rescue
|
||
|
# the reason we don't abort is some formula don't require Xcode
|
||
|
# TODO allow formula to declare themselves as "not needing Xcode"
|
||
|
opoo "Xcode is not installed! Builds may fail!"
|
||
|
end
|
||
|
|
||
|
if macports_or_fink_installed?
|
||
|
opoo "It appears you have MacPorts or Fink installed."
|
||
|
puts "Software installed with MacPorts and Fink are known to cause problems."
|
||
|
puts "If you experience issues try uninstalling these tools."
|
||
|
end
|
||
|
|
||
|
################################################################# install!
|
||
|
installer = FormulaInstaller.new
|
||
|
installer.install_deps = !ARGV.include?('--ignore-dependencies')
|
||
|
|
||
|
ARGV.formulae.each do |f|
|
||
|
if not f.installed? or ARGV.force?
|
||
|
installer.install f
|
||
|
else
|
||
|
puts "Formula already installed: #{f.prefix}"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def check_for_blacklisted_formula names
|
||
|
return if ARGV.force?
|
||
|
|
||
|
names.each do |name|
|
||
|
case name
|
||
|
when 'tex', 'tex-live', 'texlive' then abort <<-EOS.undent
|
||
|
Installing TeX from source is weird and gross, requires a lot of patches,
|
||
|
and only builds 32-bit (and thus can't use Homebrew deps on Snow Leopard.)
|
||
|
|
||
|
We recommend using a MacTeX distribution:
|
||
|
http://www.tug.org/mactex/
|
||
|
EOS
|
||
|
|
||
|
when 'mercurial', 'hg' then abort <<-EOS.undent
|
||
|
Mercurial can be install thusly:
|
||
|
brew install pip && pip install mercurial
|
||
|
EOS
|
||
|
|
||
|
when 'npm' then abort <<-EOS.undent
|
||
|
npm can be installed thusly by following the instructions at
|
||
|
http://npmjs.org/
|
||
|
|
||
|
To do it in one line, use this command:
|
||
|
curl http://npmjs.org/install.sh | sudo sh
|
||
|
EOS
|
||
|
|
||
|
when 'setuptools' then abort <<-EOS.undent
|
||
|
When working with a Homebrew-built Python, distribute is preferred
|
||
|
over setuptools, and can be used as the prerequisite for pip.
|
||
|
|
||
|
Install distribute using:
|
||
|
brew install distribute
|
||
|
EOS
|
||
|
end
|
||
|
end
|
||
|
end
|