| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  | require "formulary" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							|  |  |  |   module MissingFormula | 
					
						
							|  |  |  |     class << self | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |       def reason(name, silent: false, show_info: false) | 
					
						
							|  |  |  |         cask_reason(name, silent: silent, show_info: show_info) || blacklisted_reason(name) || | 
					
						
							|  |  |  |           tap_migration_reason(name) || deleted_reason(name, silent: silent) | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def blacklisted_reason(name) | 
					
						
							|  |  |  |         case name.downcase | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "gem", /^rubygems?$/ then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-18 15:42:49 -05:00
										 |  |  |           macOS provides gem as part of Ruby. To install a newer version: | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |             brew install ruby | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "pip" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           pip is part of the python formula: | 
					
						
							| 
									
										
										
										
											2019-02-05 14:05:57 +00:00
										 |  |  |             brew install python | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "pil" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           Instead of PIL, consider pillow: | 
					
						
							|  |  |  |             pip2 install pillow | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "macruby" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-18 16:20:59 -05:00
										 |  |  |           MacRuby has been discontinued. Consider RubyMotion: | 
					
						
							|  |  |  |             brew cask install rubymotion | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2019-02-05 13:38:08 +00:00
										 |  |  |         when /(lib)?lzma/ then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           lzma is now part of the xz formula: | 
					
						
							| 
									
										
										
										
											2019-02-05 14:05:57 +00:00
										 |  |  |             brew install xz | 
					
						
							| 
									
										
										
										
											2019-02-05 13:38:08 +00:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "gtest", "googletest", "google-test" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           Installing gtest system-wide is not recommended; it should be vendored | 
					
						
							|  |  |  |           in your projects that use it. | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "gmock", "googlemock", "google-mock" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           Installing gmock system-wide is not recommended; it should be vendored | 
					
						
							|  |  |  |           in your projects that use it. | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "sshpass" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           We won't add sshpass because it makes it too easy for novice SSH users to | 
					
						
							|  |  |  |           ruin SSH's security. | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "gsutil" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           gsutil is available through pip: | 
					
						
							|  |  |  |             pip2 install gsutil | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "gfortran" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           GNU Fortran is part of the GCC formula: | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |             brew install gcc | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "play" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           Play 2.3 replaces the play command with activator: | 
					
						
							|  |  |  |             brew install typesafe-activator | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           You can read more about this change at: | 
					
						
							|  |  |  |             #{Formatter.url("https://www.playframework.com/documentation/2.3.x/Migration23")} | 
					
						
							|  |  |  |             #{Formatter.url("https://www.playframework.com/documentation/2.3.x/Highlights23")} | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "haskell-platform" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-18 15:42:49 -05:00
										 |  |  |           The components of the Haskell Platform are available separately. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           Glasgow Haskell Compiler: | 
					
						
							|  |  |  |             brew install ghc | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           Cabal build system: | 
					
						
							|  |  |  |             brew install cabal-install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           Haskell Stack tool: | 
					
						
							|  |  |  |             brew install haskell-stack | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "mysqldump-secure" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           The creator of mysqldump-secure tried to game our popularity metrics. | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         when "ngrok" then <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |           Upstream sunsetted 1.x in March 2016 and 2.x is not open-source. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 20:12:29 +01:00
										 |  |  |           If you wish to use the 2.x release you can install with Homebrew Cask: | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |             brew cask install ngrok | 
					
						
							| 
									
										
										
										
											2018-06-06 23:34:19 -04:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2019-02-05 13:38:08 +00:00
										 |  |  |         when "cargo" then <<~EOS | 
					
						
							| 
									
										
										
										
											2019-02-16 17:31:24 -05:00
										 |  |  |           cargo is part of the rust formula: | 
					
						
							| 
									
										
										
										
											2019-02-05 14:05:57 +00:00
										 |  |  |             brew install rust | 
					
						
							| 
									
										
										
										
											2019-02-05 13:38:08 +00:00
										 |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2019-02-19 10:51:52 +00:00
										 |  |  |         when "uconv" then <<~EOS | 
					
						
							|  |  |  |           uconv is part of the icu4c formula: | 
					
						
							|  |  |  |             brew install icu4c | 
					
						
							|  |  |  |         EOS | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       alias generic_blacklisted_reason blacklisted_reason | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |       def tap_migration_reason(name) | 
					
						
							|  |  |  |         message = nil | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Tap.each do |old_tap| | 
					
						
							| 
									
										
										
										
											2017-03-30 19:18:40 +01:00
										 |  |  |           new_tap = old_tap.tap_migrations[name] | 
					
						
							|  |  |  |           next unless new_tap | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-25 10:16:22 +01:00
										 |  |  |           new_tap_user, new_tap_repo, new_tap_new_name = new_tap.split("/") | 
					
						
							| 
									
										
										
										
											2017-03-30 19:18:40 +01:00
										 |  |  |           new_tap_name = "#{new_tap_user}/#{new_tap_repo}" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |           message = <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-30 19:18:40 +01:00
										 |  |  |             It was migrated from #{old_tap} to #{new_tap}. | 
					
						
							| 
									
										
										
										
											2017-07-02 15:28:44 +01:00
										 |  |  |           EOS | 
					
						
							|  |  |  |           break if new_tap_name == CoreTap.instance.name | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 18:03:16 +02:00
										 |  |  |           install_cmd = if new_tap_name.start_with?("homebrew/cask") | 
					
						
							| 
									
										
										
										
											2018-04-25 10:16:22 +01:00
										 |  |  |             "cask install" | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             "install" | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |           new_tap_new_name ||= name | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |           message += <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |             You can access it again by running: | 
					
						
							|  |  |  |               brew tap #{new_tap_name} | 
					
						
							| 
									
										
										
										
											2018-04-25 10:16:22 +01:00
										 |  |  |             And then you can install it by running: | 
					
						
							|  |  |  |               brew #{install_cmd} #{new_tap_new_name} | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |           EOS | 
					
						
							|  |  |  |           break | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         message | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-22 21:56:15 +00:00
										 |  |  |       def deleted_reason(name, silent: false) | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |         path = Formulary.path name | 
					
						
							|  |  |  |         return if File.exist? path | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |         tap = Tap.from_path(path) | 
					
						
							| 
									
										
										
										
											2017-04-10 16:22:50 -04:00
										 |  |  |         return if tap.nil? || !File.exist?(tap.path) | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |         relative_path = path.relative_path_from tap.path | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         tap.path.cd do | 
					
						
							| 
									
										
										
										
											2017-06-03 10:02:40 +01:00
										 |  |  |           unless silent | 
					
						
							| 
									
										
										
										
											2017-12-30 21:18:02 +00:00
										 |  |  |             ohai "Searching for a previously deleted formula (in the last month)..." | 
					
						
							| 
									
										
										
										
											2017-06-03 10:02:40 +01:00
										 |  |  |             if (tap.path/".git/shallow").exist? | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |               opoo <<~EOS | 
					
						
							| 
									
										
										
										
											2017-06-03 10:02:40 +01:00
										 |  |  |                 #{tap} is shallow clone. To get complete history run: | 
					
						
							|  |  |  |                   git -C "$(brew --repo #{tap})" fetch --unshallow | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |               EOS | 
					
						
							|  |  |  |             end | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2017-03-22 21:56:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-02 16:15:09 +01:00
										 |  |  |           log_command = "git log --since='1 month ago' --diff-filter=D " \ | 
					
						
							|  |  |  |                         "--name-only --max-count=1 " \ | 
					
						
							|  |  |  |                         "--format=%H\\\\n%h\\\\n%B -- #{relative_path}" | 
					
						
							| 
									
										
										
										
											2017-03-22 21:56:15 +00:00
										 |  |  |           hash, short_hash, *commit_message, relative_path = | 
					
						
							|  |  |  |             Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp) | 
					
						
							| 
									
										
										
										
											2017-03-22 00:28:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-14 17:02:19 +01:00
										 |  |  |           if hash.blank? || short_hash.blank? || relative_path.blank? | 
					
						
							| 
									
										
										
										
											2017-03-22 21:56:15 +00:00
										 |  |  |             ofail "No previously deleted formula found." unless silent | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |             return | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           commit_message = commit_message.reject(&:empty?).join("\n  ") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           commit_message.sub!(/ \(#(\d+)\)$/, " (#{tap.issues_url}/\\1)") | 
					
						
							|  |  |  |           commit_message.gsub!(/(Closes|Fixes) #(\d+)/, "\\1 #{tap.issues_url}/\\2") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |           <<~EOS | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |             #{name} was deleted from #{tap.name} in commit #{short_hash}: | 
					
						
							|  |  |  |               #{commit_message} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             To show the formula before removal run: | 
					
						
							|  |  |  |               git -C "$(brew --repo #{tap})" show #{short_hash}^:#{relative_path} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             If you still use this formula consider creating your own tap: | 
					
						
							| 
									
										
										
										
											2019-04-05 12:24:10 -04:00
										 |  |  |               #{Formatter.url("https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap")} | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |           EOS | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-21 07:12:09 +01:00
										 |  |  |       def cask_reason(name, silent: false, show_info: false); end | 
					
						
							| 
									
										
										
										
											2019-01-16 20:50:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-20 14:09:13 -04:00
										 |  |  |       def suggest_command(name, command); end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |       require "extend/os/missing_formula" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |