aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/cask/lib/hbc.rb1
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb6
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/caveats.rb14
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl.rb14
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/caveats.rb107
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb26
-rw-r--r--Library/Homebrew/diagnostic.rb1
-rwxr-xr-xbin/brew5
11 files changed, 98 insertions, 84 deletions
diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb
index 01a085019..db036d279 100644
--- a/Library/Homebrew/cask/lib/hbc.rb
+++ b/Library/Homebrew/cask/lib/hbc.rb
@@ -11,7 +11,6 @@ require "hbc/caskroom"
require "hbc/checkable"
require "hbc/cli"
require "hbc/cask_dependencies"
-require "hbc/caveats"
require "hbc/container"
require "hbc/download"
require "hbc/download_strategy"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb
index 7505ac49a..94e906a73 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb
@@ -30,6 +30,12 @@ module Hbc
super(cask)
directives[:signal] = [*directives[:signal]].flatten.each_slice(2).to_a
@directives = directives
+
+ return unless directives.key?(:kext)
+
+ cask.caveats do
+ kext
+ end
end
def to_h
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb
index 72a23066f..df885371a 100644
--- a/Library/Homebrew/cask/lib/hbc/cask.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask.rb
@@ -24,7 +24,7 @@ module Hbc
end
DSL::DSL_METHODS.each do |method_name|
- define_method(method_name) { @dsl.send(method_name) }
+ define_method(method_name) { |&block| @dsl.send(method_name, &block) }
end
def timestamped_versions
diff --git a/Library/Homebrew/cask/lib/hbc/caveats.rb b/Library/Homebrew/cask/lib/hbc/caveats.rb
deleted file mode 100644
index 983d28874..000000000
--- a/Library/Homebrew/cask/lib/hbc/caveats.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-module Hbc
- class Caveats
- def initialize(block)
- @block = block
- end
-
- def eval_and_print(cask)
- dsl = DSL::Caveats.new(cask)
- retval = dsl.instance_eval(&@block)
- return if retval.nil?
- puts retval.to_s.sub(/[\r\n \t]*\Z/, "\n\n")
- end
- end
-end
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 215b59843..e2deb6f67 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -113,9 +113,9 @@ module Hbc
# other Ruby libraries must do everything via "require"
klass.run(*args)
end
- elsif which("brewcask-#{command}")
+ elsif external_command = which("brewcask-#{command}", ENV["HOMEBREW_PATH"])
# arbitrary external executable on PATH, Homebrew-style
- exec "brewcask-#{command}", *ARGV[1..-1]
+ exec external_command, *ARGV[1..-1]
elsif Pathname.new(command.to_s).executable? &&
command.to_s.include?("/") &&
!command.to_s.match(/\.rb$/)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index bafaadc24..bdb1c0c30 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -74,7 +74,7 @@ module Hbc
value = value[artifact_name] if artifact_name
end
- if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?)
+ if value.nil? || (value.respond_to?(:empty?) && value.empty?)
stanza_name = artifact_name ? artifact_name : stanza
raise CaskError, "no such stanza '#{stanza_name}' on Cask '#{cask}'"
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb
index 2db2c66a9..22f0d2f66 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl.rb
@@ -232,12 +232,16 @@ module Hbc
@staged_path = caskroom_path.join(cask_version.to_s)
end
- def caveats(*string, &block)
- @caveats ||= []
+ def caveats(*strings, &block)
+ @caveats ||= DSL::Caveats.new(cask)
if block_given?
- @caveats << Hbc::Caveats.new(block)
- elsif string.any?
- @caveats << string.map { |s| s.to_s.sub(/[\r\n \t]*\Z/, "\n\n") }
+ @caveats.eval_caveats(&block)
+ elsif strings.any?
+ strings.each do |string|
+ @caveats.eval_caveats { string }
+ end
+ else
+ return @caveats.to_s
end
@caveats
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/caveats.rb b/Library/Homebrew/cask/lib/hbc/dsl/caveats.rb
index 45ee5d160..a6cbdd6bf 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/caveats.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/caveats.rb
@@ -8,96 +8,132 @@
module Hbc
class DSL
class Caveats < Base
- def path_environment_variable(path)
- puts <<~EOS
+ def initialize(*args)
+ super(*args)
+ @built_in_caveats = {}
+ @custom_caveats = []
+ end
+
+ def self.caveat(name, &block)
+ define_method(name) do |*args|
+ key = [name, *args]
+ text = instance_exec(*args, &block)
+ @built_in_caveats[key] = text if text
+ :built_in_caveat
+ end
+ end
+
+ private_class_method :caveat
+
+ def to_s
+ (@custom_caveats + @built_in_caveats.values).join("\n")
+ end
+
+ # Override `puts` to collect caveats.
+ def puts(*args)
+ @custom_caveats += args
+ :built_in_caveat
+ end
+
+ def eval_caveats(&block)
+ result = instance_eval(&block)
+ return unless result
+ return if result == :built_in_caveat
+ @custom_caveats << result.to_s.sub(/\s*\Z/, "\n")
+ end
+
+ caveat :kext do
+ next if MacOS.version < :high_sierra
+ <<~EOS
+ To install and/or use #{@cask} you may need to enable their kernel extension in
+
+ System Preferences → Security & Privacy → General
+
+ For more information refer to vendor documentation or the Apple Technical Note:
+
+ #{Formatter.url("https://developer.apple.com/library/content/technotes/tn2459/_index.html")}
+ EOS
+ end
+
+ caveat :path_environment_variable do |path|
+ <<~EOS
To use #{@cask}, you may need to add the #{path} directory
to your PATH environment variable, eg (for bash shell):
export PATH=#{path}:"$PATH"
-
EOS
end
- def zsh_path_helper(path)
- puts <<~EOS
+ caveat :zsh_path_helper do |path|
+ <<~EOS
To use #{@cask}, zsh users may need to add the following line to their
~/.zprofile. (Among other effects, #{path} will be added to the
PATH environment variable):
eval `/usr/libexec/path_helper -s`
-
EOS
end
- def files_in_usr_local
- localpath = "/usr/local"
- return unless HOMEBREW_PREFIX.to_s.downcase.start_with?(localpath)
- puts <<~EOS
- Cask #{@cask} installs files under "#{localpath}". The presence of such
+ caveat :files_in_usr_local do
+ next unless HOMEBREW_PREFIX.to_s.downcase.start_with?("/usr/local")
+ <<~EOS
+ Cask #{@cask} installs files under /usr/local. The presence of such
files can cause warnings when running "brew doctor", which is considered
to be a bug in Homebrew-Cask.
-
EOS
end
- def depends_on_java(java_version = "any")
- if java_version == "any"
- puts <<~EOS
+ caveat :depends_on_java do |java_version = :any|
+ if java_version == :any
+ <<~EOS
#{@cask} requires Java. You can install the latest version with
brew cask install java
-
EOS
elsif java_version.include?("9") || java_version.include?("+")
- puts <<~EOS
+ <<~EOS
#{@cask} requires Java #{java_version}. You can install the latest version with
brew cask install java
-
EOS
else
- puts <<~EOS
+ <<~EOS
#{@cask} requires Java #{java_version}. You can install it with
brew cask install caskroom/versions/java#{java_version}
-
EOS
end
end
- def logout
- puts <<~EOS
- You must log out and log back in for the installation of #{@cask}
- to take effect.
-
+ caveat :logout do
+ <<~EOS
+ You must log out and log back in for the installation of #{@cask} to take effect.
EOS
end
- def reboot
- puts <<~EOS
+ caveat :reboot do
+ <<~EOS
You must reboot for the installation of #{@cask} to take effect.
-
EOS
end
- def discontinued
- puts <<~EOS
+ caveat :discontinued do
+ <<~EOS
#{@cask} has been officially discontinued upstream.
It may stop working correctly (or at all) in recent versions of macOS.
EOS
end
- def free_license(web_page)
- puts <<~EOS
+ caveat :free_license do |web_page|
+ <<~EOS
The vendor offers a free license for #{@cask} at
#{web_page}
-
EOS
end
- def malware(radar_number)
- puts <<~EOS
+ caveat :malware do |radar_number|
+ <<~EOS
#{@cask} has been reported to bundle malware. Like with any app, use at your own risk.
A report has been made to Apple about this app. Their certificate will hopefully be revoked.
@@ -108,7 +144,6 @@ module Hbc
#{Formatter.url("https://bugreport.apple.com/")}
If this report is a mistake, please let us know by opening an issue at
#{Formatter.url("https://github.com/caskroom/homebrew-cask/issues/new")}
-
EOS
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 553d947f9..8520f154d 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -35,30 +35,12 @@ module Hbc
def self.print_caveats(cask)
odebug "Printing caveats"
- return if cask.caveats.empty?
-
- output = capture_output do
- cask.caveats.each do |caveat|
- if caveat.respond_to?(:eval_and_print)
- caveat.eval_and_print(cask)
- else
- puts caveat
- end
- end
- end
- return if output.empty?
- ohai "Caveats"
- puts output
- end
+ caveats = cask.caveats
+ return if caveats.empty?
- def self.capture_output(&block)
- old_stdout = $stdout
- $stdout = Buffer.new($stdout.tty?)
- block.call
- output = $stdout.string
- $stdout = old_stdout
- output
+ ohai "Caveats"
+ puts caveats + "\n"
end
def fetch
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index e1b1bb8ee..61f9b53a3 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -180,6 +180,7 @@ module Homebrew
"libecomlodr.dylib", # Symantec Endpoint Protection
"libsymsea*.dylib", # Symantec Endpoint Protection
"sentinel.dylib", # SentinelOne
+ "sentinel-*.dylib", # SentinelOne
]
__check_stray_files "/usr/local/lib", "*.dylib", white_list, <<~EOS
diff --git a/bin/brew b/bin/brew
index f058fa34f..c330831b6 100755
--- a/bin/brew
+++ b/bin/brew
@@ -88,7 +88,8 @@ then
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
FILTERED_ENV=()
- for VAR in HOME SHELL PATH TERM LOGNAME USER CI TRAVIS \
+ for VAR in HOME SHELL PATH TERM LOGNAME USER CI TRAVIS SUDO_ASKPASS \
+ http_proxy https_proxy ftp_proxy HTTPS_PROXY FTP_PROXY \
"${!HOMEBREW_@}" "${!TRAVIS_@}" "${!JENKINS_@}"
do
# Skip if variable value is empty.
@@ -97,7 +98,7 @@ then
FILTERED_ENV+=( "${VAR}=${!VAR}" )
done
- /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
+ exec /usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
else
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
fi