diff options
44 files changed, 286 insertions, 169 deletions
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index c40ce8bf7..66908925c 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -105,7 +105,14 @@ then HOMEBREW_OS_USER_AGENT_VERSION="Mac OS X $HOMEBREW_MACOS_VERSION" printf -v HOMEBREW_MACOS_VERSION_NUMERIC "%02d%02d%02d" ${HOMEBREW_MACOS_VERSION//./ } - if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "100900" && + if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101000" ]] + then + HOMEBREW_SYSTEM_CURL_TOO_OLD="1" + fi + + # The system Curl is too old for some modern HTTPS certificates on + # older macOS versions. + if [[ -n "$HOMEBREW_SYSTEM_CURL_TOO_OLD" && -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] then HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb index 6670d4249..4e8edbc11 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb @@ -43,6 +43,10 @@ module Hbc return if (block = directives[dsl_key]).nil? class_for_dsl_key(dsl_key).new(cask).instance_eval(&block) end + + def summarize + directives.keys.map(&:to_s).join(", ") + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb index 2ce4f399d..badd549ce 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb @@ -28,6 +28,7 @@ module Hbc def initialize(cask, directives) super(cask) + directives[:signal] = [*directives[:signal]].flatten.each_slice(2).to_a @directives = directives end @@ -35,6 +36,10 @@ module Hbc directives.to_h end + def summarize + to_h.map { |key, val| [*val].map { |v| "#{key.inspect} => #{v.inspect}" }.join(", ") }.join(", ") + end + private def dispatch_uninstall_directives(**options) @@ -122,15 +127,15 @@ module Hbc end # :signal should come after :quit so it can be used as a backup when :quit fails - def uninstall_signal(*signals, **options) - signals.flatten.each_slice(2) do |pair| + def uninstall_signal(*signals, command: nil, **_) + signals.each do |pair| unless pair.size == 2 raise CaskInvalidError.new(cask, "Each #{stanza} :signal must consist of 2 elements.") end signal, bundle_id = pair ohai "Signalling '#{signal}' to application ID '#{bundle_id}'" - pids = running_processes(bundle_id, **options).map(&:first) + pids = running_processes(bundle_id, command: command).map(&:first) next unless pids.any? # Note that unlike :quit, signals are sent from the current user (not # upgraded to the superuser). This is a todo item for the future, but diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index 27f8ae791..72a23066f 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -41,6 +41,14 @@ module Hbc .reverse end + def full_name + if @tap.nil? || @tap == Hbc.default_tap + token + else + "#{@tap}/#{token}" + end + end + def installed? !versions.empty? end diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index dd9c61089..532d9f3c3 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -116,6 +116,22 @@ module Hbc end end + class FromInstanceLoader + attr_reader :cask + + def self.can_load?(ref) + ref.is_a?(Cask) + end + + def initialize(cask) + @cask = cask + end + + def load + cask + end + end + class NullLoader < FromPathLoader def self.can_load?(*) true @@ -149,6 +165,7 @@ module Hbc def self.for(ref) [ + FromInstanceLoader, FromURILoader, FromTapLoader, FromTapPathLoader, diff --git a/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb b/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb index 77f85301e..001a9623b 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb @@ -42,41 +42,32 @@ module Hbc @args = process_arguments(*args) end - def self.warn_unavailable_with_suggestion(cask_token, e) - exact_match, partial_matches = Search.search(cask_token) - error_message = e.message - if exact_match - error_message.concat(" Did you mean:\n#{exact_match}") - elsif !partial_matches.empty? - error_message.concat(" Did you mean one of:\n") - .concat(Formatter.columns(partial_matches.take(20))) - end - onoe error_message - end - private def casks(alternative: -> { [] }) - return to_enum(:casks, alternative: alternative) unless block_given? - - count = 0 - + return @casks if defined?(@casks) casks = args.empty? ? alternative.call : args + @casks = casks.map { |cask| CaskLoader.load(cask) } + rescue CaskUnavailableError => e + reason = [e.reason, suggestion_message(e.token)].join(" ") + raise e.class.new(e.token, reason) + end + + def suggestion_message(cask_token) + exact_match, partial_matches = Search.search(cask_token) - casks.each do |cask_or_token| - begin - yield cask_or_token.respond_to?(:token) ? cask_or_token : CaskLoader.load(cask_or_token) - count += 1 - rescue CaskUnavailableError => e - cask_token = cask_or_token - self.class.warn_unavailable_with_suggestion cask_token, e - rescue CaskError => e - onoe e.message - end + if exact_match.nil? && partial_matches.count == 1 + exact_match = partial_matches.first end - return :empty if casks.length.zero? - (count == casks.length) ? :complete : :incomplete + if exact_match + "Did you mean “#{exact_match}”?" + elsif !partial_matches.empty? + "Did you mean one of these?\n" + .concat(Formatter.columns(partial_matches.take(20))) + else + "" + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/cat.rb b/Library/Homebrew/cask/lib/hbc/cli/cat.rb index d08c87bea..043080556 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/cat.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/cat.rb @@ -7,10 +7,6 @@ module Hbc end def run - raise CaskError, "Cat incomplete." if cat_casks == :incomplete - end - - def cat_casks casks.each do |cask| puts File.open(cask.sourcefile_path, &:read) end diff --git a/Library/Homebrew/cask/lib/hbc/cli/edit.rb b/Library/Homebrew/cask/lib/hbc/cli/edit.rb index b9485886c..8bce81c52 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/edit.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/edit.rb @@ -4,21 +4,18 @@ module Hbc def initialize(*) super raise CaskUnspecifiedError if args.empty? - raise ArgumentError, "Only one Cask can be created at a time." if args.count > 1 + raise ArgumentError, "Only one Cask can be edited at a time." if args.count > 1 end def run - cask_token = args.first - cask_path = begin - CaskLoader.load(cask_token).sourcefile_path - rescue CaskUnavailableError => e - reason = e.reason.empty? ? "" : "#{e.reason} " - reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.") - raise e.class.new(e.token, reason) - end - - odebug "Opening editor for Cask #{cask_token}" + cask = casks.first + cask_path = cask.sourcefile_path + odebug "Opening editor for Cask #{cask.token}" exec_editor cask_path + rescue CaskUnavailableError => e + reason = e.reason.empty? ? "" : "#{e.reason} " + reason.concat("Run #{Formatter.identifier("brew cask create #{e.token}")} to create a new Cask.") + raise e.class.new(e.token, reason) end def self.help diff --git a/Library/Homebrew/cask/lib/hbc/cli/fetch.rb b/Library/Homebrew/cask/lib/hbc/cli/fetch.rb index e31b1a17c..12c794f5f 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/fetch.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/fetch.rb @@ -9,10 +9,6 @@ module Hbc end def run - raise CaskError, "Fetch incomplete." if fetch_casks == :incomplete - end - - def fetch_casks casks.each do |cask| ohai "Downloading external files for Cask #{cask}" downloaded_path = Download.new(cask, force: force?).perform diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb index 0f1a5dd34..9a2116e6a 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/install.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb @@ -10,10 +10,6 @@ module Hbc end def run - raise CaskError, "Install incomplete." if install_casks == :incomplete - end - - def install_casks casks.each do |cask| begin Installer.new(cask, binaries: binaries?, diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index cd2679782..a538ffd8c 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -12,7 +12,7 @@ module Hbc if args.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ } self.class.appcask_checkpoint_for_url(args) else - self.class.appcask_checkpoint(args, calculate?) + self.class.appcask_checkpoint(casks, calculate?) end end @@ -23,33 +23,27 @@ module Hbc end end - def self.appcask_checkpoint(cask_tokens, calculate) - count = 0 - - cask_tokens.each do |cask_token| - cask = CaskLoader.load(cask_token) - + def self.appcask_checkpoint(casks, calculate) + casks.each do |cask| if cask.appcast.nil? opoo "Cask '#{cask}' is missing an `appcast` stanza." else - if calculate + checkpoint = if calculate result = cask.appcast.calculate_checkpoint - - checkpoint = result[:checkpoint] + result[:checkpoint] else - checkpoint = cask.appcast.checkpoint + cask.appcast.checkpoint end - if checkpoint.nil? + if calculate && checkpoint.nil? onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" + elsif casks.count > 1 + puts "#{checkpoint} #{cask}" else - puts((cask_tokens.count > 1) ? "#{checkpoint} #{cask}" : checkpoint) - count += 1 + puts checkpoint end end end - - count == cask_tokens.count end def self.help diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index 46273cbe3..8a38ce1be 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -7,10 +7,6 @@ module Hbc end def run - raise CaskError, "Dump incomplete." if dump_casks == :incomplete - end - - def dump_casks casks.each(&:dumpcask) end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 018b4e9ca..c04619798 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -46,12 +46,6 @@ module Hbc end def run - return unless print_stanzas == :incomplete - exit 1 if quiet? - raise CaskError, "Print incomplete." - end - - def print_stanzas if ARTIFACTS.include?(stanza) artifact_name = stanza @stanza = :artifacts diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 4b5fcd873..32415af8a 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -3,6 +3,7 @@ module Hbc class List < AbstractCommand option "-1", :one, false option "--versions", :versions, false + option "--full-name", :full_name, false option "-l", (lambda do |*| one = true # rubocop:disable Lint/UselessAssignment @@ -10,8 +11,7 @@ module Hbc end) def run - retval = args.any? ? list : list_installed - raise CaskError, "Listing incomplete." if retval == :incomplete + args.any? ? list : list_installed end def list @@ -43,11 +43,11 @@ module Hbc puts installed_casks.map(&:to_s) elsif versions? puts installed_casks.map(&self.class.method(:format_versioned)) + elsif full_name? + puts installed_casks.map(&:full_name).sort &tap_and_name_comparison elsif !installed_casks.empty? puts Formatter.columns(installed_casks.map(&:to_s)) end - - installed_casks.empty? ? :empty : :complete end def self.format_versioned(cask) diff --git a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb index 337a2eb9d..408be134d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb @@ -1,7 +1,7 @@ module Hbc class CLI class Reinstall < Install - def install_casks + def run casks.each do |cask| Installer.new(cask, binaries: binaries?, verbose: verbose?, diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb index c0697c808..7e55db5f1 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb @@ -9,10 +9,6 @@ module Hbc end def run - raise CaskError, "Uninstall incomplete." if uninstall_casks == :incomplete - end - - def uninstall_casks casks.each do |cask| odebug "Uninstalling Cask #{cask}" diff --git a/Library/Homebrew/cask/lib/hbc/cli/zap.rb b/Library/Homebrew/cask/lib/hbc/cli/zap.rb index e709f4191..7f5e6785d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/zap.rb @@ -9,10 +9,6 @@ module Hbc end def run - raise CaskError, "Zap incomplete." if zap_casks == :incomplete - end - - def zap_casks casks.each do |cask| odebug "Zapping Cask #{cask}" Installer.new(cask, verbose: verbose?, force: force?).zap diff --git a/Library/Homebrew/cmd/irb.rb b/Library/Homebrew/cmd/irb.rb index cba8a5b82..4cd3d4c9e 100644 --- a/Library/Homebrew/cmd/irb.rb +++ b/Library/Homebrew/cmd/irb.rb @@ -19,15 +19,13 @@ class String end end -def cask - $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") - require "hbc" -end - module Homebrew module_function def irb + $LOAD_PATH.unshift("#{HOMEBREW_LIBRARY_PATH}/cask/lib") + require "hbc" + if ARGV.include? "--examples" puts "'v8'.f # => instance of the v8 formula" puts ":hub.f.installed?" diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index f5c4e68ac..436fc1f97 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -39,15 +39,7 @@ module Homebrew filtered_list elsif ARGV.named.empty? if ARGV.include? "--full-name" - full_names = Formula.installed.map(&:full_name).sort do |a, b| - if a.include?("/") && !b.include?("/") - 1 - elsif !a.include?("/") && b.include?("/") - -1 - else - a <=> b - end - end + full_names = Formula.installed.map(&:full_name).sort &tap_and_name_comparison return if full_names.empty? puts Formatter.columns(full_names) else diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index fb6a3459c..e8211e4dd 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -385,6 +385,12 @@ EOS if ! git --version >/dev/null 2>&1 then + # we need a new enough curl to install git + if [[ -n "$HOMEBREW_SYSTEM_CURL_TOO_OLD" && + ! -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] + then + brew install curl + fi # we cannot install brewed git if homebrew/core is unavailable. [[ -d "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" ]] && brew install git unset GIT_EXECUTABLE diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 24e0eb4ff..e2a288fdb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -202,12 +202,12 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default], check_content: false, strict: false) + def self.check_http_content(url, user_agents: [:default], check_content: false, strict: false, require_http: false) return unless url.start_with? "http" details = nil user_agent = nil - hash_needed = url.start_with?("http:") && name != "curl" + hash_needed = url.start_with?("http:") && !require_http user_agents.each do |ua| details = http_content_headers_and_checksum(url, hash_needed: hash_needed, user_agent: ua) user_agent = ua @@ -574,9 +574,8 @@ class FormulaAuditor return unless @online - return unless DevelopmentTools.curl_handles_most_https_homepages? + return unless DevelopmentTools.curl_handles_most_https_certificates? if http_content_problem = FormulaAuditor.check_http_content(homepage, - formula.name, user_agents: [:browser, :default], check_content: true, strict: @strict) @@ -629,13 +628,14 @@ class FormulaAuditor end %w[Stable Devel HEAD].each do |name| - next unless spec = formula.send(name.downcase) + spec_name = name.downcase.to_sym + next unless spec = formula.send(spec_name) - ra = ResourceAuditor.new(spec, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name}: #{problem}" } spec.resources.each_value do |resource| - ra = ResourceAuditor.new(resource, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name} resource #{resource.name.inspect}: #{problem}" } @@ -1086,10 +1086,10 @@ class FormulaAuditor end class ResourceAuditor - attr_reader :problems - attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name + attr_reader :name, :version, :checksum, :url, :mirrors, :using, :specs, :owner + attr_reader :spec_name, :problems - def initialize(resource, options = {}) + def initialize(resource, spec_name, options = {}) @name = resource.name @version = resource.version @checksum = resource.checksum @@ -1097,9 +1097,11 @@ class ResourceAuditor @mirrors = resource.mirrors @using = resource.using @specs = resource.specs - @online = options[:online] - @strict = options[:strict] - @problems = [] + @owner = resource.owner + @spec_name = spec_name + @online = options[:online] + @strict = options[:strict] + @problems = [] end def audit @@ -1173,11 +1175,29 @@ class ResourceAuditor problem "Redundant :using value in URL" end + def self.curl_openssl_and_deps + @curl_openssl_and_deps ||= begin + formulae_names = ["curl", "openssl"] + formulae_names += formulae_names.flat_map do |f| + Formula[f].recursive_dependencies.map(&:name) + end + formulae_names.uniq + rescue FormulaUnavailableError + [] + end + end + def audit_urls urls = [url] + mirrors - if name == "curl" && !urls.find { |u| u.start_with?("http://") } - problem "should always include at least one HTTP url" + curl_openssl_or_deps = ResourceAuditor.curl_openssl_and_deps.include?(owner.name) + + if spec_name == :stable && curl_openssl_or_deps + problem "should not use xz tarballs" if url.end_with?(".xz") + + unless urls.find { |u| u.start_with?("http://") } + problem "should always include at least one HTTP mirror" + end end return unless @online @@ -1189,7 +1209,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name) + if http_content_problem = FormulaAuditor.check_http_content(url, require_http: curl_openssl_or_deps) problem http_content_problem end elsif strategy <= GitDownloadStrategy diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index 996dea87c..b7787d849 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -114,7 +114,7 @@ class DevelopmentTools @non_apple_gcc_version = {} end - def curl_handles_most_https_homepages? + def curl_handles_most_https_certificates? true end diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index caa85ffca..66b3bf9d2 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -43,11 +43,16 @@ class DevelopmentTools end def custom_installation_instructions - if MacOS.version > :tiger + if MacOS.version > :leopard <<-EOS.undent Install GNU's GCC brew install gcc EOS + elsif MacOS.version > :tiger + <<-EOS.undent + Install GNU's GCC + brew install gcc@4.6 + EOS else # Tiger doesn't ship with apple-gcc42, and this is required to build # some software that doesn't build properly with FSF GCC. @@ -55,7 +60,7 @@ class DevelopmentTools Install Apple's GCC brew install apple-gcc42 or GNU's GCC - brew install gcc + brew install gcc@4.6 EOS end end @@ -77,10 +82,10 @@ class DevelopmentTools end end - def curl_handles_most_https_homepages? - # The system Curl is too old for some modern HTTPS homepages on + def curl_handles_most_https_certificates? + # The system Curl is too old for some modern HTTPS certificates on # older macOS versions. - MacOS.version >= :el_capitan + !ENV["HOMEBREW_SYSTEM_CURL_TOO_OLD"].nil? end def subversion_handles_most_https_certificates? diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 0cdd7b115..ab5433565 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -197,6 +197,7 @@ module Homebrew def check_ruby_version ruby_version = "2.0" return if RUBY_VERSION[/\d\.\d/] == ruby_version + return if ARGV.homebrew_developer? && OS::Mac.prerelease? <<-EOS.undent Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 216a375ce..e955dcf07 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -603,6 +603,12 @@ class FormulaInstaller # let's reset Utils.git_available? if we just installed git Utils.clear_git_available_cache if formula.name == "git" + + # use installed curl when it's needed and available + if formula.name == "curl" && + !DevelopmentTools.curl_handles_most_https_certificates? + ENV["HOMEBREW_CURL"] = formula.opt_bin/"curl" + end ensure unlock end diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index ad4c01021..085748632 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -156,7 +156,7 @@ class Keg libtool_files = [] path.find do |pn| - next if pn.symlink? || pn.directory? || pn.extname != ".la" + next if pn.symlink? || pn.directory? || ![".la", ".lai"].include?(pn.extname) libtool_files << pn end libtool_files diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 37bc55a2f..59e7026bd 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -216,7 +216,7 @@ module OS # on the older supported platform for that Xcode release, i.e there's no # CLT package for 10.11 that contains the Clang version from Xcode 8. case MacOS.version - when "10.13" then "900.0.35" + when "10.13" then "900.0.37" when "10.12" then "802.0.42" when "10.11" then "800.0.42.1" when "10.10" then "700.1.81" diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb index a6ecc207f..5858a7c6d 100644 --- a/Library/Homebrew/test/cask/cask_spec.rb +++ b/Library/Homebrew/test/cask/cask_spec.rb @@ -171,4 +171,38 @@ describe Hbc::Cask, :cask do end end end + + describe "full_name" do + context "when it is a core cask" do + it "is the cask token" do + c = Hbc::CaskLoader.load("local-caffeine") + expect(c.full_name).to eq("local-caffeine") + end + end + + context "when it is from a non-core tap" do + it "returns the fully-qualified name of the cask" do + c = Hbc::CaskLoader.load("third-party/tap/third-party-cask") + expect(c.full_name).to eq("third-party/tap/third-party-cask") + end + end + + context "when it is from no known tap" do + it "retuns the cask token" do + file = Tempfile.new(%w[tapless-cask .rb]) + + begin + cask_name = File.basename(file.path, ".rb") + file.write "cask '#{cask_name}'" + file.close + + c = Hbc::CaskLoader.load(file.path) + expect(c.full_name).to eq(cask_name) + ensure + file.close + file.unlink + end + end + end + end end diff --git a/Library/Homebrew/test/cask/cli/audit_spec.rb b/Library/Homebrew/test/cask/cli/audit_spec.rb index 01f506c8c..30ab437cb 100644 --- a/Library/Homebrew/test/cask/cli/audit_spec.rb +++ b/Library/Homebrew/test/cask/cli/audit_spec.rb @@ -1,8 +1,10 @@ describe Hbc::CLI::Audit, :cask do - let(:cask) { double("cask", token: nil) } + let(:cask) { Hbc::Cask.new(nil) } describe "selection of Casks to audit" do it "audits all Casks if no tokens are given" do + expect(cask).to be_a Hbc::Cask + allow(Hbc).to receive(:all).and_return([cask, cask]) expect(Hbc::Auditor).to receive(:audit).twice.and_return(true) diff --git a/Library/Homebrew/test/cask/cli/cat_spec.rb b/Library/Homebrew/test/cask/cli/cat_spec.rb index b726a0b36..5a4b29c6f 100644 --- a/Library/Homebrew/test/cask/cli/cat_spec.rb +++ b/Library/Homebrew/test/cask/cli/cat_spec.rb @@ -35,8 +35,7 @@ describe Hbc::CLI::Cat, :cask do it "raises an exception when the Cask does not exist" do expect { Hbc::CLI::Cat.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Cat incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/create_spec.rb b/Library/Homebrew/test/cask/cli/create_spec.rb index d77b0a2aa..17d426f78 100644 --- a/Library/Homebrew/test/cask/cli/create_spec.rb +++ b/Library/Homebrew/test/cask/cli/create_spec.rb @@ -39,7 +39,7 @@ describe Hbc::CLI::Create, :cask do it "raises an exception when more than one Cask is given" do expect { described_class.run("additional-cask", "another-cask") - }.to raise_error(/Only one Cask can be created at a time./) + }.to raise_error(/Only one Cask can be created at a time\./) end it "raises an exception when the Cask already exists" do diff --git a/Library/Homebrew/test/cask/cli/edit_spec.rb b/Library/Homebrew/test/cask/cli/edit_spec.rb index 5d5cbf4b9..51542807f 100644 --- a/Library/Homebrew/test/cask/cli/edit_spec.rb +++ b/Library/Homebrew/test/cask/cli/edit_spec.rb @@ -12,7 +12,7 @@ describe Hbc::CLI::Edit, :cask do it "raises an error when given more than one argument" do expect { described_class.new("local-caffeine", "local-transmission") - }.to raise_error(/Only one Cask can be created at a time./) + }.to raise_error(/Only one Cask can be edited at a time\./) end it "raises an exception when the Cask doesnt exist" do diff --git a/Library/Homebrew/test/cask/cli/fetch_spec.rb b/Library/Homebrew/test/cask/cli/fetch_spec.rb index f71c23fb6..faaa69b35 100644 --- a/Library/Homebrew/test/cask/cli/fetch_spec.rb +++ b/Library/Homebrew/test/cask/cli/fetch_spec.rb @@ -42,7 +42,7 @@ describe Hbc::CLI::Fetch, :cask do it "properly handles Casks that are not present" do expect { Hbc::CLI::Fetch.run("notacask") - }.to raise_error(Hbc::CaskError, "Fetch incomplete.") + }.to raise_error(Hbc::CaskUnavailableError) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/install_spec.rb b/Library/Homebrew/test/cask/cli/install_spec.rb index 64feacce9..e30489789 100644 --- a/Library/Homebrew/test/cask/cli/install_spec.rb +++ b/Library/Homebrew/test/cask/cli/install_spec.rb @@ -56,27 +56,19 @@ describe Hbc::CLI::Install, :cask do it "properly handles Casks that are not present" do expect { Hbc::CLI::Install.run("notacask") - }.to raise_error(Hbc::CaskError, "Install incomplete.") + }.to raise_error(Hbc::CaskUnavailableError) end it "returns a suggestion for a misspelled Cask" do expect { - begin - Hbc::CLI::Install.run("localcaffeine") - rescue Hbc::CaskError - nil - end - }.to output(/Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean:\nlocal-caffeine/).to_stderr + Hbc::CLI::Install.run("localcaffeine") + }.to raise_error(Hbc::CaskUnavailableError, /Cask 'localcaffeine' is unavailable: No Cask with this name exists\. Did you mean “local-caffeine”?/) end it "returns multiple suggestions for a Cask fragment" do expect { - begin - Hbc::CLI::Install.run("local-caf") - rescue Hbc::CaskError - nil - end - }.to output(/Cask 'local-caf' is unavailable: No Cask with this name exists\. Did you mean one of:\nlocal-caffeine/).to_stderr + Hbc::CLI::Install.run("local") + }.to raise_error(Hbc::CaskUnavailableError, /Cask 'local' is unavailable: No Cask with this name exists\. Did you mean one of these\?\nlocal-caffeine\nlocal-transmission/) end describe "when no Cask is specified" do diff --git a/Library/Homebrew/test/cask/cli/list_spec.rb b/Library/Homebrew/test/cask/cli/list_spec.rb index fd6997f41..d2d7efd3b 100644 --- a/Library/Homebrew/test/cask/cli/list_spec.rb +++ b/Library/Homebrew/test/cask/cli/list_spec.rb @@ -14,6 +14,26 @@ describe Hbc::CLI::List, :cask do EOS end + it "lists full names" do + casks = %w[ + local-caffeine + third-party/tap/third-party-cask + local-transmission + ].map { |c| Hbc::CaskLoader.load(c) } + + casks.each do |c| + InstallHelper.install_with_caskfile(c) + end + + expect { + Hbc::CLI::List.run("--full-name") + }.to output(<<-EOS.undent).to_stdout + local-caffeine + local-transmission + third-party/tap/third-party-cask + EOS + end + describe "lists versions" do let(:casks) { ["local-caffeine", "local-transmission"] } let(:expected_output) { diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 1a1c57e88..2ec506839 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -16,14 +16,12 @@ describe Hbc::CLI::Uninstall, :cask do it "shows an error when a bad Cask is provided" do expect { Hbc::CLI::Uninstall.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end it "shows an error when a Cask is provided that's not installed" do expect { Hbc::CLI::Uninstall.run("local-caffeine") } - .to output(/is not installed/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskNotInstalledError, /is not installed/) end it "tries anyway on a non-present Cask when --force is given" do @@ -76,8 +74,7 @@ describe Hbc::CLI::Uninstall, :cask do Hbc.appdir.join("MyFancyApp.app").rmtree expect { Hbc::CLI::Uninstall.run("with-uninstall-script-app") } - .to output(/does not exist/).to_stderr - .and raise_error(Hbc::CaskError, "Uninstall incomplete.") + .to raise_error(Hbc::CaskError, /uninstall script .* does not exist/) expect(cask).to be_installed diff --git a/Library/Homebrew/test/cask/cli/zap_spec.rb b/Library/Homebrew/test/cask/cli/zap_spec.rb index fdc5b4125..502bf8e69 100644 --- a/Library/Homebrew/test/cask/cli/zap_spec.rb +++ b/Library/Homebrew/test/cask/cli/zap_spec.rb @@ -1,8 +1,7 @@ describe Hbc::CLI::Zap, :cask do it "shows an error when a bad Cask is provided" do expect { Hbc::CLI::Zap.run("notacask") } - .to output(/is unavailable/).to_stderr - .and raise_error(Hbc::CaskError, "Zap incomplete.") + .to raise_error(Hbc::CaskUnavailableError, /is unavailable/) end it "can zap and unlink multiple Casks at once" do diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index d6186e46b..83d95c2ef 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -47,15 +47,10 @@ describe Homebrew::Diagnostic::Checks do end specify "#check_ruby_version" do - allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.13")) - stub_const("RUBY_VERSION", "2.3.3p222") + allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.12")) + stub_const("RUBY_VERSION", "1.8.6") expect(subject.check_ruby_version) - .to match <<-EOS.undent - Ruby version 2.3.3p222 is unsupported on 10.13. Homebrew - is developed and tested on Ruby 2.0, and may not work correctly - on other Rubies. Patches are accepted as long as they don't cause breakage - on supported Rubies. - EOS + .to match "Ruby version 1.8.6 is unsupported on 10.12" end end diff --git a/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb b/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb new file mode 100644 index 000000000..d7add0522 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/third-party/Casks/third-party-cask.rb @@ -0,0 +1,9 @@ +cask 'third-party-cask' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url 'http://example.com/ThirdParty.dmg' + homepage 'http://example.com/' + + app 'ThirdParty.app' +end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb index c51d339a7..fc83149d0 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb @@ -18,6 +18,7 @@ HOMEBREW_CASK_DIRS = [ RSpec.shared_context "Homebrew-Cask" do around(:each) do |example| + third_party_tap = Tap.fetch("third-party", "tap") begin dirs = HOMEBREW_CASK_DIRS.map do |dir| Pathname.new(TEST_TMPDIR).join("cask-#{dir}").tap do |path| @@ -31,11 +32,18 @@ RSpec.shared_context "Homebrew-Cask" do FileUtils.ln_sf TEST_FIXTURE_DIR.join("cask"), tap.path end + third_party_tap.tap do |tap| + FileUtils.mkdir_p tap.path.dirname + FileUtils.ln_sf TEST_FIXTURE_DIR.join("third-party"), tap.path + end + example.run ensure FileUtils.rm_rf dirs Hbc.default_tap.path.unlink FileUtils.rm_rf Hbc.default_tap.path.parent + third_party_tap.path.unlink + FileUtils.rm_rf third_party_tap.path.parent end end end diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index 37bd83c4f..3b5355b15 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -296,4 +296,33 @@ describe "globally-scoped helper methods" do expect(ENV["PATH"]).not_to eq("/bin") end end + + describe "#tap_and_name_comparison" do + describe "both strings are only names" do + it "alphabetizes the strings" do + expect(%w[a b].sort(&tap_and_name_comparison)).to eq(%w[a b]) + expect(%w[b a].sort(&tap_and_name_comparison)).to eq(%w[a b]) + end + end + + describe "both strings include tap" do + it "alphabetizes the strings" do + expect(%w[a/z/z b/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z]) + expect(%w[b/z/z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[a/z/z b/z/z]) + + expect(%w[z/a/z z/b/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z]) + expect(%w[z/b/z z/a/z].sort(&tap_and_name_comparison)).to eq(%w[z/a/z z/b/z]) + + expect(%w[z/z/a z/z/b].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b]) + expect(%w[z/z/b z/z/a].sort(&tap_and_name_comparison)).to eq(%w[z/z/a z/z/b]) + end + end + + describe "only one string includes tap" do + it "prefers the string without tap" do + expect(%w[a/z/z z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z]) + expect(%w[z a/z/z].sort(&tap_and_name_comparison)).to eq(%w[z a/z/z]) + end + end + end end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 07e339576..3033eb4dd 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -560,3 +560,15 @@ end def shell_profile Utils::Shell.profile end + +def tap_and_name_comparison + proc do |a, b| + if a.include?("/") && !b.include?("/") + 1 + elsif !a.include?("/") && b.include?("/") + -1 + else + a <=> b + end + end +end diff --git a/Library/Homebrew/utils/popen.rb b/Library/Homebrew/utils/popen.rb index 4e03711a1..bcdd815bb 100644 --- a/Library/Homebrew/utils/popen.rb +++ b/Library/Homebrew/utils/popen.rb @@ -13,7 +13,7 @@ module Utils return pipe.read unless block_given? yield pipe else - $stderr.reopen("/dev/null", "w") + $stderr.reopen("/dev/null", "w") if !ARGV.debug? && !ARGV.verbose? exec(*args) end end diff --git a/docs/Installation.md b/docs/Installation.md index e36ed3efa..9f091d2e5 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -47,7 +47,7 @@ PowerPC and Tiger branches from other users in the fork network. See [Interesting Taps and Forks](Interesting-Taps-and-Forks.md). <a name="2"><sup>2</sup></a> 10.10 or higher is recommended. 10.5–10.9 are -supported on a best-effort basis. For 10.4 and 10.5, see +supported on a best-effort basis. For 10.4 see [Tigerbrew](https://github.com/mistydemeo/tigerbrew). <a name="3"><sup>3</sup></a> Most formulae require a compiler. A handful |
