aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2017-03-18 17:02:08 +0200
committerMike McQuaid2017-03-20 18:20:31 +0200
commit80e95b684e7485b5c5b7f7209dd95b0bdc9e3406 (patch)
tree421290914f160363cf4333477eee6b3efbdfc982 /Library/Homebrew
parent623c95b3f8660d5c77936483ec9b9a4db16aff00 (diff)
downloadbrew-80e95b684e7485b5c5b7f7209dd95b0bdc9e3406.tar.bz2
blacklist: move to missing_formula class instead.
This will allow extending this class so it can be used by more than just blacklisting.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/blacklist.rb92
-rw-r--r--Library/Homebrew/cmd/info.rb8
-rw-r--r--Library/Homebrew/cmd/install.rb6
-rw-r--r--Library/Homebrew/cmd/search.rb4
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb4
-rw-r--r--Library/Homebrew/dev-cmd/create.rb6
-rw-r--r--Library/Homebrew/extend/os/blacklist.rb2
-rw-r--r--Library/Homebrew/extend/os/mac/blacklist.rb16
-rw-r--r--Library/Homebrew/extend/os/mac/missing_formula.rb22
-rw-r--r--Library/Homebrew/extend/os/missing_formula.rb2
-rw-r--r--Library/Homebrew/missing_formula.rb106
-rw-r--r--Library/Homebrew/test/blacklist_spec.rb115
-rw-r--r--Library/Homebrew/test/missing_formula_spec.rb125
13 files changed, 269 insertions, 239 deletions
diff --git a/Library/Homebrew/blacklist.rb b/Library/Homebrew/blacklist.rb
deleted file mode 100644
index 93c8f81a0..000000000
--- a/Library/Homebrew/blacklist.rb
+++ /dev/null
@@ -1,92 +0,0 @@
-def blacklisted?(name)
- case name.downcase
- when "gem", /^rubygems?$/ then <<-EOS.undent
- Homebrew provides gem via: `brew install ruby`.
- EOS
- when "tex", "tex-live", "texlive", "latex" then <<-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 dependencies)
-
- We recommend using a MacTeX distribution: https://www.tug.org/mactex/
-
- You can install it with Homebrew-Cask:
- brew cask install mactex
- EOS
- when "pip" then <<-EOS.undent
- Homebrew provides pip via: `brew install python`. However you will then
- have two Pythons installed on your Mac, so alternatively you can install
- pip via the instructions at:
- #{Formatter.url("https://pip.readthedocs.io/en/stable/installing/")}
- EOS
- when "pil" then <<-EOS.undent
- Instead of PIL, consider `pip install pillow` or `brew install Homebrew/python/pillow`.
- EOS
- when "macruby" then <<-EOS.undent
- MacRuby is not packaged and is on an indefinite development hiatus.
- You can read more about it at:
- #{Formatter.url("https://github.com/MacRuby/MacRuby")}
- EOS
- when /(lib)?lzma/
- "lzma is now part of the xz formula."
- when "gtest", "googletest", "google-test" then <<-EOS.undent
- Installing gtest system-wide is not recommended; it should be vendored
- in your projects that use it.
- EOS
- when "gmock", "googlemock", "google-mock" then <<-EOS.undent
- Installing gmock system-wide is not recommended; it should be vendored
- in your projects that use it.
- EOS
- when "sshpass" then <<-EOS.undent
- We won't add sshpass because it makes it too easy for novice SSH users to
- ruin SSH's security.
- EOS
- when "gsutil" then <<-EOS.undent
- Install gsutil with `pip install gsutil`
- EOS
- when "clojure" then <<-EOS.undent
- Clojure isn't really a program but a library managed as part of a
- project and Leiningen is the user interface to that library.
-
- To install Clojure you should install Leiningen:
- brew install leiningen
- and then follow the tutorial:
- #{Formatter.url("https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md")}
- EOS
- when "osmium" then <<-EOS.undent
- The creator of Osmium requests that it not be packaged and that people
- use the GitHub master branch instead.
- EOS
- when "gfortran" then <<-EOS.undent
- GNU Fortran is now provided as part of GCC, and can be installed with:
- brew install gcc
- EOS
- when "play" then <<-EOS.undent
- 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")}
- EOS
- when "haskell-platform" then <<-EOS.undent
- We no longer package haskell-platform. Consider installing ghc
- and cabal-install instead:
- brew install ghc cabal-install
-
- You can install with Homebrew-Cask:
- brew cask install haskell-platform
- EOS
- when "mysqldump-secure" then <<-EOS.undent
- The creator of mysqldump-secure tried to game our popularity metrics.
- EOS
- when "ngrok" then <<-EOS.undent
- Upstream sunsetted 1.x in March 2016 and 2.x is not open-source.
-
- If you wish to use the 2.x release you can install with Homebrew-Cask:
- brew cask install ngrok
- EOS
- end
-end
-alias generic_blacklisted? blacklisted?
-
-require "extend/os/blacklist"
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 2d5e34ce2..5c96e5c50 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -16,7 +16,7 @@
#: See the docs for examples of using the JSON output:
#: <http://docs.brew.sh/Querying-Brew.html>
-require "blacklist"
+require "missing_formula"
require "caveats"
require "options"
require "formula"
@@ -56,9 +56,9 @@ module Homebrew
info_formula Formulary.find_with_priority(f)
end
rescue FormulaUnavailableError => e
- # No formula with this name, try a blacklist lookup
- if (blacklist = blacklisted?(f))
- ofail "#{e.message}\n#{blacklist}"
+ # No formula with this name, try a missing formula lookup
+ if (missing_formula = Homebrew::MissingFormula.missing_formula(f))
+ ofail "#{e.message}\n#{missing_formula}"
else
ofail e.message
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 8a99bd397..a0f95887b 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -55,7 +55,7 @@
#: If `--git` is passed, Homebrew will create a Git repository, useful for
#: creating patches to the software.
-require "blacklist"
+require "missing_formula"
require "diagnostic"
require "cmd/search"
require "formula_installer"
@@ -207,8 +207,8 @@ module Homebrew
# formula was found, but there's a problem with its implementation).
ofail e.message
rescue FormulaUnavailableError => e
- if (blacklist = blacklisted?(e.name))
- ofail "#{e.message}\n#{blacklist}"
+ if (missing_formula = Homebrew::MissingFormula.missing_formula(e.name))
+ ofail "#{e.message}\n#{missing_formula}"
elsif e.name == "updog"
ofail "What's updog?"
else
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 4c8bbc77c..6887805d6 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -14,7 +14,7 @@
#: Search for <text> in the given package manager's list.
require "formula"
-require "blacklist"
+require "missing_formula"
require "utils"
require "thread"
require "official_taps"
@@ -67,7 +67,7 @@ module Homebrew
if $stdout.tty?
count = local_results.length + tap_results.length
- if msg = blacklisted?(query)
+ if msg = Homebrew::MissingFormula.missing_formula(query)
if count > 0
puts
puts "If you meant #{query.inspect} specifically:"
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 677a52447..70104e0cb 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -38,7 +38,7 @@ require "official_taps"
require "cmd/search"
require "cmd/style"
require "date"
-require "blacklist"
+require "missing_formula"
require "digest"
module Homebrew
@@ -399,7 +399,7 @@ class FormulaAuditor
name = formula.name
full_name = formula.full_name
- if blacklisted?(name)
+ if Homebrew::MissingFormula.blacklisted_reason(name)
problem "'#{name}' is blacklisted."
end
diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb
index 9c58dc71a..6855d6f37 100644
--- a/Library/Homebrew/dev-cmd/create.rb
+++ b/Library/Homebrew/dev-cmd/create.rb
@@ -19,7 +19,7 @@
#: the specified tap.
require "formula"
-require "blacklist"
+require "missing_formula"
require "digest"
require "erb"
@@ -73,8 +73,8 @@ module Homebrew
# Don't allow blacklisted formula, or names that shadow aliases,
# unless --force is specified.
unless ARGV.force?
- if msg = blacklisted?(fc.name)
- raise "#{fc.name} is blacklisted for creation.\n#{msg}\nIf you really want to create this formula use --force."
+ if reason = Homebrew::MissingFormula.blacklisted_reason(fc.name)
+ raise "#{fc.name} is blacklisted for creation.\n#{reason}\nIf you really want to create this formula use --force."
end
if Formula.aliases.include? fc.name
diff --git a/Library/Homebrew/extend/os/blacklist.rb b/Library/Homebrew/extend/os/blacklist.rb
deleted file mode 100644
index 932040f82..000000000
--- a/Library/Homebrew/extend/os/blacklist.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require "blacklist"
-require "extend/os/mac/blacklist" if OS.mac?
diff --git a/Library/Homebrew/extend/os/mac/blacklist.rb b/Library/Homebrew/extend/os/mac/blacklist.rb
deleted file mode 100644
index edff4697e..000000000
--- a/Library/Homebrew/extend/os/mac/blacklist.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-def blacklisted?(name)
- case name.downcase
- when "xcode"
- if MacOS.version >= :lion
- <<-EOS.undent
- Xcode can be installed from the App Store.
- EOS
- else
- <<-EOS.undent
- Xcode can be installed from https://developer.apple.com/xcode/downloads/
- EOS
- end
- else
- generic_blacklisted?(name)
- end
-end
diff --git a/Library/Homebrew/extend/os/mac/missing_formula.rb b/Library/Homebrew/extend/os/mac/missing_formula.rb
new file mode 100644
index 000000000..48dfd2865
--- /dev/null
+++ b/Library/Homebrew/extend/os/mac/missing_formula.rb
@@ -0,0 +1,22 @@
+module Homebrew
+ module MissingFormula
+ class << self
+ def blacklisted_reason(name)
+ case name.downcase
+ when "xcode"
+ if MacOS.version >= :lion
+ <<-EOS.undent
+ Xcode can be installed from the App Store.
+ EOS
+ else
+ <<-EOS.undent
+ Xcode can be installed from #{Formatter.url("https://developer.apple.com/xcode/downloads/")}.
+ EOS
+ end
+ else
+ generic_blacklisted_reason(name)
+ end
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/extend/os/missing_formula.rb b/Library/Homebrew/extend/os/missing_formula.rb
new file mode 100644
index 000000000..02c59f4e4
--- /dev/null
+++ b/Library/Homebrew/extend/os/missing_formula.rb
@@ -0,0 +1,2 @@
+require "missing_formula"
+require "extend/os/mac/missing_formula" if OS.mac?
diff --git a/Library/Homebrew/missing_formula.rb b/Library/Homebrew/missing_formula.rb
new file mode 100644
index 000000000..28738a0dc
--- /dev/null
+++ b/Library/Homebrew/missing_formula.rb
@@ -0,0 +1,106 @@
+require "formulary"
+require "tap"
+require "utils"
+
+module Homebrew
+ module MissingFormula
+ class << self
+ def reason(name)
+ blacklisted_reason(name)
+ end
+
+ def blacklisted_reason(name)
+ case name.downcase
+ when "gem", /^rubygems?$/ then <<-EOS.undent
+ Homebrew provides gem via: `brew install ruby`.
+ EOS
+ when "tex", "tex-live", "texlive", "latex" then <<-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 dependencies)
+
+ We recommend using a MacTeX distribution: https://www.tug.org/mactex/
+
+ You can install it with Homebrew-Cask:
+ brew cask install mactex
+ EOS
+ when "pip" then <<-EOS.undent
+ Homebrew provides pip via: `brew install python`. However you will then
+ have two Pythons installed on your Mac, so alternatively you can install
+ pip via the instructions at:
+ #{Formatter.url("https://pip.readthedocs.io/en/stable/installing/")}
+ EOS
+ when "pil" then <<-EOS.undent
+ Instead of PIL, consider `pip install pillow` or `brew install Homebrew/python/pillow`.
+ EOS
+ when "macruby" then <<-EOS.undent
+ MacRuby is not packaged and is on an indefinite development hiatus.
+ You can read more about it at:
+ #{Formatter.url("https://github.com/MacRuby/MacRuby")}
+ EOS
+ when /(lib)?lzma/
+ "lzma is now part of the xz formula."
+ when "gtest", "googletest", "google-test" then <<-EOS.undent
+ Installing gtest system-wide is not recommended; it should be vendored
+ in your projects that use it.
+ EOS
+ when "gmock", "googlemock", "google-mock" then <<-EOS.undent
+ Installing gmock system-wide is not recommended; it should be vendored
+ in your projects that use it.
+ EOS
+ when "sshpass" then <<-EOS.undent
+ We won't add sshpass because it makes it too easy for novice SSH users to
+ ruin SSH's security.
+ EOS
+ when "gsutil" then <<-EOS.undent
+ Install gsutil with `pip install gsutil`
+ EOS
+ when "clojure" then <<-EOS.undent
+ Clojure isn't really a program but a library managed as part of a
+ project and Leiningen is the user interface to that library.
+
+ To install Clojure you should install Leiningen:
+ brew install leiningen
+ and then follow the tutorial:
+ #{Formatter.url("https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md")}
+ EOS
+ when "osmium" then <<-EOS.undent
+ The creator of Osmium requests that it not be packaged and that people
+ use the GitHub master branch instead.
+ EOS
+ when "gfortran" then <<-EOS.undent
+ GNU Fortran is now provided as part of GCC, and can be installed with:
+ brew install gcc
+ EOS
+ when "play" then <<-EOS.undent
+ 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")}
+ EOS
+ when "haskell-platform" then <<-EOS.undent
+ We no longer package haskell-platform. Consider installing ghc
+ and cabal-install instead:
+ brew install ghc cabal-install
+
+ You can install with Homebrew-Cask:
+ brew cask install haskell-platform
+ EOS
+ when "mysqldump-secure" then <<-EOS.undent
+ The creator of mysqldump-secure tried to game our popularity metrics.
+ EOS
+ when "ngrok" then <<-EOS.undent
+ Upstream sunsetted 1.x in March 2016 and 2.x is not open-source.
+
+ If you wish to use the 2.x release you can install with Homebrew-Cask:
+ brew cask install ngrok
+ EOS
+ end
+ end
+ alias generic_blacklisted_reason blacklisted_reason
+
+ require "extend/os/missing_formula"
+ end
+ end
+end
diff --git a/Library/Homebrew/test/blacklist_spec.rb b/Library/Homebrew/test/blacklist_spec.rb
deleted file mode 100644
index 01882167d..000000000
--- a/Library/Homebrew/test/blacklist_spec.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-require "blacklist"
-
-describe "Blacklist" do
- matcher(:be_blacklisted) { match(&method(:blacklisted?)) }
-
- context "rubygems" do
- %w[gem rubygem rubygems].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "latex" do
- %w[latex tex tex-live texlive TexLive].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "pip" do
- subject { "pip" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "pil" do
- subject { "pil" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "macruby" do
- subject { "MacRuby" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "lzma" do
- %w[lzma liblzma].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "gtest" do
- %w[gtest googletest google-test].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "gmock" do
- %w[gmock googlemock google-mock].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "sshpass" do
- subject { "sshpass" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "gsutil" do
- subject { "gsutil" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "clojure" do
- subject { "clojure" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "osmium" do
- %w[osmium Osmium].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
- context "gfortran" do
- subject { "gfortran" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "play" do
- subject { "play" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "haskell-platform" do
- subject { "haskell-platform" }
-
- it { is_expected.to be_blacklisted }
- end
-
- context "xcode", :needs_macos do
- %w[xcode Xcode].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-end
diff --git a/Library/Homebrew/test/missing_formula_spec.rb b/Library/Homebrew/test/missing_formula_spec.rb
new file mode 100644
index 000000000..11b93316f
--- /dev/null
+++ b/Library/Homebrew/test/missing_formula_spec.rb
@@ -0,0 +1,125 @@
+require "missing_formula"
+
+describe Homebrew::MissingFormula do
+ context ".reason" do
+ subject { described_class.reason("gem") }
+
+ it { is_expected.to_not be_nil }
+ end
+
+ context ".blacklisted_reason" do
+ matcher(:be_blacklisted) do
+ match(&Homebrew::MissingFormula.method(:blacklisted_reason))
+ end
+
+ context "rubygems" do
+ %w[gem rubygem rubygems].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "latex" do
+ %w[latex tex tex-live texlive TexLive].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "pip" do
+ subject { "pip" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "pil" do
+ subject { "pil" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "macruby" do
+ subject { "MacRuby" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "lzma" do
+ %w[lzma liblzma].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gtest" do
+ %w[gtest googletest google-test].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gmock" do
+ %w[gmock googlemock google-mock].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "sshpass" do
+ subject { "sshpass" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "gsutil" do
+ subject { "gsutil" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "clojure" do
+ subject { "clojure" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "osmium" do
+ %w[osmium Osmium].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+
+ context "gfortran" do
+ subject { "gfortran" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "play" do
+ subject { "play" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "haskell-platform" do
+ subject { "haskell-platform" }
+
+ it { is_expected.to be_blacklisted }
+ end
+
+ context "xcode", :needs_macos do
+ %w[xcode Xcode].each do |s|
+ subject { s }
+
+ it { is_expected.to be_blacklisted }
+ end
+ end
+ end
+end