From 84e41194cb20c2a88d6c3cfcf51575fce6eb4f02 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Fri, 3 Nov 2017 19:09:53 -0300 Subject: [PATCH 01/69] Let Cask doctor exit with 1 via a CaskError --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index d7bcf15379..e439c871b4 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -3,6 +3,8 @@ require "system_config" module Hbc class CLI class Doctor < AbstractCommand + attr_accessor :failed + def initialize(*) super return if args.empty? @@ -35,6 +37,8 @@ module Hbc ] (self.class.locale_variables + environment_variables).sort.each(&self.class.method(:render_env_var)) + + raise CaskError, "One or more checks failed." if @failed end def self.locale_variables @@ -61,6 +65,7 @@ module Hbc def self.cask_count_for_tap(tap) Formatter.pluralize(tap.cask_files.count, "cask") rescue StandardError + @failed = true "0 #{error_string "error reading #{tap.path}"}" end @@ -92,6 +97,7 @@ module Hbc if locations.empty? none_string else + @failed = true locations.collect do |l| "#{l} #{error_string 'error: legacy install. Run "brew uninstall --force brew-cask".'}" end @@ -101,8 +107,10 @@ module Hbc def self.render_staging_location(path) path = Pathname.new(user_tilde(path.to_s)) if !path.exist? + @failed = true "#{path} #{error_string "error: path does not exist"}" elsif !path.writable? + @failed = true "#{path} #{error_string "error: not writable by current user"}" else path From 691caf4b54bb17d183aefc48e0a39bbaa0d19739 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Sat, 2 Dec 2017 00:53:54 +0000 Subject: [PATCH 02/69] Refactor Cask's doctor command - Remove :failed - Use Checkable to store the status and warnings/errors - Refactor the methods using audit as basis --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 127 ++++++++++++++++++-- 1 file changed, 114 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index e439c871b4..ff4a37bcfc 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -1,9 +1,10 @@ require "system_config" +require "hbc/checkable" module Hbc class CLI class Doctor < AbstractCommand - attr_accessor :failed + include Checkable def initialize(*) super @@ -11,16 +12,103 @@ module Hbc raise ArgumentError, "#{self.class.command_name} does not take arguments." end + def success? + !(errors? || warnings?) + end + + def summary_header + "Cask's Doctor checkup" + end + def run + check_software_versions + check_install_location + check_staging_location + check_taps + check_load_path + check_environment_variables + + puts summary unless success? + raise CaskError, "Your system is not ready for Cask." unless success? + end + + def check_software_versions ohai "Homebrew-Cask Version", Hbc.full_version ohai "macOS", MacOS.full_version ohai "Java", SystemConfig.describe_java - ohai "Homebrew-Cask Install Location", self.class.render_install_location - ohai "Homebrew-Cask Staging Location", self.class.render_staging_location(Hbc.caskroom) - ohai "Homebrew-Cask Cached Downloads", self.class.render_cached_downloads + end + + # This could be done by calling into Homebrew, but the situation + # where "doctor" is needed is precisely the situation where such + # things are less dependable. + def check_install_location + ohai "Homebrew-Cask Install Location" + + locations = Dir.glob(HOMEBREW_CELLAR.join("brew-cask", "*")).reverse + if locations.empty? + puts self.class.none_string + else + locations.collect do |l| + add_error "Legacy install at #{l}. Run \"brew uninstall --force brew-cask\"." + puts l + end + end + end + + def check_staging_location + ohai "Homebrew-Cask Staging Location" + + path = Pathname.new(user_tilde(Hbc.caskroom.to_s)) + + if !path.exist? + add_error "The staging path #{path} does not exist." + elsif !path.writable? + add_error "The staging path #{path} is not writable by the current user." + end + + puts path + end + + def check_cached_downloads + ohai "Homebrew-Cask Cached Downloads" + + cleanup = CLI::Cleanup.new + count = cleanup.cache_files.count + size = cleanup.disk_cleanup_size + msg = user_tilde(Hbc.cache.to_s) + msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? + puts msg + end + + def check_taps ohai "Homebrew-Cask Taps:" - puts self.class.render_taps(Hbc.default_tap, *self.class.alt_taps) - ohai "Contents of $LOAD_PATH", self.class.render_load_path($LOAD_PATH) + + default_tap = [Hbc.default_tap] + + alt_taps = Tap.select { |t| t.cask_dir.exist? && t != Hbc.default_tap } + + (default_tap + alt_taps).each do |tap| + if tap.path.nil? || tap.path.to_s.empty? + puts none_string + else + puts "#{tap.path} (#{cask_count_for_tap(tap)})" + end + end + end + + def check_load_path + ohai "Contents of $LOAD_PATH" + paths = $LOAD_PATH.map(&method(:user_tilde)) + + if paths.empty? + puts none_string + add_error "$LOAD_PATH is empty" + else + puts paths + end + end + + def check_environment_variables ohai "Environment Variables" environment_variables = %w[ @@ -36,9 +124,25 @@ module Hbc SHELL ] - (self.class.locale_variables + environment_variables).sort.each(&self.class.method(:render_env_var)) + locale_variables = ENV.keys.grep(/^(?:LC_\S+|LANG|LANGUAGE)\Z/).sort - raise CaskError, "One or more checks failed." if @failed + (locale_variables + environment_variables).sort.each(&method(:render_env_var)) + end + + def user_tilde(path) + self.class.user_tilde(path) + end + + def cask_count_for_tap(tap) + self.class.cask_count_for_tap(tap) + end + + def none_string + self.class.none_string + end + + def render_env_var(var) + self.class.render_env_var(var) end def self.locale_variables @@ -65,8 +169,8 @@ module Hbc def self.cask_count_for_tap(tap) Formatter.pluralize(tap.cask_files.count, "cask") rescue StandardError - @failed = true - "0 #{error_string "error reading #{tap.path}"}" + add_error "Unable to read from Tap: #{tap.path}" + "0" end def self.render_taps(*taps) @@ -97,7 +201,6 @@ module Hbc if locations.empty? none_string else - @failed = true locations.collect do |l| "#{l} #{error_string 'error: legacy install. Run "brew uninstall --force brew-cask".'}" end @@ -107,10 +210,8 @@ module Hbc def self.render_staging_location(path) path = Pathname.new(user_tilde(path.to_s)) if !path.exist? - @failed = true "#{path} #{error_string "error: path does not exist"}" elsif !path.writable? - @failed = true "#{path} #{error_string "error: not writable by current user"}" else path From 06f2b50ee4b1b5db6737c4dc670536ca97cc7bb4 Mon Sep 17 00:00:00 2001 From: Kevin Abel Date: Tue, 9 Jan 2018 19:56:54 -0600 Subject: [PATCH 03/69] Fix cached download file extension for certain URL PHP URLs have the downloadable file in the middle of the pathname. If no extension is detected, continue up the pathname. --- Library/Homebrew/download_strategy.rb | 6 +++++- Library/Homebrew/test/download_strategies_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index feb518057f..6869d33703 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -303,7 +303,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy # We can't use basename_without_params, because given a URL like # https://example.com/download.php?file=foo-1.0.tar.gz # the extension we want is ".tar.gz", not ".php". - Pathname.new(@url).extname[/[^?]+/] + url_pathname = Pathname.new(@url) + while !ext = url_pathname.extname[/[^?]+/] + url_pathname = url_pathname.dirname + end + ext end end diff --git a/Library/Homebrew/test/download_strategies_spec.rb b/Library/Homebrew/test/download_strategies_spec.rb index 06d6fa855c..7ad070fc44 100644 --- a/Library/Homebrew/test/download_strategies_spec.rb +++ b/Library/Homebrew/test/download_strategies_spec.rb @@ -209,6 +209,19 @@ describe CurlDownloadStrategy do it "parses the opts and sets the corresponding args" do expect(subject.send(:_curl_opts)).to eq(["--user", "download:123456"]) end + + describe "#tarball_path" do + subject { described_class.new(name, resource).tarball_path } + + context "when URL ends with file" do + it { is_expected.to eq(HOMEBREW_CACHE/"foo-.tar.gz") } + end + + context "when URL file is in middle" do + let(:url) { "http://example.com/foo.tar.gz/from/this/mirror" } + it { is_expected.to eq(HOMEBREW_CACHE/"foo-.tar.gz") } + end + end end describe DownloadStrategyDetector do From dca8dc5bf50c508eadf051d4316cec12dacf7674 Mon Sep 17 00:00:00 2001 From: Kevin Abel Date: Tue, 9 Jan 2018 20:11:52 -0600 Subject: [PATCH 04/69] Fix audit --- Library/Homebrew/download_strategy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 6869d33703..3419475445 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -304,7 +304,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy # https://example.com/download.php?file=foo-1.0.tar.gz # the extension we want is ".tar.gz", not ".php". url_pathname = Pathname.new(@url) - while !ext = url_pathname.extname[/[^?]+/] + until ext = url_pathname.extname[/[^?]+/] url_pathname = url_pathname.dirname end ext From 0254605cd52b1bb92ffe33114c671cc111c5a687 Mon Sep 17 00:00:00 2001 From: Kevin Abel Date: Sat, 13 Jan 2018 17:06:21 -0600 Subject: [PATCH 05/69] Handle reaching the top of a URL which searching for file ext Should never reach this as most URL's will have a domain name that will be caught as an extname. --- Library/Homebrew/download_strategy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 3419475445..2774f2fadb 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -306,6 +306,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy url_pathname = Pathname.new(@url) until ext = url_pathname.extname[/[^?]+/] url_pathname = url_pathname.dirname + return if url_pathname.to_s == "." end ext end From 4c5e3d04e1914f98c326e5bcd3b22acd4a54c782 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Mon, 29 Jan 2018 13:43:21 +0000 Subject: [PATCH 06/69] Fix @reitermarkus's comments --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index ff4a37bcfc..1ad5eaff55 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -17,7 +17,7 @@ module Hbc end def summary_header - "Cask's Doctor checkup" + "Cask's Doctor Checkup" end def run @@ -29,7 +29,7 @@ module Hbc check_environment_variables puts summary unless success? - raise CaskError, "Your system is not ready for Cask." unless success? + raise CaskError, "There are some problems with your setup." unless success? end def check_software_versions From 601af55b43bc96627359eca06eeec4bf9881c890 Mon Sep 17 00:00:00 2001 From: Kevin Abel Date: Fri, 2 Feb 2018 18:15:05 -0600 Subject: [PATCH 07/69] Add root dirname as a escape value too --- Library/Homebrew/download_strategy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 2774f2fadb..ed316fa7fb 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -306,7 +306,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy url_pathname = Pathname.new(@url) until ext = url_pathname.extname[/[^?]+/] url_pathname = url_pathname.dirname - return if url_pathname.to_s == "." + return if url_pathname.to_s == "." || url_pathname.to_s == "/" end ext end From 14a25bdd693236f82082c0b67058e7b2c9265c29 Mon Sep 17 00:00:00 2001 From: Sander Bol Date: Wed, 7 Feb 2018 09:50:01 +0100 Subject: [PATCH 08/69] Grammar: "formula are" -> "formulae are" Fix plural form of formula in `brew doctor` output. --- Library/Homebrew/diagnostic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index dbd6aa0c14..46750c24f4 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -822,7 +822,7 @@ module Homebrew return if linked.empty? inject_file_list linked.map(&:full_name), <<~EOS - Some keg-only formula are linked into the Cellar. + Some keg-only formulae are linked into the Cellar. Linking a keg-only formula, such as gettext, into the cellar with `brew link ` will cause other formulae to detect them during the `./configure` step. This may cause problems when compiling those @@ -872,7 +872,7 @@ module Homebrew return if missing.empty? <<~EOS - Some installed formula are missing dependencies. + Some installed formulae are missing dependencies. You should `brew install` the missing dependencies: brew install #{missing.sort_by(&:full_name) * " "} From c946da88ab07772ac4becd45ef0c82a60bbfc515 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 10 Feb 2018 08:34:23 -0500 Subject: [PATCH 09/69] linkage_checker: Distinguish indirect deps from undeclared deps --- Library/Homebrew/os/mac/linkage_checker.rb | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/os/mac/linkage_checker.rb b/Library/Homebrew/os/mac/linkage_checker.rb index e1709d1b45..cf6c12f22c 100644 --- a/Library/Homebrew/os/mac/linkage_checker.rb +++ b/Library/Homebrew/os/mac/linkage_checker.rb @@ -14,6 +14,7 @@ class LinkageChecker @system_dylibs = Set.new @broken_dylibs = Set.new @variable_dylibs = Set.new + @indirect_deps = [] @undeclared_deps = [] @reverse_links = Hash.new { |h, k| h[k] = Set.new } @unnecessary_deps = [] @@ -52,7 +53,7 @@ class LinkageChecker end end - @undeclared_deps, @unnecessary_deps = check_undeclared_deps if formula + @indirect_deps, @undeclared_deps, @unnecessary_deps = check_undeclared_deps if formula end def check_undeclared_deps @@ -62,13 +63,31 @@ class LinkageChecker formula.build.without?(dep) end declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name) + recursive_deps = keg.to_formula.runtime_dependencies.map { |dep| dep.to_formula.full_name } declared_dep_names = declared_deps.map { |dep| dep.split("/").last } - undeclared_deps = @brewed_dylibs.keys.reject do |full_name| + indirect_deps = [] + undeclared_deps = [] + @brewed_dylibs.each_key do |full_name| name = full_name.split("/").last - next true if name == formula.name - declared_dep_names.include?(name) + next if name == formula.name + if recursive_deps.include?(name) + indirect_deps << full_name unless declared_dep_names.include?(name) + else + undeclared_deps << full_name + end end - undeclared_deps.sort do |a, b| + sort_by_formula_full_name!(indirect_deps) + sort_by_formula_full_name!(undeclared_deps) + unnecessary_deps = declared_dep_names.reject do |full_name| + name = full_name.split("/").last + next true if Formula[name].bin.directory? + @brewed_dylibs.keys.map { |x| x.split("/").last }.include?(name) + end + [indirect_deps, undeclared_deps, unnecessary_deps] + end + + def sort_by_formula_full_name!(arr) + arr.sort! do |a, b| if a.include?("/") && !b.include?("/") 1 elsif !a.include?("/") && b.include?("/") @@ -77,17 +96,12 @@ class LinkageChecker a <=> b end end - unnecessary_deps = declared_dep_names.reject do |full_name| - name = full_name.split("/").last - next true if Formula[name].bin.directory? - @brewed_dylibs.keys.map { |x| x.split("/").last }.include?(name) - end - [undeclared_deps, unnecessary_deps] end def display_normal_output display_items "System libraries", @system_dylibs display_items "Homebrew libraries", @brewed_dylibs + display_items "Indirect dependencies with linkage", @indirect_deps display_items "Variable-referenced libraries", @variable_dylibs display_items "Missing libraries", @broken_dylibs display_items "Undeclared dependencies with linkage", @undeclared_deps From f97d8e3905f4ede7403be512df4aaeccc59147be Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Sat, 10 Feb 2018 09:05:06 +0000 Subject: [PATCH 10/69] diagnostic: implement cache size check --- Library/Homebrew/diagnostic.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index dbd6aa0c14..cc364eaaa4 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -835,6 +835,17 @@ module Homebrew EOS end + def check_for_large_cache + return unless HOMEBREW_CACHE.exist? + return if ENV["CI"] # CI can be expected to have a large cache. + cache_size = HOMEBREW_CACHE.disk_usage + return unless cache_size > 2_147_483_648 + <<~EOS + Your HOMEBREW_CACHE is using #{disk_usage_readable(cache_size)} of disk space. + You may wish to consider running `brew cleanup`. + EOS + end + def check_for_other_frameworks # Other frameworks that are known to cause problems when present frameworks_to_check = %w[ From 49972e59052635cf1e42fa2418f9bb4c2cf29a8a Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Fri, 9 Feb 2018 20:57:06 -0500 Subject: [PATCH 11/69] write_jar_script: add java version option --- Library/Homebrew/extend/pathname.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index b4311f13fa..baf47b2764 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -436,11 +436,14 @@ class Pathname end # Writes an exec script that invokes a java jar - def write_jar_script(target_jar, script_name, java_opts = "") + def write_jar_script(target_jar, script_name, java_opts = "", java_version: nil) mkpath + java_home = if java_version + "JAVA_HOME=\"$(#{Language::Java.java_home_cmd(java_version)})\" " + end join(script_name).write <<~EOS #!/bin/bash - exec java #{java_opts} -jar #{target_jar} "$@" + #{java_home}exec java #{java_opts} -jar #{target_jar} "$@" EOS end From 51ed7983a5d77213b7e6df0e51c54c0bf9ebe350 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Mon, 12 Feb 2018 10:11:45 +0000 Subject: [PATCH 12/69] diagnostic: guard cache check on Jenkins too --- Library/Homebrew/diagnostic.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index cc364eaaa4..8516f2b634 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -837,7 +837,8 @@ module Homebrew def check_for_large_cache return unless HOMEBREW_CACHE.exist? - return if ENV["CI"] # CI can be expected to have a large cache. + # CI can be expected to have a large cache. + return if ENV["CI"] || ENV["JENKINS_HOME"] cache_size = HOMEBREW_CACHE.disk_usage return unless cache_size > 2_147_483_648 <<~EOS From a30c74987a1b10fbc5ab7b600e8f8769a34344f7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 12 Feb 2018 16:38:10 +0000 Subject: [PATCH 13/69] brew, diagnostic: tweak CI variable checks. I've adjusted test-bot in: https://github.com/Homebrew/homebrew-test-bot/commit/603918939a58a8d6351177fe35f0193b79549dfa to set CI=1 for Jenkins to make future JENKINS_HOME checks unnecessary. The only `TRAVIS_*` variable we care about is `TRAVIS_SUDO` so whitelist that specifically rather than passing through loads of others. --- Library/Homebrew/diagnostic.rb | 4 ++-- bin/brew | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 8516f2b634..1787583476 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -788,7 +788,7 @@ module Homebrew EOS end - return if ENV["CI"] || ENV["JENKINS_HOME"] + return if ENV["CI"] branch = coretap_path.git_branch return if branch.nil? || branch =~ /master/ @@ -838,7 +838,7 @@ module Homebrew def check_for_large_cache return unless HOMEBREW_CACHE.exist? # CI can be expected to have a large cache. - return if ENV["CI"] || ENV["JENKINS_HOME"] + return if ENV["CI"] cache_size = HOMEBREW_CACHE.disk_usage return unless cache_size > 2_147_483_648 <<~EOS diff --git a/bin/brew b/bin/brew index 881ace1ec1..34c28056b1 100755 --- a/bin/brew +++ b/bin/brew @@ -66,9 +66,9 @@ then FILTERED_ENV=() # Filter all but the specific variables. - for VAR in HOME SHELL PATH TERM LOGNAME USER CI TRAVIS SSH_AUTH_SOCK SUDO_ASKPASS \ + for VAR in HOME SHELL PATH TERM LOGNAME USER CI TRAVIS TRAVIS_SUDO SSH_AUTH_SOCK SUDO_ASKPASS \ http_proxy https_proxy ftp_proxy no_proxy all_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY \ - "${!HOMEBREW_@}" "${!TRAVIS_@}" "${!JENKINS_@}" + "${!HOMEBREW_@}" do # Skip if variable value is empty. [[ -z "${!VAR}" ]] && continue From 473cdff132d8460012f37c28f4cf4f0241f6d01f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 12 Feb 2018 16:54:23 +0000 Subject: [PATCH 14/69] ISSUE_TEMPLATE: various updates. Most notably: try to point people towards Discourse for non-bugs. --- .github/ISSUE_TEMPLATE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 287e95b03a..cfa55d26e6 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,10 +1,10 @@ **Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.** -# Please always follow these steps: -- [ ] Confirmed this is a problem with running a `brew` command and not `brew install`ing or the post-install behaviour of one or more formulae? If it's a formulae-specific problem please file this issue at the relevant tap e.g. for Homebrew/homebrew-core https://github.com/Homebrew/homebrew-core/issues/new -- [ ] Ran `brew update` and retried your prior step? -- [ ] Ran `brew doctor`, fixed all issues and retried your prior step? -- [ ] Ran `brew config` and `brew doctor` and included their output with your issue? +- [ ] are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh +- [ ] ran a `brew` command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new. If it's a `brew cask` problem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap. +- [ ] ran `brew update` and can still reproduce the problem? +- [ ] ran `brew doctor`, fixed all issues and can still reproduce the problem? +- [ ] ran `brew config` and `brew doctor` and included their output with your issue? To help us debug your issue please explain: - What you were trying to do (and why) @@ -16,7 +16,7 @@ To help us debug your issue please explain: Please replace this section with: - a detailed description of your proposed feature - the motivation for the feature -- how the feature would be relevant to at least 90% of Homebrew users +- how the feature would be relevant to at least 90% of Homebrew users (if it's not: do not open a feature request) - what alternatives to the feature you have considered -We will close this issue or ask you to create a pull-request if it's something we're not actively planning to work on. +We will close this issue or ask you to create a pull-request if it's something the maintainers are not actively planning to work on. From 7388acb86e0b9811e6badd610255954b3b3a6453 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Mon, 12 Feb 2018 11:06:55 -0600 Subject: [PATCH 15/69] Tty: if HOMEBREW_NO_COLOR env var is present, disable color bin/brew will recognize NO_COLOR variable and copy it to HOMEBREW_NO_COLOR --- Library/Homebrew/manpages/brew.1.md.erb | 3 +++ Library/Homebrew/test/cask/dsl_spec.rb | 1 + Library/Homebrew/test/utils/tty_spec.rb | 14 +++++++++++++- Library/Homebrew/utils/tty.rb | 4 +++- bin/brew | 2 +- docs/Manpage.md | 3 +++ manpages/brew.1 | 4 ++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 508c90f2d4..fbe6fca946 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -199,6 +199,9 @@ can take several different forms: If set, Homebrew will not auto-update before running `brew install`, `brew upgrade` or `brew tap`. + * `HOMEBREW_NO_COLOR`: + If set, Homebrew will not print text with color added. + * `HOMEBREW_NO_EMOJI`: If set, Homebrew will not print the `HOMEBREW_INSTALL_BADGE` on a successful build. diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index d3bb462642..993c03bac8 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -75,6 +75,7 @@ describe Hbc::DSL, :cask do it "may use deprecated DSL version hash syntax" do allow(ENV).to receive(:[]).with("HOMEBREW_DEVELOPER").and_return(nil) + allow(ENV).to receive(:[]).with("HOMEBREW_NO_COLOR").and_return(nil) expect(cask.token).to eq("with-dsl-version") expect(cask.url.to_s).to eq("http://example.com/TestCask.dmg") diff --git a/Library/Homebrew/test/utils/tty_spec.rb b/Library/Homebrew/test/utils/tty_spec.rb index 3ba89b6fdb..e6c9168f31 100644 --- a/Library/Homebrew/test/utils/tty_spec.rb +++ b/Library/Homebrew/test/utils/tty_spec.rb @@ -53,7 +53,7 @@ describe Tty do allow($stdout).to receive(:tty?).and_return(true) end - it "returns an empty string for all colors" do + it "returns ANSI escape codes for colors" do expect(subject.to_s).to eq("") expect(subject.red.to_s).to eq("\033[31m") expect(subject.green.to_s).to eq("\033[32m") @@ -63,5 +63,17 @@ describe Tty do expect(subject.cyan.to_s).to eq("\033[36m") expect(subject.default.to_s).to eq("\033[39m") end + + it "returns an empty string for all colors when HOMEBREW_NO_COLOR is set" do + ENV["HOMEBREW_NO_COLOR"] = "1" + expect(subject.to_s).to eq("") + expect(subject.red.to_s).to eq("") + expect(subject.green.to_s).to eq("") + expect(subject.yellow.to_s).to eq("") + expect(subject.blue.to_s).to eq("") + expect(subject.magenta.to_s).to eq("") + expect(subject.cyan.to_s).to eq("") + expect(subject.default.to_s).to eq("") + end end end diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb index e872e64601..81d5f00d7b 100644 --- a/Library/Homebrew/utils/tty.rb +++ b/Library/Homebrew/utils/tty.rb @@ -59,7 +59,9 @@ module Tty end def to_s - return "" unless $stdout.tty? + if ENV["HOMEBREW_NO_COLOR"] || !$stdout.tty? + return "" + end current_escape_sequence ensure reset_escape_sequence! diff --git a/bin/brew b/bin/brew index 881ace1ec1..946e836370 100755 --- a/bin/brew +++ b/bin/brew @@ -47,7 +47,7 @@ HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library" # Whitelist and copy to HOMEBREW_* all variables previously mentioned in # manpage or used elsewhere by Homebrew. for VAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY BINTRAY_USER BINTRAY_KEY \ - BROWSER EDITOR GIT PATH VISUAL \ + BROWSER EDITOR GIT NO_COLOR PATH VISUAL \ GITHUB_USER GITHUB_PASSWORD GITHUB_TOKEN do # Skip if variable value is empty. diff --git a/docs/Manpage.md b/docs/Manpage.md index 9205183767..e4f189490b 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1037,6 +1037,9 @@ can take several different forms: If set, Homebrew will not auto-update before running `brew install`, `brew upgrade` or `brew tap`. + * `HOMEBREW_NO_COLOR`: + If set, Homebrew will not print text with color added. + * `HOMEBREW_NO_EMOJI`: If set, Homebrew will not print the `HOMEBREW_INSTALL_BADGE` on a successful build. diff --git a/manpages/brew.1 b/manpages/brew.1 index 56581bfc0f..4f373558c6 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1059,6 +1059,10 @@ If set, Homebrew will not send analytics\. See: \fIhttps://docs\.brew\.sh/Analyt If set, Homebrew will not auto\-update before running \fBbrew install\fR, \fBbrew upgrade\fR or \fBbrew tap\fR\. . .TP +\fBHOMEBREW_NO_COLOR\fR +If set, Homebrew will not print text with color added\. +. +.TP \fBHOMEBREW_NO_EMOJI\fR If set, Homebrew will not print the \fBHOMEBREW_INSTALL_BADGE\fR on a successful build\. . From ca3fccaf2b4bfe5c4d96a17ac5559f3721d00230 Mon Sep 17 00:00:00 2001 From: Kevin Abel Date: Mon, 12 Feb 2018 14:22:10 -0600 Subject: [PATCH 16/69] Make ext use bounded iterator --- Library/Homebrew/download_strategy.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index ed316fa7fb..e85661d76d 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -303,12 +303,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy # We can't use basename_without_params, because given a URL like # https://example.com/download.php?file=foo-1.0.tar.gz # the extension we want is ".tar.gz", not ".php". - url_pathname = Pathname.new(@url) - until ext = url_pathname.extname[/[^?]+/] - url_pathname = url_pathname.dirname - return if url_pathname.to_s == "." || url_pathname.to_s == "/" + Pathname.new(@url).ascend do |path| + ext = path.extname[/[^?]+/] + return ext if ext end - ext + nil end end From c57ab279ba4c723c275864e4f99c55a1cbc62a67 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 13 Feb 2018 09:34:19 +0000 Subject: [PATCH 17/69] Use rspec-retry in flaky brew tests. We have a few tests that are intermittently flaky. Let's try this to see if we can get them a bit more reliable. --- Library/Homebrew/test/Gemfile | 1 + Library/Homebrew/test/Gemfile.lock | 5 ++++- Library/Homebrew/test/cmd/search_spec.rb | 2 +- Library/Homebrew/test/cmd/services_spec.rb | 2 +- Library/Homebrew/test/dev-cmd/pull_spec.rb | 2 +- Library/Homebrew/test/spec_helper.rb | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index b6d1405ff6..34ba794a89 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -5,6 +5,7 @@ require_relative "../constants" gem "parallel_tests" gem "rspec" gem "rspec-its", require: false +gem "rspec-retry", require: false gem "rspec-wait", require: false gem "rubocop", HOMEBREW_RUBOCOP_VERSION diff --git a/Library/Homebrew/test/Gemfile.lock b/Library/Homebrew/test/Gemfile.lock index 47f51e56bb..a3f9c4c47e 100644 --- a/Library/Homebrew/test/Gemfile.lock +++ b/Library/Homebrew/test/Gemfile.lock @@ -31,6 +31,8 @@ GEM rspec-mocks (3.6.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.6.0) + rspec-retry (0.5.6) + rspec-core (> 3.3, < 3.8) rspec-support (3.6.0) rspec-wait (0.0.9) rspec (>= 3, < 4) @@ -58,9 +60,10 @@ DEPENDENCIES parallel_tests rspec rspec-its + rspec-retry rspec-wait rubocop (= 0.52.1) simplecov BUNDLED WITH - 1.16.0 + 1.16.1 diff --git a/Library/Homebrew/test/cmd/search_spec.rb b/Library/Homebrew/test/cmd/search_spec.rb index 36ddde3e1d..aec23ae4c1 100644 --- a/Library/Homebrew/test/cmd/search_spec.rb +++ b/Library/Homebrew/test/cmd/search_spec.rb @@ -25,7 +25,7 @@ describe "brew search", :integration_test do .and be_a_success end - it "falls back to a GitHub tap search when no formula is found", :needs_network do + it "falls back to a GitHub tap search when no formula is found", :needs_network, retry: 3 do expect { brew "search", "caskroom/cask/firefox" } .to output(/firefox/).to_stdout .and output(/Searching/).to_stderr diff --git a/Library/Homebrew/test/cmd/services_spec.rb b/Library/Homebrew/test/cmd/services_spec.rb index 669e84e5f8..fb40ce0b21 100644 --- a/Library/Homebrew/test/cmd/services_spec.rb +++ b/Library/Homebrew/test/cmd/services_spec.rb @@ -1,4 +1,4 @@ -describe "brew services", :integration_test, :needs_macos, :needs_network do +describe "brew services", :integration_test, :needs_macos, :needs_network, retry: 3 do it "allows controlling services" do setup_remote_tap "homebrew/services" diff --git a/Library/Homebrew/test/dev-cmd/pull_spec.rb b/Library/Homebrew/test/dev-cmd/pull_spec.rb index 984ac08439..cc66df7830 100644 --- a/Library/Homebrew/test/dev-cmd/pull_spec.rb +++ b/Library/Homebrew/test/dev-cmd/pull_spec.rb @@ -6,7 +6,7 @@ describe "brew pull", :integration_test do .and be_a_failure end - it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network do + it "fetches a patch from a GitHub commit or pull request and applies it", :needs_network, retry: 3 do CoreTap.instance.path.cd do system "git", "init" system "git", "checkout", "-b", "new-branch" diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index be184b6e09..865342ddfc 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -2,6 +2,7 @@ require "find" require "pathname" require "rspec/its" require "rspec/wait" +require "rspec/retry" require "rubocop" require "rubocop/rspec/support" require "set" From 0efe63402b661752601faaf4450d428ca60f54c8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Tue, 13 Feb 2018 01:57:20 -0800 Subject: [PATCH 18/69] diagnostic: remove cache size check --- Library/Homebrew/diagnostic.rb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 1787583476..d1de5ab00b 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -835,18 +835,6 @@ module Homebrew EOS end - def check_for_large_cache - return unless HOMEBREW_CACHE.exist? - # CI can be expected to have a large cache. - return if ENV["CI"] - cache_size = HOMEBREW_CACHE.disk_usage - return unless cache_size > 2_147_483_648 - <<~EOS - Your HOMEBREW_CACHE is using #{disk_usage_readable(cache_size)} of disk space. - You may wish to consider running `brew cleanup`. - EOS - end - def check_for_other_frameworks # Other frameworks that are known to cause problems when present frameworks_to_check = %w[ From 8d458fa443f039b646e71a17aa5fa60c96d24454 Mon Sep 17 00:00:00 2001 From: commitay Date: Tue, 13 Feb 2018 21:03:06 +1000 Subject: [PATCH 19/69] cask doctor: check_cached_downloads --- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb index a586a00ab1..32b927218b 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb @@ -24,6 +24,7 @@ module Hbc check_software_versions check_install_location check_staging_location + check_cached_downloads check_taps check_load_path check_environment_variables From 191b6218152f64da6e165e9a8947322388a7fdfb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 13 Feb 2018 17:23:49 +0100 Subject: [PATCH 20/69] Make sure `.metadata` shows up in Cask backtrace. --- Library/Homebrew/cask/lib/hbc/cask_loader.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb index c32b355847..74c39176d3 100644 --- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb +++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb @@ -16,11 +16,11 @@ module Hbc end def initialize(content) - @content = content + @content = content.force_encoding("UTF-8") end def load - instance_eval(content.force_encoding("UTF-8"), __FILE__, __LINE__) + instance_eval(content, __FILE__, __LINE__) end private @@ -52,7 +52,7 @@ module Hbc @content = IO.read(path) - super + instance_eval(content, path) end private From cf4c2bb97adbde2ff8796e4363572f7f6fdaa8a5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 13 Feb 2018 18:01:25 +0100 Subject: [PATCH 21/69] Auto-update on `brew cask install/upgrade`. --- Library/Homebrew/brew.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 60952c7fed..47064c61b9 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -224,6 +224,15 @@ case "$HOMEBREW_COMMAND" in --config) HOMEBREW_COMMAND="config" ;; esac +if [[ "$HOMEBREW_COMMAND" = "cask" ]] +then + HOMEBREW_CASK_COMMAND="$1" + + case "$HOMEBREW_CASK_COMMAND" in + instal) HOMEBREW_CASK_COMMAND="install" ;; # gem does the same + esac +fi + # Set HOMEBREW_DEV_CMD_RUN for users who have run a development command. # This makes them behave like HOMEBREW_DEVELOPERs for brew update. if [[ -z "$HOMEBREW_DEVELOPER" ]] @@ -297,7 +306,8 @@ update-preinstall() { [[ -z "$HOMEBREW_AUTO_UPDATE_CHECKED" ]] || return [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return - if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" ]] + if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" || + "$HOMEBREW_CASK_COMMAND" = "install" || "$HOMEBREW_CASK_COMMAND" = "upgrade" ]] then if [[ -z "$HOMEBREW_VERBOSE" ]] then From 102a2a491b12db20d5096418bb559e25c864f20a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 13 Feb 2018 18:49:01 +0100 Subject: [PATCH 22/69] =?UTF-8?q?Add=20Homebrew=E2=80=99s=20`bin`=20to=20P?= =?UTF-8?q?ATH=20for=20Cask=20installers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cask/lib/hbc/artifact/installer.rb | 2 +- Library/Homebrew/cask/lib/hbc/system_command.rb | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb index 5cd388c7fe..8fa54c01ec 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb @@ -23,7 +23,7 @@ module Hbc def install_phase(command: nil, **_) ohai "Running #{self.class.dsl_key} script '#{path.relative_path_from(cask.staged_path)}'" FileUtils.chmod "+x", path unless path.executable? - command.run(path, **args) + command.run(path, **args, path: PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"])) end end diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index a890c42e41..dfb3019998 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -37,7 +37,7 @@ module Hbc result end - def initialize(executable, args: [], sudo: false, input: [], print_stdout: false, print_stderr: true, must_succeed: false, **options) + def initialize(executable, args: [], sudo: false, input: [], print_stdout: false, print_stderr: true, must_succeed: false, path: ENV["PATH"], **options) @executable = executable @args = args @sudo = sudo @@ -47,6 +47,7 @@ module Hbc @must_succeed = must_succeed options.extend(HashValidator).assert_valid_keys(:chdir) @options = options + @path = path end def command @@ -55,7 +56,7 @@ module Hbc private - attr_reader :executable, :args, :input, :options, :processed_output, :processed_status + attr_reader :executable, :args, :input, :options, :processed_output, :processed_status, :path attr_predicate :sudo?, :print_stdout?, :print_stderr?, :must_succeed? @@ -83,12 +84,8 @@ module Hbc def each_output_line(&b) executable, *args = expanded_command - unless File.exist?(executable) - executable = which(executable, PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin")) - end - raw_stdin, raw_stdout, raw_stderr, raw_wait_thr = - Open3.popen3([executable, executable], *args, **options) + Open3.popen3({ "PATH" => path }, executable, *args, **options) write_input_to(raw_stdin) raw_stdin.close_write From e078becf4f3b7beaedea35e664a8c3562331ab3e Mon Sep 17 00:00:00 2001 From: commitay Date: Sun, 21 Jan 2018 19:10:30 +1000 Subject: [PATCH 23/69] cask move_back: copy / delete --- Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 8 +++++--- Library/Homebrew/test/cask/cli/reinstall_spec.rb | 3 ++- Library/Homebrew/test/cask/cli/uninstall_spec.rb | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index 856ab2766f..5a7483543e 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -62,14 +62,16 @@ module Hbc raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there." end - ohai "Moving #{self.class.english_name} '#{target.basename}' back to '#{source}'." + ohai "Copying #{self.class.english_name} '#{target.basename}' back to '#{source}'." source.dirname.mkpath if target.parent.writable? - FileUtils.move(target, source) + FileUtils.cp_r(target, source) else - command.run("/bin/mv", args: [target, source], sudo: true) + command.run("/bin/cp", args: ["-r", target, source], sudo: true) end + + delete(target, force: force, command: command, **options) end def delete(target, force: false, command: nil, **_) diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb index 3737a7a701..f56ed986d1 100644 --- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb @@ -13,7 +13,8 @@ describe Hbc::CLI::Reinstall, :cask do Already downloaded: .*local-caffeine--1.2.3.zip ==> Verifying checksum for Cask local-caffeine ==> Uninstalling Cask local-caffeine - ==> Moving App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine ==> Installing Cask local-caffeine ==> Moving App 'Caffeine.app' to '.*Caffeine.app'. diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 322394de4c..2cac42211a 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -12,7 +12,8 @@ describe Hbc::CLI::Uninstall, :cask do output = Regexp.new <<~EOS ==> Uninstalling Cask local-caffeine - ==> Moving App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine EOS From b864ae7b408741338f0016d686857fc0fe545fe2 Mon Sep 17 00:00:00 2001 From: commitay Date: Wed, 14 Feb 2018 07:56:59 +1000 Subject: [PATCH 24/69] backing up --- Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 2 +- Library/Homebrew/test/cask/cli/reinstall_spec.rb | 2 +- Library/Homebrew/test/cask/cli/uninstall_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb index 5a7483543e..31cede71a9 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb @@ -62,7 +62,7 @@ module Hbc raise CaskError, "It seems the #{self.class.english_name} source '#{target}' is not there." end - ohai "Copying #{self.class.english_name} '#{target.basename}' back to '#{source}'." + ohai "Backing #{self.class.english_name} '#{target.basename}' up to '#{source}'." source.dirname.mkpath if target.parent.writable? diff --git a/Library/Homebrew/test/cask/cli/reinstall_spec.rb b/Library/Homebrew/test/cask/cli/reinstall_spec.rb index f56ed986d1..f2d1322ad5 100644 --- a/Library/Homebrew/test/cask/cli/reinstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/reinstall_spec.rb @@ -13,7 +13,7 @@ describe Hbc::CLI::Reinstall, :cask do Already downloaded: .*local-caffeine--1.2.3.zip ==> Verifying checksum for Cask local-caffeine ==> Uninstalling Cask local-caffeine - ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Backing App 'Caffeine.app' up to '.*Caffeine.app'. ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine ==> Installing Cask local-caffeine diff --git a/Library/Homebrew/test/cask/cli/uninstall_spec.rb b/Library/Homebrew/test/cask/cli/uninstall_spec.rb index 2cac42211a..38ee1bb73a 100644 --- a/Library/Homebrew/test/cask/cli/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cli/uninstall_spec.rb @@ -12,7 +12,7 @@ describe Hbc::CLI::Uninstall, :cask do output = Regexp.new <<~EOS ==> Uninstalling Cask local-caffeine - ==> Copying App 'Caffeine.app' back to '.*Caffeine.app'. + ==> Backing App 'Caffeine.app' up to '.*Caffeine.app'. ==> Removing App '.*Caffeine.app'. ==> Purging files for version 1.2.3 of Cask local-caffeine EOS From 88b1e9223672ac2c23faf31055211a9a129eb692 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 14 Feb 2018 03:38:38 -0800 Subject: [PATCH 25/69] formula_installer: also run audit_installed for keg_only formulae --- Library/Homebrew/formula_installer.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index a89da9ae9e..8d7f0aae1c 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -566,7 +566,7 @@ class FormulaInstaller def caveats return if only_deps? - audit_installed if ARGV.homebrew_developer? && !formula.keg_only? + audit_installed if ARGV.homebrew_developer? caveats = Caveats.new(formula) @@ -882,8 +882,10 @@ class FormulaInstaller end def audit_installed - problem_if_output(check_env_path(formula.bin)) - problem_if_output(check_env_path(formula.sbin)) + unless formula.keg_only? + problem_if_output(check_env_path(formula.bin)) + problem_if_output(check_env_path(formula.sbin)) + end super end From e5f4160d3e7ca58f2d5f9d599246e051a32cbec4 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 15 Feb 2018 11:43:20 -0600 Subject: [PATCH 26/69] brew.sh: changes from Linuxbrew (Linux fork) These fixes do two things: - set HOMEBREW_MACOS_VERSION to 0 on non-HOMEBREW_MACOS machines - set HOMEBREW_CURL to Homebrew'd curl --- Library/Homebrew/brew.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 47064c61b9..505cbeb4ca 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -111,10 +111,16 @@ then else HOMEBREW_PROCESSOR="$(uname -m)" HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" + HOMEBREW_MACOS_VERSION=0 [[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)" : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" + if [[ -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] + then + HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" + fi + if [[ -z "$HOMEBREW_CACHE" ]] then if [[ -n "$XDG_CACHE_HOME" ]] From e47c364c55be42462ccaacfc9bebbfd2101525b2 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 15 Feb 2018 13:09:47 -0600 Subject: [PATCH 27/69] Don't set HOMEBREW_MACOS_VERSION on non-mac systems --- Library/Homebrew/brew.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 505cbeb4ca..d646ebfd34 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -111,7 +111,6 @@ then else HOMEBREW_PROCESSOR="$(uname -m)" HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" - HOMEBREW_MACOS_VERSION=0 [[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)" : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" From 30d468978fb0d299f3faa4461c15e82102e0d3a5 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 15 Feb 2018 13:26:17 -0600 Subject: [PATCH 28/69] Unifying Linux/Mac logic that sets HOMEBREW_CURL --- Library/Homebrew/brew.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index d646ebfd34..a9074a6438 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -97,13 +97,6 @@ then HOMEBREW_FORCE_BREWED_CURL="1" fi - if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" && - -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] && - "$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null - then - HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" - fi - if [[ -z "$HOMEBREW_CACHE" ]] then HOMEBREW_CACHE="$HOME/Library/Caches/Homebrew" @@ -114,11 +107,7 @@ else [[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)" : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" - - if [[ -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] - then - HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" - fi + HOMEBREW_FORCE_BREWED_CURL=1 if [[ -z "$HOMEBREW_CACHE" ]] then @@ -130,6 +119,14 @@ else fi fi fi + +if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" && + -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] && + "$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null +then + HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" +fi + HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_USER_AGENT_VERSION)" HOMEBREW_CURL_VERSION="$("$HOMEBREW_CURL" --version 2>/dev/null | head -n1 | awk '{print $1"/"$2}')" HOMEBREW_USER_AGENT_CURL="$HOMEBREW_USER_AGENT $HOMEBREW_CURL_VERSION" From d70d91cf2aa5223655b0c66baa61f06040663847 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Mon, 5 Feb 2018 18:36:26 -0800 Subject: [PATCH 29/69] test/utils/svn: Requires svn to succeed --- Library/Homebrew/test/spec_helper.rb | 4 ++++ Library/Homebrew/test/utils/svn_spec.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 865342ddfc..cba530736a 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -75,6 +75,10 @@ RSpec.configure do |config| skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"] end + config.before(:each, :needs_svn) do + skip "Requires subversion." unless which "svn" + end + config.around(:each) do |example| def find_files Find.find(TEST_TMPDIR) diff --git a/Library/Homebrew/test/utils/svn_spec.rb b/Library/Homebrew/test/utils/svn_spec.rb index 503d285f3e..f527a614f2 100644 --- a/Library/Homebrew/test/utils/svn_spec.rb +++ b/Library/Homebrew/test/utils/svn_spec.rb @@ -30,7 +30,7 @@ describe Utils do expect(described_class.svn_remote_exists(HOMEBREW_CACHE/"install")).to be_falsey end - it "returns true when remote exists", :needs_network do + it "returns true when remote exists", :needs_network, :needs_svn do remote = "http://github.com/Homebrew/install" svn = HOMEBREW_SHIMS_PATH/"scm/svn" From 444b292df9d60b355895c9b024522d01b9e30771 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 10:41:14 -0600 Subject: [PATCH 30/69] zip and bzip2 dependencies when needed On some systems identified as Linux, zip and bzip2 might not be available. Therefore, on such platforms we add them unconditionally as dependencies when required. On Mac, these dependencies are always satisfied. --- Library/Homebrew/dependency_collector.rb | 10 +++++++ .../extend/os/dependency_collector.rb | 1 + .../extend/os/linux/dependency_collector.rb | 27 +++++++++++++++++++ .../extend/os/mac/dependency_collector.rb | 5 ++++ 4 files changed, 43 insertions(+) create mode 100644 Library/Homebrew/extend/os/linux/dependency_collector.rb diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 03a86d661e..9e6d6ab0b9 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -72,6 +72,14 @@ class DependencyCollector def ld64_dep_if_needed(*); end + def zip_dep_if_needed(tags) + return + end + + def bzip2_dep_if_needed(tags) + return + end + def self.tar_needs_xz_dependency? !new.xz_dep_if_needed([]).nil? end @@ -162,6 +170,8 @@ class DependencyCollector when ".lz" then Dependency.new("lzip", tags) when ".rar" then Dependency.new("unrar", tags) when ".7z" then Dependency.new("p7zip", tags) + when ".zip" then zip_dep_if_needed(tags) + when ".bz2" then bzip2_dep_if_needed(tags) end end end diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb index 56fcad31d0..fffec1c999 100644 --- a/Library/Homebrew/extend/os/dependency_collector.rb +++ b/Library/Homebrew/extend/os/dependency_collector.rb @@ -1,2 +1,3 @@ require "dependency_collector" require "extend/os/mac/dependency_collector" if OS.mac? +require "extend/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb new file mode 100644 index 0000000000..13ea1ab334 --- /dev/null +++ b/Library/Homebrew/extend/os/linux/dependency_collector.rb @@ -0,0 +1,27 @@ +class DependencyCollector + + def git_dep_if_needed(tags) + Dependency.new("git", tags) + end + + def cvs_dep_if_needed(tags) + Dependency.new("cvs", tags) + end + + def xz_dep_if_needed(tags) + Dependency.new("xz", tags) + end + + def ld64_dep_if_needed(*) + return + end + + def zip_dep_if_needed(tags) + Dependency.new("zip", tags) + end + + def bzip2_dep_if_needed(tags) + Dependency.new("bzip2", tags) + end + +end diff --git a/Library/Homebrew/extend/os/mac/dependency_collector.rb b/Library/Homebrew/extend/os/mac/dependency_collector.rb index 108b6ccb2b..1162868794 100644 --- a/Library/Homebrew/extend/os/mac/dependency_collector.rb +++ b/Library/Homebrew/extend/os/mac/dependency_collector.rb @@ -23,4 +23,9 @@ class DependencyCollector return if MacOS.version > :tiger LD64Dependency.new end + + def zip_dep_if_needed(tags); end + + def bzip2_dep_if_needed(tags); end + end From 5a9297612060d25d5c959530330e4a907e0931a8 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 10:49:43 -0600 Subject: [PATCH 31/69] Fixing brew-style offenses --- Library/Homebrew/dependency_collector.rb | 8 ++------ Library/Homebrew/extend/os/linux/dependency_collector.rb | 6 +----- Library/Homebrew/extend/os/mac/dependency_collector.rb | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 9e6d6ab0b9..689e4e2f13 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -72,13 +72,9 @@ class DependencyCollector def ld64_dep_if_needed(*); end - def zip_dep_if_needed(tags) - return - end + def zip_dep_if_needed(*); end - def bzip2_dep_if_needed(tags) - return - end + def bzip2_dep_if_needed(*); end def self.tar_needs_xz_dependency? !new.xz_dep_if_needed([]).nil? diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb index 13ea1ab334..61df498ffa 100644 --- a/Library/Homebrew/extend/os/linux/dependency_collector.rb +++ b/Library/Homebrew/extend/os/linux/dependency_collector.rb @@ -1,5 +1,4 @@ class DependencyCollector - def git_dep_if_needed(tags) Dependency.new("git", tags) end @@ -12,9 +11,7 @@ class DependencyCollector Dependency.new("xz", tags) end - def ld64_dep_if_needed(*) - return - end + def ld64_dep_if_needed(*); end def zip_dep_if_needed(tags) Dependency.new("zip", tags) @@ -23,5 +20,4 @@ class DependencyCollector def bzip2_dep_if_needed(tags) Dependency.new("bzip2", tags) end - end diff --git a/Library/Homebrew/extend/os/mac/dependency_collector.rb b/Library/Homebrew/extend/os/mac/dependency_collector.rb index 1162868794..5fd83f6185 100644 --- a/Library/Homebrew/extend/os/mac/dependency_collector.rb +++ b/Library/Homebrew/extend/os/mac/dependency_collector.rb @@ -27,5 +27,4 @@ class DependencyCollector def zip_dep_if_needed(tags); end def bzip2_dep_if_needed(tags); end - end From a53171d9fe99eee935720bccab84cdfd5092ee5b Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 14:58:07 -0600 Subject: [PATCH 32/69] Adding tests for dependency_collector on Linux --- .../test/dependency_collector_spec.rb | 1 + .../test/os/dependency_collector_spec.rb | 1 + .../os/linux/dependency_collector_spec.rb | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 Library/Homebrew/test/os/dependency_collector_spec.rb create mode 100644 Library/Homebrew/test/os/linux/dependency_collector_spec.rb diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb index 46e859b2d8..f8fb16c029 100644 --- a/Library/Homebrew/test/dependency_collector_spec.rb +++ b/Library/Homebrew/test/dependency_collector_spec.rb @@ -140,3 +140,4 @@ describe DependencyCollector do end end end +require "test/os/dependency_collector_spec" diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb new file mode 100644 index 0000000000..3d7029e405 --- /dev/null +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -0,0 +1 @@ +require "test/os/linux/dependency_collector_spec" if OS.linux? diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb new file mode 100644 index 0000000000..37d61c89be --- /dev/null +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -0,0 +1,23 @@ +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + it "creates a resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bzip2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end +end From 5cfcd2ae9f2a4ef731f666e3e78cfb74ae28ae38 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 15:04:43 -0600 Subject: [PATCH 33/69] Fixing test --- Library/Homebrew/test/os/linux/dependency_collector_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb index 37d61c89be..eaae99fe92 100644 --- a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -14,9 +14,9 @@ describe DependencyCollector do expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) end - it "creates a resource dependency from a '.bzip2' URL" do + it "creates a resource dependency from a '.bz2' URL" do resource = Resource.new - resource.url("http://example.com/foo.tar.bzip2") + resource.url("http://example.com/foo.tar.bz2") expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) end end From 1b74f21492ca92bb8899304176cfdf4c42def297 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Fri, 16 Feb 2018 15:08:55 -0600 Subject: [PATCH 34/69] Removing unnecessary arguments --- Library/Homebrew/extend/os/mac/dependency_collector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/dependency_collector.rb b/Library/Homebrew/extend/os/mac/dependency_collector.rb index 5fd83f6185..671a63f558 100644 --- a/Library/Homebrew/extend/os/mac/dependency_collector.rb +++ b/Library/Homebrew/extend/os/mac/dependency_collector.rb @@ -24,7 +24,7 @@ class DependencyCollector LD64Dependency.new end - def zip_dep_if_needed(tags); end + def zip_dep_if_needed(*); end - def bzip2_dep_if_needed(tags); end + def bzip2_dep_if_needed(*); end end From 3dabebbd1643971d1904749530fe6ba73ec38817 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 06:49:42 +0000 Subject: [PATCH 35/69] Refactoring based on suggestions Defaulting zip_dep_if_needed(tags) and bzip2_dep_if_needed(tags) methods to those on Linux and overriding them on macOS. --- Library/Homebrew/dependency_collector.rb | 8 +++++-- .../extend/os/dependency_collector.rb | 1 - .../extend/os/linux/dependency_collector.rb | 23 ------------------- 3 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 Library/Homebrew/extend/os/linux/dependency_collector.rb diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 689e4e2f13..4b8f9e8723 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -72,9 +72,13 @@ class DependencyCollector def ld64_dep_if_needed(*); end - def zip_dep_if_needed(*); end + def zip_dep_if_needed(tags) + Dependency.new("zip", tags) + end - def bzip2_dep_if_needed(*); end + def bzip2_dep_if_needed(tags) + Dependency.new("bzip2", tags) + end def self.tar_needs_xz_dependency? !new.xz_dep_if_needed([]).nil? diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb index fffec1c999..56fcad31d0 100644 --- a/Library/Homebrew/extend/os/dependency_collector.rb +++ b/Library/Homebrew/extend/os/dependency_collector.rb @@ -1,3 +1,2 @@ require "dependency_collector" require "extend/os/mac/dependency_collector" if OS.mac? -require "extend/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb deleted file mode 100644 index 61df498ffa..0000000000 --- a/Library/Homebrew/extend/os/linux/dependency_collector.rb +++ /dev/null @@ -1,23 +0,0 @@ -class DependencyCollector - def git_dep_if_needed(tags) - Dependency.new("git", tags) - end - - def cvs_dep_if_needed(tags) - Dependency.new("cvs", tags) - end - - def xz_dep_if_needed(tags) - Dependency.new("xz", tags) - end - - def ld64_dep_if_needed(*); end - - def zip_dep_if_needed(tags) - Dependency.new("zip", tags) - end - - def bzip2_dep_if_needed(tags) - Dependency.new("bzip2", tags) - end -end From b084a2581f32fcbc6fbdf081ffce9a6c53f66ff6 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 07:21:34 +0000 Subject: [PATCH 36/69] Making zip and bzip2 dependecies conditional Here, we are adding `unless which("zip")` and `unless which("bzip2")` and, thus, make `zip` and `bzip2` dependencies conditional. --- Library/Homebrew/dependency_collector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 4b8f9e8723..bd71d61b09 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -73,11 +73,11 @@ class DependencyCollector def ld64_dep_if_needed(*); end def zip_dep_if_needed(tags) - Dependency.new("zip", tags) + Dependency.new("zip", tags) unless which("zip") end def bzip2_dep_if_needed(tags) - Dependency.new("bzip2", tags) + Dependency.new("bzip2", tags) unless which("bzip2") end def self.tar_needs_xz_dependency? From 73a3592981f7645ba81afef0332def27f553abc4 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 08:54:30 +0000 Subject: [PATCH 37/69] Renaming linux-specifix file with tests Files are globbed based on their name. Therefore, we have to rename them so tests for Linux are not executed on a Mac. --- Library/Homebrew/test/os/dependency_collector_spec.rb | 2 +- .../{dependency_collector_spec.rb => dependency_collector.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Library/Homebrew/test/os/linux/{dependency_collector_spec.rb => dependency_collector.rb} (100%) diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index 3d7029e405..d190788daa 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1 @@ -require "test/os/linux/dependency_collector_spec" if OS.linux? +require "test/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector.rb similarity index 100% rename from Library/Homebrew/test/os/linux/dependency_collector_spec.rb rename to Library/Homebrew/test/os/linux/dependency_collector.rb From d25fc5ce50a46b37e84d90151d0ea3c467667231 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 09:54:36 +0000 Subject: [PATCH 38/69] Code refactoring --- Library/Homebrew/dependency_collector.rb | 4 ++-- Library/Homebrew/extend/os/mac/dependency_collector.rb | 8 ++++---- Library/Homebrew/test/dependency_collector_spec.rb | 1 - Library/Homebrew/test/os/dependency_collector_spec.rb | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index bd71d61b09..41e79810ea 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -166,12 +166,12 @@ class DependencyCollector def parse_url_spec(url, tags) case File.extname(url) when ".xz" then xz_dep_if_needed(tags) + when ".zip" then zip_dep_if_needed(tags) + when ".bz2" then bzip2_dep_if_needed(tags) when ".lha", ".lzh" then Dependency.new("lha", tags) when ".lz" then Dependency.new("lzip", tags) when ".rar" then Dependency.new("unrar", tags) when ".7z" then Dependency.new("p7zip", tags) - when ".zip" then zip_dep_if_needed(tags) - when ".bz2" then bzip2_dep_if_needed(tags) end end end diff --git a/Library/Homebrew/extend/os/mac/dependency_collector.rb b/Library/Homebrew/extend/os/mac/dependency_collector.rb index 671a63f558..a7e5d7ffc8 100644 --- a/Library/Homebrew/extend/os/mac/dependency_collector.rb +++ b/Library/Homebrew/extend/os/mac/dependency_collector.rb @@ -18,13 +18,13 @@ class DependencyCollector Dependency.new("xz", tags) end + def zip_dep_if_needed(tags); end + + def bzip2_dep_if_needed(tags); end + def ld64_dep_if_needed(*) # Tiger's ld is too old to properly link some software return if MacOS.version > :tiger LD64Dependency.new end - - def zip_dep_if_needed(*); end - - def bzip2_dep_if_needed(*); end end diff --git a/Library/Homebrew/test/dependency_collector_spec.rb b/Library/Homebrew/test/dependency_collector_spec.rb index f8fb16c029..46e859b2d8 100644 --- a/Library/Homebrew/test/dependency_collector_spec.rb +++ b/Library/Homebrew/test/dependency_collector_spec.rb @@ -140,4 +140,3 @@ describe DependencyCollector do end end end -require "test/os/dependency_collector_spec" diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index d190788daa..4fe064732c 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1 @@ -require "test/os/linux/dependency_collector" if OS.linux? +require "test/dependency_collector" From 306c19061ee1211e285cdd6006d852cc26a5ae90 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 09:58:30 +0000 Subject: [PATCH 39/69] Code refactoring v2.0 --- Library/Homebrew/dependency_collector.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 41e79810ea..0a38f0de39 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -70,8 +70,6 @@ class DependencyCollector Dependency.new("xz", tags) end - def ld64_dep_if_needed(*); end - def zip_dep_if_needed(tags) Dependency.new("zip", tags) unless which("zip") end @@ -80,6 +78,8 @@ class DependencyCollector Dependency.new("bzip2", tags) unless which("bzip2") end + def ld64_dep_if_needed(*); end + def self.tar_needs_xz_dependency? !new.xz_dep_if_needed([]).nil? end From c6dac68d8bdb652152d89a097a9ab9f270832d68 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 19 Feb 2018 10:21:01 +0000 Subject: [PATCH 40/69] Code refactoring v3.0 --- .../test/os/dependency_collector_spec.rb | 24 ++++++++++++++++++- .../test/os/linux/dependency_collector.rb | 23 ------------------ 2 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 Library/Homebrew/test/os/linux/dependency_collector.rb diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb index 4fe064732c..eaae99fe92 100644 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/dependency_collector_spec.rb @@ -1 +1,23 @@ -require "test/dependency_collector" +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + it "creates a resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bz2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bz2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end +end diff --git a/Library/Homebrew/test/os/linux/dependency_collector.rb b/Library/Homebrew/test/os/linux/dependency_collector.rb deleted file mode 100644 index eaae99fe92..0000000000 --- a/Library/Homebrew/test/os/linux/dependency_collector.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "dependency_collector" - -describe DependencyCollector do - alias_matcher :be_a_build_requirement, :be_build - - after(:each) do - described_class.clear_cache - end - - describe "#add" do - it "creates a resource dependency from a '.zip' URL" do - resource = Resource.new - resource.url("http://example.com/foo.zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) - end - - it "creates a resource dependency from a '.bz2' URL" do - resource = Resource.new - resource.url("http://example.com/foo.tar.bz2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) - end - end -end From a9c64c319f8b8ef4aa3c0265bbe735002daa0d60 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 19 Feb 2018 16:14:32 +0000 Subject: [PATCH 41/69] gist-logs: require API credentials. Anonymous gists are going away shortly: https://github.com/blog/2503-deprecation-notice-removing-anonymous-gist-creation --- Library/Homebrew/cmd/gist-logs.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 630361ca2b..ab81a017e2 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -39,6 +39,16 @@ module Homebrew files["00.tap.out"] = { content: tap } end + if GitHub.api_credentials_type == :none + puts <<~EOS + You can create a new personal access token: + #{GitHub::ALL_SCOPES_URL} + and then set the new HOMEBREW_GITHUB_API_TOKEN as the authentication method. + + EOS + login! + end + # Description formatted to work well as page title when viewing gist if f.core_formula? descr = "#{f.name} on #{OS_VERSION} - Homebrew build logs" @@ -48,16 +58,6 @@ module Homebrew url = create_gist(files, descr) if ARGV.include?("--new-issue") || ARGV.switch?("n") - if GitHub.api_credentials_type == :none - puts <<~EOS - You can create a new personal access token: - #{GitHub::ALL_SCOPES_URL} - and then set the new HOMEBREW_GITHUB_API_TOKEN as the authentication method. - - EOS - login! - end - url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) end From 84be0f82d4552b1c41c5ca1ad63c39df4a59f40f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 20 Feb 2018 09:12:47 +0000 Subject: [PATCH 42/69] brew.sh: use system curl on Linux where possible. Result of discussion in #3809. --- Library/Homebrew/brew.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index a9074a6438..61d85ddd2a 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -75,7 +75,6 @@ case "$HOMEBREW_SYSTEM" in Linux) HOMEBREW_LINUX="1" ;; esac -HOMEBREW_CURL="curl" if [[ -n "$HOMEBREW_MACOS" ]] then HOMEBREW_PROCESSOR="$(uname -p)" @@ -107,7 +106,6 @@ else [[ -n "$HOMEBREW_LINUX" ]] && HOMEBREW_OS_VERSION="$(lsb_release -sd 2>/dev/null)" : "${HOMEBREW_OS_VERSION:=$(uname -r)}" HOMEBREW_OS_USER_AGENT_VERSION="$HOMEBREW_OS_VERSION" - HOMEBREW_FORCE_BREWED_CURL=1 if [[ -z "$HOMEBREW_CACHE" ]] then @@ -125,6 +123,8 @@ if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" && "$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null then HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl" +else + HOMEBREW_CURL="curl" fi HOMEBREW_USER_AGENT="$HOMEBREW_PRODUCT/$HOMEBREW_USER_AGENT_VERSION ($HOMEBREW_SYSTEM; $HOMEBREW_PROCESSOR $HOMEBREW_OS_USER_AGENT_VERSION)" From 73ba9b3d880ae72e2dd8649d60b3a338ba744ac0 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Tue, 20 Feb 2018 11:13:13 -0800 Subject: [PATCH 43/69] Define OS::Mac on Linux Define MacOS.version, MacOS.full_version, and MacOS::Xcode.version to Version::NULL on Linux so that brew readall succeeds and Homebrew/brew can tap Homebrew/core on Linux. --- Library/Homebrew/os.rb | 1 + Library/Homebrew/os/linux.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Library/Homebrew/os/linux.rb diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index d35a49dd7b..d56b032286 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -21,6 +21,7 @@ module OS end PATH_OPEN = "/usr/bin/open".freeze elsif OS.linux? + require "os/linux" ISSUES_URL = "https://github.com/Linuxbrew/brew/wiki/troubleshooting".freeze PATH_OPEN = "xdg-open".freeze end diff --git a/Library/Homebrew/os/linux.rb b/Library/Homebrew/os/linux.rb new file mode 100644 index 0000000000..e5af301b2f --- /dev/null +++ b/Library/Homebrew/os/linux.rb @@ -0,0 +1,28 @@ +module OS + # Define OS::Mac on Linux for formula API compatibility. + module Mac + module_function + + ::MacOS = self # rubocop:disable Naming/ConstantName + + def prefer_64_bit? + Hardware::CPU.is_64_bit? + end + + def version + Version::NULL + end + + def full_version + Version::NULL + end + + module Xcode + module_function + + def version + Version::NULL + end + end + end +end From 14d7a7a08c9aab7db14ea03f59ec85899e5e3ba6 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Tue, 20 Feb 2018 21:33:38 +0000 Subject: [PATCH 44/69] Code refactoring 4.0 --- .../extend/os/dependency_collector.rb | 1 + .../extend/os/linux/dependency_collector.rb | 5 ++ .../test/os/dependency_collector_spec.rb | 23 -------- .../os/linux/dependency_collector_spec.rb | 53 +++++++++++++++++++ .../test/os/mac/dependency_collector_spec.rb | 12 +++++ 5 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 Library/Homebrew/extend/os/linux/dependency_collector.rb delete mode 100644 Library/Homebrew/test/os/dependency_collector_spec.rb create mode 100644 Library/Homebrew/test/os/linux/dependency_collector_spec.rb diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb index 56fcad31d0..fffec1c999 100644 --- a/Library/Homebrew/extend/os/dependency_collector.rb +++ b/Library/Homebrew/extend/os/dependency_collector.rb @@ -1,2 +1,3 @@ require "dependency_collector" require "extend/os/mac/dependency_collector" if OS.mac? +require "extend/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb new file mode 100644 index 0000000000..dc5b994b8a --- /dev/null +++ b/Library/Homebrew/extend/os/linux/dependency_collector.rb @@ -0,0 +1,5 @@ +class DependencyCollector + def xz_dep_if_needed(tags) + Dependency.new("xz", tags) unless which("xz") + end +end diff --git a/Library/Homebrew/test/os/dependency_collector_spec.rb b/Library/Homebrew/test/os/dependency_collector_spec.rb deleted file mode 100644 index eaae99fe92..0000000000 --- a/Library/Homebrew/test/os/dependency_collector_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "dependency_collector" - -describe DependencyCollector do - alias_matcher :be_a_build_requirement, :be_build - - after(:each) do - described_class.clear_cache - end - - describe "#add" do - it "creates a resource dependency from a '.zip' URL" do - resource = Resource.new - resource.url("http://example.com/foo.zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) - end - - it "creates a resource dependency from a '.bz2' URL" do - resource = Resource.new - resource.url("http://example.com/foo.tar.bz2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) - end - end -end diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb new file mode 100644 index 0000000000..5771fd59a2 --- /dev/null +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -0,0 +1,53 @@ +require "dependency_collector" + +describe DependencyCollector do + alias_matcher :be_a_build_requirement, :be_build + + after(:each) do + described_class.clear_cache + end + + describe "#add" do + resource = Resource.new + + context "when xz, zip, and bzip2 are not available" do + it "creates a resource dependency from a '.xz' URL" do + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz") + expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) + end + + it "creates a resource dependency from a '.zip' URL" do + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + end + + it "creates a resource dependency from a '.bz2' URL" do + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + end + end + + context "when xz, zip, and bzip2 are available" do + it "does not create a resource dependency from a '.xz' URL" do + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + + it "does not create a resource dependency from a '.zip' URL" do + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + + it "does not create a resource dependency from a '.bz2' URL" do + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil + end + end + end +end diff --git a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb index 5d260ebf71..a8fe8ba54c 100644 --- a/Library/Homebrew/test/os/mac/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/mac/dependency_collector_spec.rb @@ -36,6 +36,18 @@ describe DependencyCollector do expect(subject.add(resource)).to be nil end + specify "Resource dependency from a '.zip' URL" do + resource = Resource.new + resource.url("http://example.com/foo.zip") + expect(subject.add(resource)).to be nil + end + + specify "Resource dependency from a '.bz2' URL" do + resource = Resource.new + resource.url("http://example.com/foo.tar.bz2") + expect(subject.add(resource)).to be nil + end + specify "Resource dependency from a '.git' URL" do resource = Resource.new resource.url("git://example.com/foo/bar.git") From dd2288a5b2386f0b27b2593a2045014668cc8456 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 21 Feb 2018 08:49:13 +0000 Subject: [PATCH 45/69] dependency_collector: don't create symbol deps. Need to convert this to a string first or things explode. --- Library/Homebrew/compat/dependency_collector.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/compat/dependency_collector.rb b/Library/Homebrew/compat/dependency_collector.rb index 84d5431f3e..88d393488f 100644 --- a/Library/Homebrew/compat/dependency_collector.rb +++ b/Library/Homebrew/compat/dependency_collector.rb @@ -59,7 +59,7 @@ class DependencyCollector Dependency.new("python3", tags) when :emacs, :mysql, :perl, :postgresql, :rbenv, :ruby output_deprecation(spec) - Dependency.new(spec, tags) + Dependency.new(spec.to_s, tags) else super end From 157f84a74d4274f1fcfc73eda94a819cb68df944 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 21 Feb 2018 09:04:34 +0000 Subject: [PATCH 46/69] travis.yml: use homebrew/homebrew-core on Linux. --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd43e39420..37417a10a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,22 +36,13 @@ before_install: mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library"; sudo rm -rf "$HOMEBREW_REPOSITORY"; sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"; - else - HOMEBREW_CORE_TAP_DIR="$(brew --repo "homebrew/core")"; - mkdir -p "$HOMEBREW_CORE_TAP_DIR"; fi - if [ "$MACOS" ]; then travis_retry git -C Library/Taps/homebrew/homebrew-core fetch --depth=1 origin; + else + travis_retry git clone --depth=1 https://github.com/Homebrew/homebrew-core Library/Taps/homebrew/homebrew-core; fi - travis_retry git clone --depth=1 https://github.com/Homebrew/homebrew-test-bot Library/Taps/homebrew/homebrew-test-bot - - if [ "$LINUX" ]; then - HOMEBREW_TEST_BOT_TAP_DIR="$(brew --repo "homebrew/test-bot")"; - ln -s "$HOMEBREW_TEST_BOT_TAP_DIR/.git" "$HOMEBREW_TEST_BOT_TAP_DIR/Formula" "$HOMEBREW_CORE_TAP_DIR"; - fi - # can be removed after 1.5.3 is tagged - - if [ "$LINUX" ]; then - export HOMEBREW_FORCE_VENDOR_RUBY=1; - fi script: - brew test-bot From c83dd0d04b857161b47a43b54ba56c7296ac50c0 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 21 Feb 2018 13:44:51 +0000 Subject: [PATCH 47/69] brew style: replace tabs with spaces --- .../os/linux/dependency_collector_spec.rb | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb index 5771fd59a2..543ed39b0b 100644 --- a/Library/Homebrew/test/os/linux/dependency_collector_spec.rb +++ b/Library/Homebrew/test/os/linux/dependency_collector_spec.rb @@ -12,41 +12,41 @@ describe DependencyCollector do context "when xz, zip, and bzip2 are not available" do it "creates a resource dependency from a '.xz' URL" do - resource.url("http://example.com/foo.xz") - allow_any_instance_of(Object).to receive(:which).with("xz") - expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz") + expect(subject.add(resource)).to eq(Dependency.new("xz", [:build])) end it "creates a resource dependency from a '.zip' URL" do - resource.url("http://example.com/foo.zip") - allow_any_instance_of(Object).to receive(:which).with("zip") - expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip") + expect(subject.add(resource)).to eq(Dependency.new("zip", [:build])) end it "creates a resource dependency from a '.bz2' URL" do - resource.url("http://example.com/foo.tar.bz2") - allow_any_instance_of(Object).to receive(:which).with("bzip2") - expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2") + expect(subject.add(resource)).to eq(Dependency.new("bzip2", [:build])) end end context "when xz, zip, and bzip2 are available" do it "does not create a resource dependency from a '.xz' URL" do - resource.url("http://example.com/foo.xz") - allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.xz") + allow_any_instance_of(Object).to receive(:which).with("xz").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end it "does not create a resource dependency from a '.zip' URL" do - resource.url("http://example.com/foo.zip") - allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.zip") + allow_any_instance_of(Object).to receive(:which).with("zip").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end it "does not create a resource dependency from a '.bz2' URL" do - resource.url("http://example.com/foo.tar.bz2") - allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) - expect(subject.add(resource)).to be nil + resource.url("http://example.com/foo.tar.bz2") + allow_any_instance_of(Object).to receive(:which).with("bzip2").and_return(Pathname.new("foo")) + expect(subject.add(resource)).to be nil end end end From f8874004c2c0ee06b3f0420ac549f762beeb3433 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Wed, 21 Feb 2018 14:11:35 +0000 Subject: [PATCH 48/69] Make 'xz' and 'cvs' dependencies conditional --- Library/Homebrew/dependency_collector.rb | 4 ++-- Library/Homebrew/extend/os/dependency_collector.rb | 1 - Library/Homebrew/extend/os/linux/dependency_collector.rb | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 Library/Homebrew/extend/os/linux/dependency_collector.rb diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 0a38f0de39..7d3b90f9c6 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -63,11 +63,11 @@ class DependencyCollector end def cvs_dep_if_needed(tags) - Dependency.new("cvs", tags) + Dependency.new("cvs", tags) unless which("cvs") end def xz_dep_if_needed(tags) - Dependency.new("xz", tags) + Dependency.new("xz", tags) unless which("xz") end def zip_dep_if_needed(tags) diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb index fffec1c999..56fcad31d0 100644 --- a/Library/Homebrew/extend/os/dependency_collector.rb +++ b/Library/Homebrew/extend/os/dependency_collector.rb @@ -1,3 +1,2 @@ require "dependency_collector" require "extend/os/mac/dependency_collector" if OS.mac? -require "extend/os/linux/dependency_collector" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/dependency_collector.rb b/Library/Homebrew/extend/os/linux/dependency_collector.rb deleted file mode 100644 index dc5b994b8a..0000000000 --- a/Library/Homebrew/extend/os/linux/dependency_collector.rb +++ /dev/null @@ -1,5 +0,0 @@ -class DependencyCollector - def xz_dep_if_needed(tags) - Dependency.new("xz", tags) unless which("xz") - end -end From 66410ccf1be4255952b80c0b073514825f4ce8c6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 21 Feb 2018 18:04:14 +0000 Subject: [PATCH 49/69] Versions: additional formulae requirements. These should help keep these formulae more maintainable. --- docs/Versions.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/Versions.md b/docs/Versions.md index 282640a1f0..2fa3f563f5 100644 --- a/docs/Versions.md +++ b/docs/Versions.md @@ -11,8 +11,11 @@ Versioned formulae we include in [homebrew/core](https://github.com/homebrew/hom * Versioned formulae should differ in major/minor (not patch) versions from the current stable release. This is because patch versions indicate bug or security updates and we want to ensure you apply security updates. * Upstream should have a release branch for the versioned formulae version and still make security updates for that version, when necessary. For example, [PHP 5.5 was not a supported version but PHP 7.2 was](http://php.net/supported-versions.php) in January 2018 * Formulae that depend on versioned formulae must not depend on the same formulae at two different versions twice in their recursive dependencies. For example, if you depend on `openssl@1.0` and `foo`, and `foo` depends on `openssl` then you must instead use `openssl`. -* Versioned formulae should only be linkable at the same time as their non-versioned counterpart if the upstream project provides support for it, e.g. using suffixed binaries. If this is not possible, use `keg_only :versioned_formula` to allow users to have multiple versions installed at once. Note `keg_only :versioned_formula` should not `post_install` anything in the `HOMEBREW_PREFIX` that conflicts with or duplicates the non-versioned counterpart (or other versioned formulae). For example, a `node@6` formula should not install its `npm` into `HOMEBREW_PREFIX` like the `node` formula does. +* Versioned formulae should only be linkable at the same time as their non-versioned counterpart if the upstream project provides support for it, e.g. using suffixed binaries. If this is not possible, use `keg_only :versioned_formula` to allow users to have multiple versions installed at once. +* A `keg_only :versioned_formula` should not `post_install` anything in the `HOMEBREW_PREFIX` that conflicts with or duplicates the non-versioned counterpart (or other versioned formulae). For example, a `node@6` formula should not install its `npm` into `HOMEBREW_PREFIX` like the `node` formula does. * Versioned formulae submitted should be expected to be used by a large number of people. If this ceases to be the case: they will be removed. We will aim not to remove those in the [top 1000 `install_on_request` formulae](https://brew.sh/analytics/install-on-request/). +* Versioned formulae should not have `resource`s that require security updates. For example, a `node@6` formula should not have an `npm` resource but instead rely on the `npm` provided by the upstream tarball. +* Versioned formulae should be as similar as possible and sensible to the unversioned formulae. Creating or updating a versioned formula should be a chance to ask questions of the unversioned formula e.g. can some unused or useless options be removed or made default? * No more than five versions of a formula (including the non-versioned one) will be supported at any given time, regardless of usage. When removing formulae that violate this we will aim to do so based on usage and support status rather than age. Homebrew's versions are not intended to be used for any old versions you personally require for your project. You should create your own [tap](How-to-Create-and-Maintain-a-Tap.md) for formulae you or your organisation wish to control the versioning of or those that do not meet the above standards. Software that has regular API or ABI breaking releases still needs to meet all the above requirements; that a `brew upgrade` has broken something for you is not an argument for us to add and maintain a formula for you. From 5536f49305fbb45261afcc1740a7a943a1c95f40 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 22 Feb 2018 14:20:23 +0000 Subject: [PATCH 50/69] Cross-platform java detection --- Library/Homebrew/extend/os/mac/system_config.rb | 13 +++++++++++++ Library/Homebrew/system_config.rb | 12 +++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/system_config.rb b/Library/Homebrew/extend/os/mac/system_config.rb index 7961347810..c0a28d3e95 100644 --- a/Library/Homebrew/extend/os/mac/system_config.rb +++ b/Library/Homebrew/extend/os/mac/system_config.rb @@ -23,6 +23,19 @@ class SystemConfig @ponk.join(", ") unless @ponk.empty? end + def describe_java + # java_home doesn't exist on all macOSs; it might be missing on older versions. + return "N/A" unless File.executable? "/usr/libexec/java_home" + + java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast", err: :close) + return "N/A" unless $CHILD_STATUS.success? + javas = [] + REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item| + javas << item.text + end + javas.uniq.join(", ") + end + def describe_xquartz return "N/A" unless MacOS::XQuartz.installed? "#{MacOS::XQuartz.version} => #{describe_path(MacOS::XQuartz.prefix)}" diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index 28eecf951f..9a8d1d9d3a 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -131,16 +131,10 @@ class SystemConfig end def describe_java - # java_home doesn't exist on all macOSs; it might be missing on older versions. - return "N/A" unless File.executable? "/usr/libexec/java_home" - - java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast", err: :close) + return "N/A" unless which "java" + java_version = Utils.popen_read("java", "-version") return "N/A" unless $CHILD_STATUS.success? - javas = [] - REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item| - javas << item.text - end - javas.uniq.join(", ") + java_version[/java version "([0-9\._]+)"/, 1] || "N/A" end def describe_git From 977c3323d2a795d6f57cd70cb6b2453f38084ed9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 22 Feb 2018 18:47:29 +0000 Subject: [PATCH 51/69] docs.brew.sh updates - Remove no longer needed `acme-challenge` file - Set title, description, social image, logo, etc. for SEO - Use extensionless permalinks (old links still work) - Cleanup `_config.yml` - Import latest `_layouts/base` from https://brew.sh --- ...gQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k | 1 - docs/Common-Issues.md | 2 +- docs/Formula-Cookbook.md | 2 +- docs/Manpage.md | 10 ++-- docs/New-Maintainer-Checklist.md | 4 +- docs/_config.yml | 38 ++++++++++----- docs/_layouts/base.html | 46 ++++++++++++------- 7 files changed, 65 insertions(+), 38 deletions(-) delete mode 100644 docs/.well-known/acme-challenge/CgQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k diff --git a/docs/.well-known/acme-challenge/CgQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k b/docs/.well-known/acme-challenge/CgQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k deleted file mode 100644 index d3ba42ff4b..0000000000 --- a/docs/.well-known/acme-challenge/CgQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k +++ /dev/null @@ -1 +0,0 @@ -CgQNmjNTd6fUriinp4XpuRI5PBGp7zEXbEEsQceSD0k.unNjkXuFqjKx4BO8gem4nzeMm1tSZxPPeBjNqQhFCqQ diff --git a/docs/Common-Issues.md b/docs/Common-Issues.md index 01ab4e8065..a3a31ce80b 100644 --- a/docs/Common-Issues.md +++ b/docs/Common-Issues.md @@ -80,7 +80,7 @@ When running `brew upgrade`, you see something like this: $ brew upgrade Error: undefined method `include?' for nil:NilClass Please report this bug: - https://docs.brew.sh/Troubleshooting.html + https://docs.brew.sh/Troubleshooting /usr/local/Library/Homebrew/formula.rb:393:in `canonical_name' /usr/local/Library/Homebrew/formula.rb:425:in `factory' /usr/local/Library/Contributions/examples/brew-upgrade.rb:7 diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index c4db9e9f8b..1f2b2e89e2 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -344,7 +344,7 @@ If you have already forked Homebrew on GitHub, then you can manually push (just git push https://github.com/myname/homebrew-core/ ``` -Now, [open a pull request](https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request.html) for your changes. +Now, [open a pull request](https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request) for your changes. * One formula per commit; one commit per formula * Keep merge commits out of the pull request diff --git a/docs/Manpage.md b/docs/Manpage.md index e4f189490b..91f9e0414d 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -39,7 +39,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note * `analytics` [`state`]: Display anonymous user behaviour analytics state. - Read more at . + Read more at . * `analytics` (`on`|`off`): Turn on/off Homebrew's analytics. @@ -212,7 +212,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note information on all installed formulae. See the docs for examples of using the JSON output: - + * `install` [`--debug`] [`--env=`(`std`|`super`)] [`--ignore-dependencies`|`--only-dependencies`] [`--cc=``compiler`] [`--build-from-source`|`--force-bottle`] [`--devel`|`--HEAD`] [`--keep-tmp`] [`--build-bottle`] [`--force`] [`--verbose`] `formula` [`options` ...]: Install `formula`. @@ -493,7 +493,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note Pass `--installed` to get information on installed taps. See the docs for examples of using the JSON output: - + * `tap-pin` `tap`: Pin `tap`, prioritizing its formulae over core when formula names are supplied @@ -914,7 +914,7 @@ scripts that reside somewhere in the `PATH`, named `brew-``cmdname` or to create your own commands without modifying Homebrew's internals. Instructions for creating your own commands can be found in the docs: - + ## SPECIFYING FORMULAE @@ -1031,7 +1031,7 @@ can take several different forms: *Default:* the number of available CPU cores. * `HOMEBREW_NO_ANALYTICS`: - If set, Homebrew will not send analytics. See: + If set, Homebrew will not send analytics. See: * `HOMEBREW_NO_AUTO_UPDATE`: If set, Homebrew will not auto-update before running `brew install`, diff --git a/docs/New-Maintainer-Checklist.md b/docs/New-Maintainer-Checklist.md index 72abf2ddb8..cb4919d697 100644 --- a/docs/New-Maintainer-Checklist.md +++ b/docs/New-Maintainer-Checklist.md @@ -39,8 +39,8 @@ A few requests: own fork. - if still in doubt please ask for help and we'll help you out - please read: - - https://docs.brew.sh/Brew-Test-Bot-For-Core-Contributors.html - - https://docs.brew.sh/Maintainer-Guidelines.html + - https://docs.brew.sh/Brew-Test-Bot-For-Core-Contributors + - https://docs.brew.sh/Maintainer-Guidelines - anything else you haven't read on https://docs.brew.sh How does that sound? diff --git a/docs/_config.yml b/docs/_config.yml index 210d0b0d40..d535e7bd39 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,17 +1,31 @@ -include: [.well-known] -exclude: [bin, vendor, CNAME, Gemfile, Gemfile.lock] +title: Homebrew Documentation +description: Documentation for the missing package manager for macOS. -# Same as GitHub Pages -# https://help.github.com/articles/using-jekyll-with-pages#troubleshooting -# Disable despite enabled on GitHub Pages for supported plugins to work. -# safe: true -kramdown: - input: GFM - hard_wrap: false -lsi: false -highlighter: rouge +exclude: + - bin + - CNAME + - Gemfile* + - README.md + - vendor -gems: +plugins: - jekyll-feed - jekyll-sitemap - jekyll-seo-tag + +defaults: + - scope: + path: "" + values: + image: /img/homebrew-256x256.png + +logo: /img/homebrew-256x256.png + +github: + repository_nwo: Homebrew/brew + +twitter: + username: MacHomebrew + +facebook: + publisher: https://www.facebook.com/machomebrew/ diff --git a/docs/_layouts/base.html b/docs/_layouts/base.html index ee631bda54..422e98bed8 100644 --- a/docs/_layouts/base.html +++ b/docs/_layouts/base.html @@ -1,21 +1,29 @@ +{% assign t = site.data.locales[page.lang][page.lang] %} {% if page.title %} - {{ page.title }} — Homebrew - {% elsif page.direction == "rtl" %} - {{ page.subtitle }} — Homebrew + {{ page.title }} — {{ site.title }} + {% elsif t.subtitle %} + {% if page.direction == "rtl" %} + {{ site.title }} — {{ t.subtitle }} {% else %} - Homebrew — {{ page.subtitle }} + {{ t.subtitle }} — {{ t.subtitle }} + {% endif %} + {% else %} + {{ site.title }} {% endif %} {% seo title=false %} {% feed_meta %} - + + {% if site.url == "http://localhost:4000" %} + + {% endif %} - {% for lang in site.langs %} - {% if lang.langcode == "en" %} + {% if site.data.locales %} + {% assign locales = site.data.locales | sort %} + {% for locale in locales %} + {% assign lang = locale[0] %} + {% if lang == "en" %} {% else %} - + {% endif %} {% endfor %} + {% endif %}