| 
									
										
										
										
											2011-03-18 10:30:26 -07:00
										 |  |  | ## Compatibility layer introduced in 0.8 (refactor) | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-16 02:46:46 +01:00
										 |  |  | def default_cc | 
					
						
							|  |  |  |   MacOS.default_cc | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | 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? | 
					
						
							| 
									
										
										
										
											2012-08-06 00:33:36 -05:00
										 |  |  |   MacOS::X11.installed? | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2010-11-05 13:44:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-18 10:30:26 -07:00
										 |  |  | def snow_leopard_64? | 
					
						
							|  |  |  |   MacOS.prefer_64_bit? | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-05 13:44:24 +00:00
										 |  |  | 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' | 
					
						
							| 
									
										
										
										
											2012-04-30 16:22:34 +10:00
										 |  |  |     opoo 'Use Formula.canonical_name instead.' | 
					
						
							| 
									
										
										
										
											2010-11-05 13:44:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Don't resolve paths or URLs | 
					
						
							|  |  |  |     return name if name.include?("/") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-31 11:00:15 -08:00
										 |  |  |     aka = HOMEBREW_REPOSITORY+"Library/Aliases"+name | 
					
						
							| 
									
										
										
										
											2010-11-05 13:44:24 +00:00
										 |  |  |     if aka.file? | 
					
						
							|  |  |  |       aka.realpath.basename('.rb').to_s | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       name | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-03-21 14:23:28 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # 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 | 
					
						
							| 
									
										
										
										
											2012-09-10 16:16:08 -05:00
										 |  |  |     opoo "Calling fails_with_llvm in the install method is deprecated" | 
					
						
							| 
									
										
										
										
											2013-03-18 13:10:03 -05:00
										 |  |  |     puts "Use the fails_with DSL instead" | 
					
						
							| 
									
										
										
										
											2011-03-21 14:23:28 -07:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-03-18 13:58:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def fails_with_llvm? | 
					
						
							|  |  |  |     fails_with? :llvm | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-18 13:10:03 -05:00
										 |  |  |   def self.fails_with_llvm msg=nil, data={} | 
					
						
							|  |  |  |     case msg when Hash then data = msg end | 
					
						
							|  |  |  |     failure = CompilerFailure.new(:llvm) { build(data.delete(:build).to_i) } | 
					
						
							| 
									
										
										
										
											2013-03-18 13:00:46 -05:00
										 |  |  |     @cc_failures ||= Set.new | 
					
						
							| 
									
										
										
										
											2013-03-18 13:10:03 -05:00
										 |  |  |     @cc_failures << failure | 
					
						
							| 
									
										
										
										
											2012-03-18 13:58:13 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-05-22 16:32:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def std_cmake_parameters | 
					
						
							| 
									
										
										
										
											2012-05-29 16:58:32 -07:00
										 |  |  |     "-DCMAKE_INSTALL_PREFIX='#{prefix}' -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev" | 
					
						
							| 
									
										
										
										
											2012-05-22 16:32:12 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-04-05 21:09:24 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   class << self | 
					
						
							| 
									
										
										
										
											2012-07-05 20:27:38 -05:00
										 |  |  |     def bottle_sha1 val=nil | 
					
						
							|  |  |  |       val.nil? ? @bottle_sha1 : @bottle_sha1 = val | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2012-04-05 21:09:24 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-01-23 00:26:26 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # These methods return lists of Formula objects. | 
					
						
							|  |  |  |   # They are eprecated in favor of Dependency::expand_dependencies | 
					
						
							|  |  |  |   # and Formula#recursive_dependencies, which return lists of | 
					
						
							|  |  |  |   # Dependency objects instead. | 
					
						
							|  |  |  |   def self.expand_deps f | 
					
						
							|  |  |  |     f.deps.map do |dep| | 
					
						
							|  |  |  |       f_dep = Formula.factory dep.to_s | 
					
						
							|  |  |  |       expand_deps(f_dep) << f_dep | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def recursive_deps | 
					
						
							|  |  |  |     Formula.expand_deps(self).flatten.uniq | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-03-20 22:20:30 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def self.all | 
					
						
							|  |  |  |     opoo "Formula.all is deprecated, use Formula.map instead" | 
					
						
							|  |  |  |     map | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-02 12:00:30 +01:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2011-03-21 14:23:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-02 12:00:30 +01:00
										 |  |  | class UnidentifiedFormula < Formula | 
					
						
							| 
									
										
										
										
											2010-11-05 13:44:24 +00:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2012-02-03 15:02:35 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | module HomebrewEnvExtension extend self | 
					
						
							|  |  |  |   def use_clang? | 
					
						
							|  |  |  |     compiler == :clang | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def use_gcc? | 
					
						
							|  |  |  |     compiler == :gcc | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def use_llvm? | 
					
						
							|  |  |  |     compiler == :llvm | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2012-03-18 13:58:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-04 23:04:01 -05:00
										 |  |  | # TODO eventually some of these should print deprecation warnings | 
					
						
							| 
									
										
										
										
											2012-07-09 14:58:34 -05:00
										 |  |  | module MacOS extend self | 
					
						
							|  |  |  |   def xcode_folder | 
					
						
							|  |  |  |     Xcode.folder | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def xcode_prefix | 
					
						
							|  |  |  |     Xcode.prefix | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def xcode_installed? | 
					
						
							|  |  |  |     Xcode.installed? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def xcode_version | 
					
						
							|  |  |  |     Xcode.version | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def clt_installed? | 
					
						
							|  |  |  |     CLT.installed? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def clt_version? | 
					
						
							|  |  |  |     CLT.version | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-07-25 15:04:46 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def x11_installed? | 
					
						
							| 
									
										
										
										
											2012-08-06 00:33:36 -05:00
										 |  |  |     X11.installed? | 
					
						
							| 
									
										
										
										
											2012-07-25 15:04:46 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def x11_prefix | 
					
						
							| 
									
										
										
										
											2012-08-06 00:33:36 -05:00
										 |  |  |     X11.prefix | 
					
						
							| 
									
										
										
										
											2012-07-25 15:04:46 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-08-14 11:37:29 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def leopard? | 
					
						
							|  |  |  |     10.5 == MACOS_VERSION | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def snow_leopard? | 
					
						
							|  |  |  |     10.6 <= MACOS_VERSION # Actually Snow Leopard or newer | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |   alias_method :snow_leopard_or_newer?, :snow_leopard? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def lion? | 
					
						
							|  |  |  |     10.7 <= MACOS_VERSION # Actually Lion or newer | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |   alias_method :lion_or_newer?, :lion? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def mountain_lion? | 
					
						
							|  |  |  |     10.8 <= MACOS_VERSION # Actually Mountain Lion or newer | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |   alias_method :mountain_lion_or_newer?, :mountain_lion? | 
					
						
							| 
									
										
										
										
											2012-12-17 17:05:53 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def macports_or_fink_installed? | 
					
						
							|  |  |  |     not MacOS.macports_or_fink.empty? | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2012-07-09 14:58:34 -05:00
										 |  |  | end | 
					
						
							| 
									
										
										
										
											2012-08-28 12:11:34 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Version | 
					
						
							|  |  |  |   def slice *args | 
					
						
							|  |  |  |     opoo "Calling slice on versions is deprecated, use: to_s.slice" | 
					
						
							| 
									
										
										
										
											2013-02-17 22:48:38 -06:00
										 |  |  |     to_s.slice(*args) | 
					
						
							| 
									
										
										
										
											2012-08-28 12:11:34 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2013-02-01 13:11:43 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # MD5 support | 
					
						
							|  |  |  | class Formula | 
					
						
							| 
									
										
										
										
											2013-03-18 14:59:10 -05:00
										 |  |  |   def self.md5(val) | 
					
						
							|  |  |  |     @stable ||= SoftwareSpec.new | 
					
						
							|  |  |  |     @stable.md5(val) | 
					
						
							| 
									
										
										
										
											2013-02-01 13:11:43 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SoftwareSpec | 
					
						
							| 
									
										
										
										
											2013-03-18 14:59:10 -05:00
										 |  |  |   def md5(val) | 
					
						
							|  |  |  |     @checksum = Checksum.new(:md5, val) | 
					
						
							| 
									
										
										
										
											2013-02-01 13:11:43 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Pathname | 
					
						
							|  |  |  |   def md5 | 
					
						
							|  |  |  |     require 'digest/md5' | 
					
						
							| 
									
										
										
										
											2013-02-01 21:53:10 -06:00
										 |  |  |     opoo <<-EOS.undent
 | 
					
						
							|  |  |  |     MD5 support is deprecated and will be removed in a future version. | 
					
						
							|  |  |  |     Please switch this formula to #{Checksum::TYPES.map { |t| t.to_s.upcase } * ' or '}. | 
					
						
							|  |  |  |     EOS | 
					
						
							| 
									
										
										
										
											2013-02-01 13:11:43 -06:00
										 |  |  |     incremental_hash(Digest::MD5) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |