| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  | module HomebrewArgvExtension | 
					
						
							| 
									
										
										
										
											2016-11-14 09:28:28 +00:00
										 |  |  |   def formula_install_option_names | 
					
						
							|  |  |  |     %w[
 | 
					
						
							|  |  |  |       --debug | 
					
						
							|  |  |  |       --env= | 
					
						
							|  |  |  |       --ignore-dependencies | 
					
						
							|  |  |  |       --cc= | 
					
						
							|  |  |  |       --build-from-source | 
					
						
							|  |  |  |       --devel | 
					
						
							|  |  |  |       --HEAD | 
					
						
							|  |  |  |       --keep-tmp | 
					
						
							|  |  |  |       --interactive | 
					
						
							|  |  |  |       --git | 
					
						
							|  |  |  |       --sandbox | 
					
						
							|  |  |  |       --no-sandbox | 
					
						
							|  |  |  |       --build-bottle | 
					
						
							|  |  |  |       --force-bottle | 
					
						
							| 
									
										
										
										
											2018-03-15 13:37:34 +00:00
										 |  |  |       --include-test | 
					
						
							| 
									
										
										
										
											2016-11-14 09:28:28 +00:00
										 |  |  |       --verbose | 
					
						
							| 
									
										
										
										
											2017-02-18 23:37:37 -05:00
										 |  |  |       --force | 
					
						
							| 
									
										
										
										
											2018-06-20 00:54:14 -04:00
										 |  |  |       --display-times | 
					
						
							| 
									
										
										
										
											2016-11-14 09:28:28 +00:00
										 |  |  |       -i | 
					
						
							|  |  |  |       -v | 
					
						
							|  |  |  |       -d | 
					
						
							|  |  |  |       -g | 
					
						
							|  |  |  |       -s | 
					
						
							| 
									
										
										
										
											2017-02-18 23:37:37 -05:00
										 |  |  |       -f | 
					
						
							| 
									
										
										
										
											2016-11-14 09:28:28 +00:00
										 |  |  |     ].freeze | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def named | 
					
						
							| 
									
										
										
										
											2014-08-28 22:11:08 -05:00
										 |  |  |     @named ||= self - options_only | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-03-09 02:09:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-13 07:31:43 -07:00
										 |  |  |   def options_only | 
					
						
							| 
									
										
										
										
											2014-08-28 22:11:08 -05:00
										 |  |  |     select { |arg| arg.start_with?("-") } | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-03-09 02:09:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-29 19:38:32 -05:00
										 |  |  |   def flags_only | 
					
						
							|  |  |  |     select { |arg| arg.start_with?("--") } | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def formulae | 
					
						
							| 
									
										
										
										
											2014-06-19 21:35:47 -05:00
										 |  |  |     require "formula" | 
					
						
							| 
									
										
										
										
											2015-08-09 22:43:01 +08:00
										 |  |  |     @formulae ||= (downcased_unique_named - casks).map do |name| | 
					
						
							|  |  |  |       if name.include?("/") || File.exist?(name) | 
					
						
							|  |  |  |         Formulary.factory(name, spec) | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         Formulary.find_with_priority(name, spec) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-12-31 17:03:29 +00:00
										 |  |  |     end.uniq(&:name) | 
					
						
							| 
									
										
										
										
											2014-11-28 15:02:42 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 00:53:41 +08:00
										 |  |  |   def resolved_formulae | 
					
						
							|  |  |  |     require "formula" | 
					
						
							|  |  |  |     @resolved_formulae ||= (downcased_unique_named - casks).map do |name| | 
					
						
							| 
									
										
										
										
											2016-07-16 20:58:56 +08:00
										 |  |  |       if name.include?("/") || File.exist?(name) | 
					
						
							| 
									
										
										
										
											2015-07-31 16:02:11 +08:00
										 |  |  |         f = Formulary.factory(name, spec) | 
					
						
							| 
									
										
										
										
											2016-07-15 15:03:58 +08:00
										 |  |  |         if f.any_version_installed? | 
					
						
							|  |  |  |           tab = Tab.for_formula(f) | 
					
						
							| 
									
										
										
										
											2016-07-17 02:28:20 +02:00
										 |  |  |           resolved_spec = spec(nil) || tab.spec | 
					
						
							| 
									
										
										
										
											2016-09-24 17:59:14 +02:00
										 |  |  |           f.active_spec = resolved_spec if f.send(resolved_spec) | 
					
						
							| 
									
										
										
										
											2016-07-15 15:03:58 +08:00
										 |  |  |           f.build = tab | 
					
						
							| 
									
										
										
										
											2016-07-17 11:56:13 +03:00
										 |  |  |           if f.head? && tab.tabfile | 
					
						
							|  |  |  |             k = Keg.new(tab.tabfile.parent) | 
					
						
							| 
									
										
										
										
											2016-08-06 11:22:12 +03:00
										 |  |  |             f.version.update_commit(k.version.version.commit) if k.version.head? | 
					
						
							| 
									
										
										
										
											2016-07-17 11:56:13 +03:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2015-07-31 16:02:11 +08:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2015-05-17 00:53:41 +08:00
										 |  |  |       else | 
					
						
							| 
									
										
										
										
											2015-08-10 21:12:42 +08:00
										 |  |  |         rack = Formulary.to_rack(name) | 
					
						
							| 
									
										
										
										
											2016-09-15 16:01:18 +01:00
										 |  |  |         alias_path = Formulary.factory(name).alias_path | 
					
						
							|  |  |  |         f = Formulary.from_rack(rack, spec(nil), alias_path: alias_path) | 
					
						
							| 
									
										
										
										
											2015-05-17 00:53:41 +08:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-09-15 16:01:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       # If this formula was installed with an alias that has since changed, | 
					
						
							|  |  |  |       # then it was specified explicitly in ARGV. (Using the alias would | 
					
						
							|  |  |  |       # instead have found the new formula.) | 
					
						
							|  |  |  |       # | 
					
						
							|  |  |  |       # Because of this, the user is referring to this specific formula, | 
					
						
							|  |  |  |       # not any formula targetted by the same alias, so in this context | 
					
						
							|  |  |  |       # the formula shouldn't be considered outdated if the alias used to | 
					
						
							|  |  |  |       # install it has changed. | 
					
						
							|  |  |  |       f.follow_installed_alias = false | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       f | 
					
						
							| 
									
										
										
										
											2016-12-31 17:03:29 +00:00
										 |  |  |     end.uniq(&:name) | 
					
						
							| 
									
										
										
										
											2015-05-17 00:53:41 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 15:02:42 +00:00
										 |  |  |   def casks | 
					
						
							| 
									
										
										
										
											2016-10-19 11:56:40 -04:00
										 |  |  |     @casks ||= downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-03-09 02:09:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def kegs | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     require "keg" | 
					
						
							|  |  |  |     require "formula" | 
					
						
							| 
									
										
										
										
											2009-10-24 18:09:43 +01:00
										 |  |  |     @kegs ||= downcased_unique_named.collect do |name| | 
					
						
							| 
									
										
										
										
											2016-09-25 11:04:16 -04:00
										 |  |  |       raise UsageError if name.empty? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-16 21:05:28 +08:00
										 |  |  |       rack = Formulary.to_rack(name.downcase) | 
					
						
							| 
									
										
										
										
											2015-08-09 14:56:01 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-15 12:55:14 -05:00
										 |  |  |       dirs = rack.directory? ? rack.subdirs : [] | 
					
						
							| 
									
										
										
										
											2014-04-05 22:03:34 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-11 17:53:00 +01:00
										 |  |  |       raise NoSuchKegError, rack.basename if dirs.empty? | 
					
						
							| 
									
										
										
										
											2012-03-06 13:43:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-15 18:28:42 +01:00
										 |  |  |       linked_keg_ref = HOMEBREW_LINKED_KEGS/rack.basename | 
					
						
							|  |  |  |       opt_prefix = HOMEBREW_PREFIX/"opt/#{rack.basename}" | 
					
						
							| 
									
										
										
										
											2012-03-06 13:43:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-26 22:28:00 -05:00
										 |  |  |       begin | 
					
						
							|  |  |  |         if opt_prefix.symlink? && opt_prefix.directory? | 
					
						
							|  |  |  |           Keg.new(opt_prefix.resolved_path) | 
					
						
							|  |  |  |         elsif linked_keg_ref.symlink? && linked_keg_ref.directory? | 
					
						
							|  |  |  |           Keg.new(linked_keg_ref.resolved_path) | 
					
						
							|  |  |  |         elsif dirs.length == 1
 | 
					
						
							|  |  |  |           Keg.new(dirs.first) | 
					
						
							|  |  |  |         else | 
					
						
							| 
									
										
										
										
											2016-07-16 21:05:28 +08:00
										 |  |  |           f = if name.include?("/") || File.exist?(name) | 
					
						
							|  |  |  |             Formulary.factory(name) | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             Formulary.from_rack(rack) | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-23 22:02:23 +02:00
										 |  |  |           unless (prefix = f.installed_prefix).directory? | 
					
						
							| 
									
										
										
										
											2016-09-11 17:53:00 +01:00
										 |  |  |             raise MultipleVersionsInstalledError, rack.basename | 
					
						
							| 
									
										
										
										
											2016-07-16 21:05:28 +08:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2016-09-23 22:02:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |           Keg.new(prefix) | 
					
						
							| 
									
										
										
										
											2014-06-26 22:28:00 -05:00
										 |  |  |         end | 
					
						
							|  |  |  |       rescue FormulaUnavailableError | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         raise <<~EOS | 
					
						
							| 
									
										
										
										
											2014-06-26 22:28:00 -05:00
										 |  |  |           Multiple kegs installed to #{rack} | 
					
						
							|  |  |  |           However we don't know which one you refer to. | 
					
						
							|  |  |  |           Please delete (with rm -rf!) all but one and then try again. | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2012-03-06 13:43:41 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-09-04 15:22:25 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def include?(arg) | 
					
						
							| 
									
										
										
										
											2017-02-25 19:15:08 +03:00
										 |  |  |     !(@n = index(arg)).nil? | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def next | 
					
						
							| 
									
										
										
										
											2017-06-01 16:06:51 +02:00
										 |  |  |     at(@n + 1) || raise(UsageError) | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-11 05:08:09 +02:00
										 |  |  |   def value(name) | 
					
						
							|  |  |  |     arg_prefix = "--#{name}=" | 
					
						
							|  |  |  |     flag_with_value = find { |arg| arg.start_with?(arg_prefix) } | 
					
						
							| 
									
										
										
										
											2017-09-24 19:24:46 +01:00
										 |  |  |     flag_with_value&.strip_prefix(arg_prefix) | 
					
						
							| 
									
										
										
										
											2013-07-07 09:14:10 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-10 16:42:10 +00:00
										 |  |  |   # Returns an array of values that were given as a comma-separated list. | 
					
						
							| 
									
										
										
										
											2016-10-10 13:26:09 +01:00
										 |  |  |   # @see value | 
					
						
							|  |  |  |   def values(name) | 
					
						
							|  |  |  |     return unless val = value(name) | 
					
						
							|  |  |  |     val.split(",") | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def force? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag? "--force" | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def verbose? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag?("--verbose") || !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil? | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   def debug? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil? | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-03 17:10:35 +02:00
										 |  |  |   def quieter? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag? "--quieter" | 
					
						
							| 
									
										
										
										
											2009-09-03 17:10:35 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-10 14:29:41 +01:00
										 |  |  |   def interactive? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag? "--interactive" | 
					
						
							| 
									
										
										
										
											2009-09-10 14:29:41 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 09:36:40 -07:00
										 |  |  |   def one? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     flag? "--1" | 
					
						
							| 
									
										
										
										
											2011-04-21 09:36:40 -07:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-17 18:44:35 -05:00
										 |  |  |   def dry_run? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include?("--dry-run") || switch?("n") | 
					
						
							| 
									
										
										
										
											2012-06-17 18:44:35 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-04-21 09:36:40 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 22:53:56 -04:00
										 |  |  |   def keep_tmp? | 
					
						
							|  |  |  |     include? "--keep-tmp" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 21:33:20 -06:00
										 |  |  |   def git? | 
					
						
							|  |  |  |     flag? "--git" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-31 17:51:57 +00:00
										 |  |  |   def homebrew_developer? | 
					
						
							| 
									
										
										
										
											2016-01-21 16:51:45 +01:00
										 |  |  |     !ENV["HOMEBREW_DEVELOPER"].nil? | 
					
						
							| 
									
										
										
										
											2012-12-31 17:51:57 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-09 17:42:54 +08:00
										 |  |  |   def sandbox? | 
					
						
							|  |  |  |     include?("--sandbox") || !ENV["HOMEBREW_SANDBOX"].nil? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-09 16:28:13 +00:00
										 |  |  |   def no_sandbox? | 
					
						
							|  |  |  |     include?("--no-sandbox") || !ENV["HOMEBREW_NO_SANDBOX"].nil? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-18 18:12:12 -05:00
										 |  |  |   def ignore_deps? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include? "--ignore-dependencies" | 
					
						
							| 
									
										
										
										
											2012-08-18 18:12:12 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-16 16:37:59 -08:00
										 |  |  |   def only_deps? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include? "--only-dependencies" | 
					
						
							| 
									
										
										
										
											2013-12-16 16:37:59 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-15 21:53:16 -05:00
										 |  |  |   def json | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     value "json" | 
					
						
							| 
									
										
										
										
											2012-08-15 21:53:16 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-09 12:40:41 -07:00
										 |  |  |   def build_head? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include? "--HEAD" | 
					
						
							| 
									
										
										
										
											2010-07-09 12:40:41 -07:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-11-24 09:40:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 20:09:33 -06:00
										 |  |  |   def build_devel? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include? "--devel" | 
					
						
							| 
									
										
										
										
											2011-11-20 20:09:33 -06:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 14:49:56 -07:00
										 |  |  |   def build_stable? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     !(build_head? || build_devel?) | 
					
						
							| 
									
										
										
										
											2012-06-10 14:49:56 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-21 09:36:40 -07:00
										 |  |  |   def build_universal? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include? "--universal" | 
					
						
							| 
									
										
										
										
											2010-09-25 12:49:09 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-31 19:09:49 +00:00
										 |  |  |   def build_bottle? | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     include?("--build-bottle") || !ENV["HOMEBREW_BUILD_BOTTLE"].nil? | 
					
						
							| 
									
										
										
										
											2011-12-31 19:09:49 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 14:14:53 -07:00
										 |  |  |   def bottle_arch | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     arch = value "bottle-arch" | 
					
						
							| 
									
										
										
										
											2017-09-24 19:24:46 +01:00
										 |  |  |     arch&.to_sym | 
					
						
							| 
									
										
										
										
											2013-08-25 14:14:53 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-24 09:40:37 +00:00
										 |  |  |   def build_from_source? | 
					
						
							| 
									
										
										
										
											2016-05-06 12:02:13 -07:00
										 |  |  |     switch?("s") || include?("--build-from-source") | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def build_all_from_source? | 
					
						
							| 
									
										
										
										
											2016-09-20 22:24:31 +02:00
										 |  |  |     !ENV["HOMEBREW_BUILD_FROM_SOURCE"].nil? | 
					
						
							| 
									
										
										
										
											2016-05-06 12:02:13 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # Whether a given formula should be built from source during the current | 
					
						
							|  |  |  |   # installation run. | 
					
						
							|  |  |  |   def build_formula_from_source?(f) | 
					
						
							|  |  |  |     return true if build_all_from_source? | 
					
						
							| 
									
										
										
										
											2016-09-11 17:53:00 +01:00
										 |  |  |     return false unless build_from_source? || build_bottle? | 
					
						
							| 
									
										
										
										
											2016-05-06 12:02:13 -07:00
										 |  |  |     formulae.any? { |argv_f| argv_f.full_name == f.full_name } | 
					
						
							| 
									
										
										
										
											2010-11-24 09:40:37 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def flag?(flag) | 
					
						
							| 
									
										
										
										
											2014-08-28 22:11:08 -05:00
										 |  |  |     options_only.include?(flag) || switch?(flag[2, 1]) | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-09-04 15:22:25 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-01 12:59:01 +01:00
										 |  |  |   def force_bottle? | 
					
						
							| 
									
										
										
										
											2018-07-24 09:20:50 +01:00
										 |  |  |     include?("--force-bottle") | 
					
						
							| 
									
										
										
										
											2013-09-01 12:59:01 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-22 12:47:47 +03:00
										 |  |  |   def fetch_head? | 
					
						
							|  |  |  |     include? "--fetch-HEAD" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-06 20:11:35 +00:00
										 |  |  |   # eg. `foo -ns -i --bar` has three switches, n, s and i | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def switch?(char) | 
					
						
							| 
									
										
										
										
											2014-08-28 22:11:08 -05:00
										 |  |  |     return false if char.length > 1
 | 
					
						
							| 
									
										
										
										
											2016-02-26 16:10:48 +08:00
										 |  |  |     options_only.any? { |arg| arg.scan("-").size == 1 && arg.include?(char) } | 
					
						
							| 
									
										
										
										
											2012-03-06 20:11:35 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-23 22:25:35 -07:00
										 |  |  |   def cc | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     value "cc" | 
					
						
							| 
									
										
										
										
											2013-08-23 22:25:35 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-13 10:10:59 -05:00
										 |  |  |   def env | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     value "env" | 
					
						
							| 
									
										
										
										
											2014-03-13 10:10:59 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-12 14:57:54 -04:00
										 |  |  |   # If the user passes any flags that trigger building over installing from | 
					
						
							|  |  |  |   # a bottle, they are collected here and returned as an Array for checking. | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  |   def collect_build_flags | 
					
						
							|  |  |  |     build_flags = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-22 13:15:33 +08:00
										 |  |  |     build_flags << "--HEAD" if build_head? | 
					
						
							|  |  |  |     build_flags << "--universal" if build_universal? | 
					
						
							|  |  |  |     build_flags << "--build-bottle" if build_bottle? | 
					
						
							|  |  |  |     build_flags << "--build-from-source" if build_from_source? | 
					
						
							| 
									
										
										
										
											2015-06-29 14:09:57 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     build_flags | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-28 21:35:52 -05:00
										 |  |  |   private | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |   def spec(default = :stable) | 
					
						
							| 
									
										
										
										
											2014-06-19 21:35:47 -05:00
										 |  |  |     if include?("--HEAD") | 
					
						
							|  |  |  |       :head | 
					
						
							|  |  |  |     elsif include?("--devel") | 
					
						
							|  |  |  |       :devel | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2015-07-30 16:31:47 +08:00
										 |  |  |       default | 
					
						
							| 
									
										
										
										
											2014-06-19 21:35:47 -05:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-07 22:15:29 -07:00
										 |  |  |   def downcased_unique_named | 
					
						
							| 
									
										
										
										
											2015-08-05 09:51:37 -07:00
										 |  |  |     # Only lowercase names, not paths, bottle filenames or URLs | 
					
						
							| 
									
										
										
										
											2010-09-22 07:54:53 -07:00
										 |  |  |     @downcased_unique_named ||= named.map do |arg| | 
					
						
							| 
									
										
										
										
											2016-07-16 20:58:56 +08:00
										 |  |  |       if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) | 
					
						
							| 
									
										
										
										
											2015-08-05 09:51:37 -07:00
										 |  |  |         arg | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         arg.downcase | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2010-09-22 07:54:53 -07:00
										 |  |  |     end.uniq | 
					
						
							| 
									
										
										
										
											2010-08-07 22:15:29 -07:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2009-08-10 16:27:24 +01:00
										 |  |  | end |