From b36dcc4ffde9a4f7419e9f876eac6ee77aaf3338 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Tue, 2 Aug 2011 12:00:30 +0100 Subject: Improve compatibility for old formula Allow compatibility to be disabled with --no-compat or HOMEBREW_NO_COMPAT environment variable.--- Library/Homebrew/compat/brewkit.rb | 3 ++ Library/Homebrew/compat/compatibility.rb | 82 ++++++++++++++++++++++++++++++++ Library/Homebrew/compatibility.rb | 80 ------------------------------- Library/Homebrew/global.rb | 6 ++- 4 files changed, 90 insertions(+), 81 deletions(-) create mode 100644 Library/Homebrew/compat/brewkit.rb create mode 100644 Library/Homebrew/compat/compatibility.rb delete mode 100644 Library/Homebrew/compatibility.rb (limited to 'Library/Homebrew') diff --git a/Library/Homebrew/compat/brewkit.rb b/Library/Homebrew/compat/brewkit.rb new file mode 100644 index 000000000..59a0bf150 --- /dev/null +++ b/Library/Homebrew/compat/brewkit.rb @@ -0,0 +1,3 @@ +# here so that formula from the repo that are very old can still be installed + +require 'formula' diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb new file mode 100644 index 000000000..ac94feff8 --- /dev/null +++ b/Library/Homebrew/compat/compatibility.rb @@ -0,0 +1,82 @@ +## Compatibility layer introduced in 0.8 (refactor) + +# maybe never used by anyone, but alas it must continue to exist +def versions_of(keg_name) + `/bin/ls #{HOMEBREW_CELLAR}/#{keg_name}`.collect { |version| version.strip }.reverse +end + +def dump_config + require 'cmd/--config' + Homebrew.__config +end + +def dump_build_env env + require 'cmd/--env' + Homebrew.dump_build_env env +end + +def default_cc + MacOS.default_cc +end + +def gcc_42_build + MacOS.gcc_42_build_version +end + +alias :gcc_build :gcc_42_build + +def gcc_40_build + MacOS.gcc_40_build_version +end + +def llvm_build + MacOS.llvm_build_version +end + +def x11_installed? + MacOS.x11_installed? +end + +def macports_or_fink_installed? + MacOS.macports_or_fink_installed? +end + +def outdated_brews + require 'cmd/outdated' + Homebrew.outdated_brews +end + +def search_brews text + require 'cmd/search' + Homebrew.search_brews text +end + +def snow_leopard_64? + MacOS.prefer_64_bit? +end + +class Formula + # in compatability because the naming is somewhat confusing + def self.resolve_alias name + opoo 'Formula.resolve_alias is deprecated and will eventually be removed' + + # Don't resolve paths or URLs + return name if name.include?("/") + + aka = HOMEBREW_REPOSITORY+"Library/Aliases"+name + if aka.file? + aka.realpath.basename('.rb').to_s + else + name + end + end + + # This used to be called in "def install", but should now be used + # up in the DSL section. + def fails_with_llvm msg=nil, data=nil + handle_llvm_failure FailsWithLLVM.new(msg, data) + end +end + +class UnidentifiedFormula < Formula +end diff --git a/Library/Homebrew/compatibility.rb b/Library/Homebrew/compatibility.rb deleted file mode 100644 index 5bc76d3ff..000000000 --- a/Library/Homebrew/compatibility.rb +++ /dev/null @@ -1,80 +0,0 @@ -## Compatibility layer introduced in 0.8 (refactor) - -# maybe never used by anyone, but alas it must continue to exist -def versions_of(keg_name) - `/bin/ls #{HOMEBREW_CELLAR}/#{keg_name}`.collect { |version| version.strip }.reverse -end - -def dump_config - require 'cmd/--config' - Homebrew.__config -end - -def dump_build_env env - require 'cmd/--env' - Homebrew.dump_build_env env -end - -def default_cc - MacOS.default_cc -end - -def gcc_42_build - MacOS.gcc_42_build_version -end - -alias :gcc_build :gcc_42_build - -def gcc_40_build - MacOS.gcc_40_build_version -end - -def llvm_build - MacOS.llvm_build_version -end - -def x11_installed? - MacOS.x11_installed? -end - -def macports_or_fink_installed? - MacOS.macports_or_fink_installed? -end - -def outdated_brews - require 'cmd/outdated' - Homebrew.outdated_brews -end - -def search_brews text - require 'cmd/search' - Homebrew.search_brews text -end - -def snow_leopard_64? - MacOS.prefer_64_bit? -end - -class Formula - # in compatability because the naming is somewhat confusing - def self.resolve_alias name - opoo 'Formula.resolve_alias is deprecated and will eventually be removed' - - # Don't resolve paths or URLs - return name if name.include?("/") - - aka = HOMEBREW_REPOSITORY+"Library/Aliases"+name - if aka.file? - aka.realpath.basename('.rb').to_s - else - name - end - end - - # This used to be called in "def install", but should now be used - # up in the DSL section. - def fails_with_llvm msg=nil, data=nil - handle_llvm_failure FailsWithLLVM.new(msg, data) - end - -end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index d390d7d3c..7e6f38949 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -3,7 +3,6 @@ require 'extend/ARGV' require 'extend/string' require 'utils' require 'exceptions' -require 'compatibility' ARGV.extend(HomebrewArgvExtension) @@ -58,3 +57,8 @@ end FORMULA_META_FILES = %w[README README.md ChangeLog COPYING LICENSE LICENCE COPYRIGHT AUTHORS] PLEASE_REPORT_BUG = "#{Tty.white}Please report this bug: #{Tty.em}https://github.com/mxcl/homebrew/wiki/Checklist-before-filing-a-new-issue#{Tty.reset}" + +unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT'] + $:.unshift(File.expand_path("#{__FILE__}/../compat")) + require 'compatibility' +end -- cgit v1.2.3