From 961b5fff9d4426a1b53da332c8016dcd61eae48a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 13 Dec 2016 00:37:40 +0000 Subject: [PATCH 001/176] formula_installer: prevent version mismatched deps Don't allow e.g. the use of `openssl` and `openssl@1.1` in the same dependency tree to avoid runtime failures and general weirdness. --- Library/Homebrew/formula_installer.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index bd1cc93799..c701aeb398 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -146,7 +146,23 @@ class FormulaInstaller return if ignore_deps? recursive_deps = formula.recursive_dependencies - unlinked_deps = recursive_deps.map(&:to_formula).select do |dep| + recursive_formulae = recursive_deps.map(&:to_formula) + + version_hash = {} + version_conflicts = Set.new + recursive_formulae.each do |f| + name = f.name + unversioned_name, = name.split("@") + version_hash[unversioned_name] ||= Set.new + version_hash[unversioned_name] << name + next if version_hash[unversioned_name].length < 2 + version_conflicts += version_hash[unversioned_name] + end + unless version_conflicts.empty? + raise CannotInstallFormulaError, "#{formula.full_name} contains conflicting version dependencies (#{version_conflicts.to_a.join " "}) so cannot be installed" + end + + unlinked_deps = recursive_formulae.select do |dep| dep.installed? && !dep.keg_only? && !dep.linked_keg.directory? end From 8f80cc65686bd6b5eed365fd7d9f822366c01943 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 13 Dec 2016 01:53:05 +0000 Subject: [PATCH 002/176] diagnostic: check for bad tap files. Check for Ruby files in taps that are outside of the detected `Formula` directory for a tap but inside one of the other potential directories. This usually indicates a formula has been added in the wrong directory in a tap and is used to fail CI in this case. --- Library/Homebrew/diagnostic.rb | 23 +++++++++++++++++++++++ Library/Homebrew/tap.rb | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index e8506ce807..64c155fde7 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -1075,6 +1075,29 @@ module Homebrew message end + def check_for_tap_ruby_files_locations + bad_tap_files = {} + Tap.each do |tap| + unused_formula_dirs = tap.potential_formula_dirs - [tap.formula_dir] + unused_formula_dirs.each do |dir| + next unless dir.exist? + dir.children.each do |path| + next unless path.extname == ".rb" + bad_tap_files[tap] ||= [] + bad_tap_files[tap] << path + end + end + end + return if bad_tap_files.empty? + bad_tap_files.keys.map do |tap| + <<-EOS.undent + Found Ruby file outside #{tap} tap formula directory + (#{tap.formula_dir}): + #{bad_tap_files[tap].join("\n ")} + EOS + end.join("\n") + end + def all methods.map(&:to_s).grep(/^check_/) end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 68b21ac604..4b59f23446 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -292,7 +292,11 @@ class Tap # path to the directory of all {Formula} files for this {Tap}. def formula_dir - @formula_dir ||= [path/"Formula", path/"HomebrewFormula", path].detect(&:directory?) + @formula_dir ||= potential_formula_dirs.detect(&:directory?) + end + + def potential_formula_dirs + @potential_formula_dirs ||= [path/"Formula", path/"HomebrewFormula", path].freeze end # path to the directory of all {Cask} files for this {Tap}. From 0a007fc983c83d610b918bdd8e38038e2732c170 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Thu, 15 Dec 2016 22:36:39 +0000 Subject: [PATCH 003/176] Updated homepage 404 check to use explicit parameters and return the status code --- Library/Homebrew/dev-cmd/audit.rb | 9 ++++----- Library/Homebrew/test/audit_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0112c524ff..cc5a0e62c3 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -564,11 +564,10 @@ class FormulaAuditor end return unless @online - begin - nostdout { curl "--connect-timeout", "15", "-o", "/dev/null", homepage } - rescue ErrorDuringExecution - problem "The homepage is not reachable (curl exit code #{$?.exitstatus})" - end + status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ + "--write-out", "%{http_code}", homepage + return if status_code.start_with? "20" + problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end def audit_bottle_spec diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 2725f906e3..dace4dc2ba 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -429,8 +429,8 @@ class FormulaAuditorTests < Homebrew::TestCase fa.audit_homepage assert_equal ["The homepage should start with http or https " \ - "(URL is #{fa.formula.homepage}).", "The homepage is not reachable " \ - "(curl exit code #{$?.exitstatus})"], fa.problems + "(URL is #{fa.formula.homepage}).", "The homepage #{fa.formula.homepage} is not reachable " \ + "(HTTP status code 000)"], fa.problems formula_homepages = { "bar" => "http://www.freedesktop.org/wiki/bar", From ebb659af7da12771efe134e1f9386324423f4246 Mon Sep 17 00:00:00 2001 From: "Bob W. Hogg" Date: Sun, 18 Dec 2016 14:50:38 -0800 Subject: [PATCH 004/176] Add Kaby Lake to Linux hardware list Note that no Mac hardware using a Kaby Lake processor has been released yet, so do not add it to the equivalent list for macOS. --- Library/Homebrew/extend/os/linux/hardware/cpu.rb | 2 ++ Library/Homebrew/test/hardware_test.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/linux/hardware/cpu.rb b/Library/Homebrew/extend/os/linux/hardware/cpu.rb index 2472c60ed1..9d779f789a 100644 --- a/Library/Homebrew/extend/os/linux/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/linux/hardware/cpu.rb @@ -47,6 +47,8 @@ module Hardware :haswell when 0x3d, 0x47, 0x4f, 0x56 :broadwell + when 0x8e + :kabylake else cpu_family_model end diff --git a/Library/Homebrew/test/hardware_test.rb b/Library/Homebrew/test/hardware_test.rb index 2bea5387d5..69f881a60d 100644 --- a/Library/Homebrew/test/hardware_test.rb +++ b/Library/Homebrew/test/hardware_test.rb @@ -8,7 +8,7 @@ class HardwareTests < Homebrew::TestCase if Hardware::CPU.intel? def test_hardware_intel_family - families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :dunno] + families = [:core, :core2, :penryn, :nehalem, :arrandale, :sandybridge, :ivybridge, :haswell, :broadwell, :skylake, :kabylake, :dunno] assert_includes families, Hardware::CPU.family end end From 637aae48e4814e2799a06838c24f06a2a2ef0a36 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Mon, 19 Dec 2016 08:45:21 +0000 Subject: [PATCH 005/176] Markups --- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index cc5a0e62c3..754cb597b6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -564,8 +564,8 @@ class FormulaAuditor end return unless @online - status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", \ - "--write-out", "%{http_code}", homepage + status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", + "--write-out", "%{http_code}", homepage return if status_code.start_with? "20" problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end From cc09bb14c16c8e4f6b360f30074522c2ee25167b Mon Sep 17 00:00:00 2001 From: Tom Schoonjans Date: Mon, 19 Dec 2016 21:51:57 +0100 Subject: [PATCH 006/176] brew create: add meson support meson is quickly gaining popularity as build system, in combination with ninja. Several Gnome projects for example are currently transitioning from autotools to meson, mostly because it allows for Visual Studio builds, which is impossible to accomplish with autotools. In order to facilitate generating meson based Formulas, I added support for meson to brew-create. --- Library/Homebrew/dev-cmd/create.rb | 17 ++++++++++++++++- docs/brew.1.html | 5 +++-- manpages/brew-cask.1 | 2 +- manpages/brew.1 | 6 +++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index 11544dbefe..5d46e73b95 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -1,4 +1,4 @@ -#: * `create` [`--autotools`|`--cmake`] [`--no-fetch`] [`--set-name` ] [`--set-version` ] [`--tap` `/`]: +#: * `create` [`--autotools`|`--cmake`|`--meson`] [`--no-fetch`] [`--set-name` ] [`--set-version` ] [`--tap` `/`]: #: Generate a formula for the downloadable file at and open it in the editor. #: Homebrew will attempt to automatically derive the formula name #: and version, but if it fails, you'll have to make your own template. The `wget` @@ -8,6 +8,7 @@ #: #: If `--autotools` is passed, create a basic template for an Autotools-style build. #: If `--cmake` is passed, create a basic template for a CMake-style build. +#: If `--meson` is passed, create a basic template for a Meson-style build. #: #: If `--no-fetch` is passed, Homebrew will not download to the cache and #: will thus not add the SHA256 to the formula for you. @@ -59,6 +60,8 @@ module Homebrew :cmake elsif ARGV.include? "--autotools" :autotools + elsif ARGV.include? "--meson" + :meson end if fc.name.nil? || fc.name.strip.empty? @@ -175,6 +178,9 @@ class FormulaCreator <% if mode == :cmake %> depends_on "cmake" => :build + <% elsif mode == :meson %> + depends_on "meson" => :build + depends_on "ninja" => :build <% elsif mode.nil? %> # depends_on "cmake" => :build <% end %> @@ -191,6 +197,13 @@ class FormulaCreator "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=\#{prefix}" + <% elsif mode == :meson %> + mkdir "build" do + system "meson", "--prefix=\#{prefix}", ".." + system "ninja" + system "ninja", "test" + system "ninja", "install" + end <% else %> # Remove unrecognized options if warned by configure system "./configure", "--disable-debug", @@ -199,7 +212,9 @@ class FormulaCreator "--prefix=\#{prefix}" # system "cmake", ".", *std_cmake_args <% end %> + <% if mode != :meson %> system "make", "install" # if this fails, try separate make/make install steps + <% end %> end test do diff --git a/docs/brew.1.html b/docs/brew.1.html index 7b7251faf7..8a24e499b7 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -504,7 +504,7 @@ message.

url-and-sha256 style specification into a tag-and-revision style specification, nor vice versa. It must use whichever style specification the preexisting formula already uses.

-
create URL [--autotools|--cmake] [--no-fetch] [--set-name name] [--set-version version] [--tap user/repo]

Generate a formula for the downloadable file at URL and open it in the editor. +

create URL [--autotools|--cmake|--meson] [--no-fetch] [--set-name name] [--set-version version] [--tap user/repo]

Generate a formula for the downloadable file at URL and open it in the editor. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you'll have to make your own template. The wget formula serves as a simple example. For the complete API have a look at

@@ -512,7 +512,8 @@ formula serves as a simple example. For the complete API have a look at

http://www.rubydoc.info/github/Homebrew/brew/master/Formula

If --autotools is passed, create a basic template for an Autotools-style build. -If --cmake is passed, create a basic template for a CMake-style build.

+If --cmake is passed, create a basic template for a CMake-style build. +If --meson is passed, create a basic template for a Meson-style build.

If --no-fetch is passed, Homebrew will not download URL to the cache and will thus not add the SHA256 to the formula for you.

diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index a14c7521ab..af5335f796 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW\-CASK" "1" "November 2016" "Homebrew" "brew-cask" +.TH "BREW\-CASK" "1" "December 2016" "Homebrew" "brew-cask" . .SH "NAME" \fBbrew\-cask\fR \- a friendly binary installer for macOS diff --git a/manpages/brew.1 b/manpages/brew.1 index f51468a7f0..c25f73af97 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "November 2016" "Homebrew" "brew" +.TH "BREW" "1" "December 2016" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for macOS @@ -695,14 +695,14 @@ If \fB\-\-message=\fR\fImessage\fR is passed, append \fImessage\fR to the defaul Note that this command cannot be used to transition a formula from a url\-and\-sha256 style specification into a tag\-and\-revision style specification, nor vice versa\. It must use whichever style specification the preexisting formula already uses\. . .TP -\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR] +\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR|\fB\-\-meson\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR] Generate a formula for the downloadable file at \fIURL\fR and open it in the editor\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The \fBwget\fR formula serves as a simple example\. For the complete API have a look at . .IP \fIhttp://www\.rubydoc\.info/github/Homebrew/brew/master/Formula\fR . .IP -If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. +If \fB\-\-autotools\fR is passed, create a basic template for an Autotools\-style build\. If \fB\-\-cmake\fR is passed, create a basic template for a CMake\-style build\. If \fB\-\-meson\fR is passed, create a basic template for a Meson\-style build\. . .IP If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the cache and will thus not add the SHA256 to the formula for you\. From 3ebd7df62d0b05a8a010bec74793cc4e688a2fc8 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Thu, 22 Dec 2016 00:54:08 -0500 Subject: [PATCH 007/176] bump-formula-pr: fix removal of old mirrors Previously, old mirrors are only removed if the requested spec is stable, and if the mirror lines only have two leading spaces. This leads to stale mirror line(s) when the formula a stable block like stable do url "http://example.com/v1.0.tar.gz" mirror "http://example.net/v1.0.tar.gz" end where the mirror line is lead by four spaces. In this commit, we discard the /(^ mirror .*\n)?/ pattern, and instead create a pattern with the exact url and flexible leading spaces for each mirror of the requested spec. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index b1f851b8db..8fdbd97b6f 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -156,7 +156,9 @@ module Homebrew replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"] end - replacement_pairs << [/(^ mirror .*\n)?/, ""] if requested_spec == :stable + replacement_pairs += formula_spec.mirrors.map do |mirror| + [/ +mirror \"#{mirror}\"\n/m, ""] + end replacement_pairs += if new_url_hash [ From 1ab8b5e35b46b9029c75016fb02c2bd63b4f3f08 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Thu, 22 Dec 2016 18:57:57 -0500 Subject: [PATCH 008/176] create: remove :x11 dep from new formula template --- Library/Homebrew/dev-cmd/create.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index f684f95f6c..3b8ba3344a 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -178,7 +178,6 @@ class FormulaCreator <% elsif mode.nil? %> # depends_on "cmake" => :build <% end %> - depends_on :x11 # if your formula requires any X11/XQuartz components def install # ENV.deparallelize # if your formula fails when building in parallel From 3f724825d36b467fb8a0ae074e8332369edaa304 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 23 Dec 2016 15:01:02 +0000 Subject: [PATCH 009/176] Revert "Revert "formula: runtime deps of build deps aren't runtime"" This reverts commit 862c3ba4a2fb76140e46fdf49a1ea6857f140a29. --- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/test/formula_test.rb | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index b3927d260b..600f9c2e97 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1505,7 +1505,7 @@ class Formula # Returns a list of Dependency objects that are required at runtime. # @private def runtime_dependencies - recursive_dependencies.reject(&:build?) + recursive_dependencies { |_, dep| Dependency.prune if dep.build? } end # Returns a list of formulae depended on by this formula that aren't diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index a6db1b57f2..28d376b7c2 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -651,12 +651,19 @@ class FormulaTests < Homebrew::TestCase f4 = formula("f4") do url "f4-1.0" - depends_on "f3" + depends_on "f1" + end + stub_formula_loader f4 + + f5 = formula("f5") do + url "f5-1.0" + depends_on "f3" => :build + depends_on "f4" end - assert_equal %w[f3], f4.deps.map(&:name) - assert_equal %w[f1 f2 f3], f4.recursive_dependencies.map(&:name) - assert_equal %w[f2 f3], f4.runtime_dependencies.map(&:name) + assert_equal %w[f3 f4], f5.deps.map(&:name) + assert_equal %w[f1 f2 f3 f4], f5.recursive_dependencies.map(&:name) + assert_equal %w[f1 f4], f5.runtime_dependencies.map(&:name) end def test_to_hash From 43f2e9e7bbb5917b14af81fd226d763dae388cdb Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 23 Dec 2016 15:01:02 +0000 Subject: [PATCH 010/176] formula: don't expand unused optional dependencies This properly addresses Homebrew/homebrew-core#7826. --- Library/Homebrew/formula.rb | 7 ++++++- Library/Homebrew/test/formula_test.rb | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 600f9c2e97..4578216853 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1505,7 +1505,12 @@ class Formula # Returns a list of Dependency objects that are required at runtime. # @private def runtime_dependencies - recursive_dependencies { |_, dep| Dependency.prune if dep.build? } + recursive_dependencies do |_dependent, dependency| + Dependency.prune if dependency.build? + if dependency.optional? || dependency.recommended? + Dependency.prune unless build.with?(dependency) + end + end end # Returns a list of formulae depended on by this formula that aren't diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 28d376b7c2..81022d2202 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -666,6 +666,29 @@ class FormulaTests < Homebrew::TestCase assert_equal %w[f1 f4], f5.runtime_dependencies.map(&:name) end + def test_runtime_dependencies_with_optional_deps_from_tap + tap_loader = mock + tap_loader.stubs(:get_formula).raises(RuntimeError, "tried resolving tap formula") + Formulary.stubs(:loader_for).with("foo/bar/f1", from: nil).returns(tap_loader) + + stub_formula_loader formula("f2") { url "f2-1.0" }, "baz/qux/f2" + + f3 = formula("f3") do + url "f3-1.0" + depends_on "foo/bar/f1" => :optional + depends_on "baz/qux/f2" + end + + # f1 shouldn't be loaded by default. + # If it is, an exception will be raised. + assert_equal %w[baz/qux/f2], f3.runtime_dependencies.map(&:name) + + # If --with-f1, f1 should be loaded. + stub_formula_loader formula("f1") { url "f1-1.0" }, "foo/bar/f1" + f3.build = BuildOptions.new(Options.create(%w[--with-f1]), f3.options) + assert_equal %w[foo/bar/f1 baz/qux/f2], f3.runtime_dependencies.map(&:name) + end + def test_to_hash f1 = formula("foo") do url "foo-1.0" From ef5cff5e7196b7371239d1028a0f07cd8af980b9 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 23 Dec 2016 20:56:39 +0000 Subject: [PATCH 011/176] formula: make runtime_dependencies logic clearer --- Library/Homebrew/formula.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4578216853..bc1dbd9705 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1507,9 +1507,7 @@ class Formula def runtime_dependencies recursive_dependencies do |_dependent, dependency| Dependency.prune if dependency.build? - if dependency.optional? || dependency.recommended? - Dependency.prune unless build.with?(dependency) - end + Dependency.prune if !dependency.required? && build.without?(dependency) end end From d09153763624096d6a300f02ce395f03967d01af Mon Sep 17 00:00:00 2001 From: Uladzislau Shablinski Date: Mon, 26 Dec 2016 20:16:04 +0300 Subject: [PATCH 012/176] Don't drop .rb suffix for formula names Fixes #1718 --- Library/Homebrew/formulary.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 6ed5b91ba7..7e8811c9a6 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -333,7 +333,9 @@ class Formulary return TapLoader.new(ref, from: from) end - return FromPathLoader.new(ref) if File.extname(ref) == ".rb" + if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist? + return FromPathLoader.new(ref) + end formula_with_that_name = core_path(ref) if formula_with_that_name.file? From 0a20edf9454423537a7f4d3b3659ad56f0151775 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 17 Nov 2016 16:16:31 +0000 Subject: [PATCH 013/176] tests: don't run LinkTests twice see #1526 --- Library/Homebrew/test/keg_test.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 2c91027e5b..b875c7205b 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -2,7 +2,7 @@ require "testing_env" require "keg" require "stringio" -class LinkTests < Homebrew::TestCase +class LinkTestCase < Homebrew::TestCase include FileUtils def setup_test_keg(name, version) @@ -44,7 +44,9 @@ class LinkTests < Homebrew::TestCase rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" end +end +class LinkTests < LinkTestCase def test_empty_installation %w[.DS_Store INSTALL_RECEIPT.json LICENSE.txt].each do |file| touch @keg/file @@ -315,7 +317,7 @@ class LinkTests < Homebrew::TestCase end end -class InstalledDependantsTests < LinkTests +class InstalledDependantsTests < LinkTestCase def stub_formula_name(name) f = formula(name) { url "foo-1.0" } stub_formula_loader f From e5d7e13c63e7e942f3acdd5c0fac7bed624f52c4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 27 Dec 2016 17:26:21 +0000 Subject: [PATCH 014/176] keg: installed dependencies of unknown formulae Previously, trying to resolve the dependencies of a keg would raise an exception if the formulae for any of the dependencies could not be found (e.g. if it had been moved to another tap). This commit updates the dependency finding logic to catch these exceptions, and fall back to comparing names and taps of formulae, which should give the correct behaviour. Fixes #1586. --- Library/Homebrew/keg.rb | 17 ++++++++++++++--- Library/Homebrew/test/keg_test.rb | 12 +++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 1de4ce1f0c..3d2d21d692 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -139,6 +139,10 @@ class Keg raise NotAKegError, "#{path} is not inside a keg" end + def self.all + Formula.racks.flat_map(&:subdirs).map { |d| new(d) } + end + attr_reader :path, :name, :linked_keg_record, :opt_record protected :path @@ -353,14 +357,21 @@ class Keg end def installed_dependents - Formula.installed.flat_map(&:installed_kegs).select do |keg| + my_tab = Tab.for_keg(self) + Keg.all.select do |keg| tab = Tab.for_keg(keg) next if tab.runtime_dependencies.nil? # no dependency information saved. tab.runtime_dependencies.any? do |dep| # Resolve formula rather than directly comparing names # in case of conflicts between formulae from different taps. - dep_formula = Formulary.factory(dep["full_name"]) - dep_formula == to_formula && dep["version"] == version.to_s + begin + dep_formula = Formulary.factory(dep["full_name"]) + next false unless dep_formula == to_formula + rescue FormulaUnavailableError + next false unless my_tab["full_name"] = dep["full_name"] + end + + dep["version"] == version.to_s end end end diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index b875c7205b..cf5f13a6c9 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -47,6 +47,11 @@ class LinkTestCase < Homebrew::TestCase end class LinkTests < LinkTestCase + def test_all + Formula.clear_racks_cache + assert_equal [@keg], Keg.all + end + def test_empty_installation %w[.DS_Store INSTALL_RECEIPT.json LICENSE.txt].each do |file| touch @keg/file @@ -355,10 +360,11 @@ class InstalledDependantsTests < LinkTestCase # from a file path or URL. def test_unknown_formula Formulary.unstub(:loader_for) - dependencies [] + alter_tab { |t| t.source["tap"] = "some/tap" } + dependencies [{ "full_name" => "some/tap/bar", "version" => "1.0" }] alter_tab { |t| t.source["path"] = nil } - assert_empty @keg.installed_dependents - assert_nil Keg.find_some_installed_dependents([@keg]) + assert_equal [@dependent], @keg.installed_dependents + assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) end def test_no_dependencies_anywhere From 4c379dffb740478f7dba3df078435dc8f64b8a14 Mon Sep 17 00:00:00 2001 From: Andrew McKinlay Date: Tue, 27 Dec 2016 16:35:40 -0500 Subject: [PATCH 015/176] Correct location of taps (doc) --- docs/Interesting-Taps-&-Forks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Interesting-Taps-&-Forks.md b/docs/Interesting-Taps-&-Forks.md index d23277b15c..d42a97f54d 100644 --- a/docs/Interesting-Taps-&-Forks.md +++ b/docs/Interesting-Taps-&-Forks.md @@ -60,4 +60,4 @@ You can be added as a maintainer for one of the Homebrew organization taps and a ## Technical Details -Your taps are git repositories located at `$(brew --prefix)/Library/Taps`. +Your taps are git repositories located at `$(brew --repository)/Library/Taps`. From 3a27d8121970dab95f2d28db81189ddf9619c0f5 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 27 Dec 2016 22:58:44 +0000 Subject: [PATCH 016/176] keg: fix dependents with unavailable formulae Because of an accidental use of `=` instead of `==`, the source formula check would be skipped when determining if a keg depended on another one (so only the versions would be compared). Fixed that comparison, and updated the corresponding test. Glad I caught that! --- Library/Homebrew/keg.rb | 4 ++-- Library/Homebrew/test/keg_test.rb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 3d2d21d692..756b272885 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -357,7 +357,7 @@ class Keg end def installed_dependents - my_tab = Tab.for_keg(self) + tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) next if tab.runtime_dependencies.nil? # no dependency information saved. @@ -368,7 +368,7 @@ class Keg dep_formula = Formulary.factory(dep["full_name"]) next false unless dep_formula == to_formula rescue FormulaUnavailableError - next false unless my_tab["full_name"] = dep["full_name"] + next false unless "#{tap}/#{name}" == dep["full_name"] end dep["version"] == version.to_s diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index cf5f13a6c9..4fe7c6a3cf 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -360,9 +360,11 @@ class InstalledDependantsTests < LinkTestCase # from a file path or URL. def test_unknown_formula Formulary.unstub(:loader_for) - alter_tab { |t| t.source["tap"] = "some/tap" } - dependencies [{ "full_name" => "some/tap/bar", "version" => "1.0" }] - alter_tab { |t| t.source["path"] = nil } + alter_tab(@keg) do |t| + t.source["tap"] = "some/tap" + t.source["path"] = nil + end + dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }] assert_equal [@dependent], @keg.installed_dependents assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) end From 0097dbe4eeb5071c1775927a7e8588530b219f70 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 20 Dec 2016 03:39:30 -0500 Subject: [PATCH 017/176] brew deps: support --full-name in --installed, --all, and --tree modes --- Library/Homebrew/cmd/deps.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index a5089392fc..b5240b2c96 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -66,16 +66,16 @@ module Homebrew else all_deps = deps_for_formulae(ARGV.formulae, !ARGV.one?, &(mode.union? ? :| : :&)) all_deps = all_deps.select(&:installed?) if mode.installed? - all_deps = if ARGV.include? "--full-name" - all_deps.map(&:to_formula).map(&:full_name) - else - all_deps.map(&:name) - end.uniq + all_deps = all_deps.map(&method(:dep_display_name)).uniq all_deps.sort! unless mode.topo_order? puts all_deps end end + def dep_display_name(d) + ARGV.include?("--full-name") ? d.to_formula.full_name : d.name + end + def deps_for_formula(f, recursive = false) includes = [] ignores = [] @@ -127,7 +127,10 @@ module Homebrew end def puts_deps(formulae) - formulae.each { |f| puts "#{f.full_name}: #{deps_for_formula(f).sort_by(&:name) * " "}" } + formulae.each do |f| + deps = deps_for_formula(f).sort_by(&:name).map(&method(:dep_display_name)) + puts "#{f.full_name}: #{deps.join(" ")}" + end end def puts_deps_tree(formulae) @@ -143,14 +146,14 @@ module Homebrew max = reqs.length - 1 reqs.each_with_index do |req, i| chr = i == max ? "└──" : "├──" - puts prefix + "#{chr} :#{req.to_dependency.name}" + puts prefix + "#{chr} :#{dep_display_name(req.to_dependency)}" end deps = f.deps.default max = deps.length - 1 deps.each_with_index do |dep, i| chr = i == max ? "└──" : "├──" prefix_ext = i == max ? " " : "│ " - puts prefix + "#{chr} #{dep.name}" + puts prefix + "#{chr} #{dep_display_name(dep)}" recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext) end end From 8ffe231f44f18aeb482a213e50c3959a3f6405ab Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 29 Dec 2016 11:46:49 +0000 Subject: [PATCH 018/176] audit: don't allow openssl & libressl dependency. Formulae should not depend on both OpenSSL and LibreSSL (even optionally). This is to avoid descending into madness where every formulae that could use LibreSSL has to have option and switching logic. Homebrew has standardised on OpenSSL and will do so everywhere that LibreSSL is not a hard requirement. --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 93431c9514..ef22cbb7a4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -788,6 +788,10 @@ class FormulaAuditor problem "Please set plist_options when using a formula-defined plist." end + if text =~ /depends_on\s+['"]openssl['"]/ && text =~ /depends_on\s+['"]libressl['"]/ + problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)." + end + return unless text.include?('require "language/go"') && !text.include?("go_resource") problem "require \"language/go\" is unnecessary unless using `go_resource`s" end From 6f44dc41d5316e26a3ac533019199da502f430fc Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 29 Dec 2016 12:50:41 +0000 Subject: [PATCH 019/176] development_tools: remove unused method. --- Library/Homebrew/development_tools.rb | 4 ---- Library/Homebrew/extend/os/mac/development_tools.rb | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index ea7f5837d0..bee2b86dea 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -119,10 +119,6 @@ class DevelopmentTools @clang_version = @clang_build_version = nil @non_apple_gcc_version = {} end - - def tar_supports_xz? - false - end end end diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index 7c97b9d69e..381b26e661 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -76,9 +76,5 @@ class DevelopmentTools end end end - - def tar_supports_xz? - false - end end end From 59180ec370560d461d9fa44a3e510e9f1ea68375 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 23 Dec 2016 20:29:56 +0000 Subject: [PATCH 020/176] audit: improve reliability of homepage audit. - Don't run on Yosemite where the system Curl is too old for some modern HTTPS homepages - Try up to 3 times in case of transient failures. --- Library/Homebrew/dev-cmd/audit.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ef22cbb7a4..757cc0df4b 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -569,9 +569,20 @@ class FormulaAuditor end return unless @online - status_code, = curl_output "--connect-timeout", "15", "--output", "/dev/null", "--range", "0-0", - "--write-out", "%{http_code}", homepage - return if status_code.start_with? "20" + + # The system Curl is too old and unreliable with HTTPS homepages on + # Yosemite and below. + return unless MacOS.version >= :el_capitan + + retries = 3 + retries.times do + status_code, = curl_output "--connect-timeout", "15", + "--output", "/dev/null", + "--range", "0-0", + "--write-out", "%{http_code}", + homepage + return if status_code.start_with? "20" + end problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end From e6fb3c3114ea842884a49c7f2ddfe1a9c4e3eee0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 25 Dec 2016 23:01:40 +0000 Subject: [PATCH 021/176] curl: make curl_args more configurable. Allow configuring whether output should be shown or the default the default user agent is used. --- Library/Homebrew/global.rb | 8 -------- Library/Homebrew/utils/curl.rb | 29 ++++++++++++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index eabc4c164c..9a2f0c794e 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -27,14 +27,6 @@ RUBY_BIN = RUBY_PATH.dirname HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze -HOMEBREW_CURL_ARGS = [ - "--fail", - "--progress-bar", - "--remote-time", - "--location", - "--user-agent", HOMEBREW_USER_AGENT_CURL -].freeze - require "tap_constants" module Homebrew diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 00c3a591cd..eab623c404 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -1,27 +1,38 @@ require "pathname" require "open3" -def curl_args(extra_args = []) +def curl_args(options = {}) curl = Pathname.new ENV["HOMEBREW_CURL"] curl = Pathname.new "/usr/bin/curl" unless curl.exist? raise "#{curl} is not executable" unless curl.exist? && curl.executable? - flags = HOMEBREW_CURL_ARGS - flags -= ["--progress-bar"] if ARGV.verbose? + args = [ + curl.to_s, + "--remote-time", + "--location", + ] - args = [curl.to_s] + flags + extra_args - args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] - args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] + unless options[:default_user_agent] + args << "--user-agent" << HOMEBREW_USER_AGENT_CURL + end + + unless options[:show_output] + args << "--progress-bar" unless ARGV.verbose? + args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"] + args << "--fail" + args << "--silent" if !$stdout.tty? || ENV["TRAVIS"] + end + + args += options[:extra_args] if options[:extra_args] args end def curl(*args) - safe_system(*curl_args(args)) + safe_system(*curl_args(extra_args: args)) end def curl_output(*args) - curl_args = curl_args(args) - curl_args -= ["--fail", "--silent"] + curl_args = curl_args(extra_args: args, show_output: true) Open3.popen3(*curl_args) do |_, stdout, stderr, wait_thread| [stdout.read, stderr.read, wait_thread.value] end From c3a2bf34a2bb11b9354f88bbbd83a817b6b879bf Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 18 Dec 2016 13:18:46 -0800 Subject: [PATCH 022/176] tap_migrations: support renaming to/from casks. Allow `tap_migrations` entries to have a `user/repo/formula` or `user/repo/cask` format for migration of formulae to/from casks. --- Library/Homebrew/cmd/update-report.rb | 23 ++++++++++++++++------- Library/Homebrew/formulary.rb | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 10b433dd25..caa1e01adf 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -421,18 +421,27 @@ class Reporter new_tap_name = tap.tap_migrations[name] next if new_tap_name.nil? # skip if not in tap_migrations list. + new_tap_user, new_tap_repo, new_tap_new_name = new_tap_name.split("/") + new_name = if new_tap_new_name + new_full_name = new_tap_new_name + new_tap_name = "#{new_tap_user}/#{new_tap_repo}" + new_tap_new_name + else + new_full_name = "#{new_tap_name}/#{name}" + name + end + # This means it is a Cask if report[:DC].include? full_name - next unless (HOMEBREW_PREFIX/"Caskroom"/name).exist? + next unless (HOMEBREW_PREFIX/"Caskroom"/new_name).exist? new_tap = Tap.fetch(new_tap_name) new_tap.install unless new_tap.installed? ohai "#{name} has been moved to Homebrew.", <<-EOS.undent To uninstall the cask run: brew cask uninstall --force #{name} EOS - new_full_name = "#{new_tap_name}/#{name}" - next if (HOMEBREW_CELLAR/name.split("/").last).directory? - ohai "Installing #{name}..." + next if (HOMEBREW_CELLAR/new_name.split("/").last).directory? + ohai "Installing #{new_name}..." system HOMEBREW_BREW_FILE, "install", new_full_name begin unless Formulary.factory(new_full_name).keg_only? @@ -456,13 +465,13 @@ class Reporter system HOMEBREW_BREW_FILE, "uninstall", "--force", name ohai "brew prune" system HOMEBREW_BREW_FILE, "prune" - ohai "brew cask install #{name}" - system HOMEBREW_BREW_FILE, "cask", "install", name + ohai "brew cask install #{new_name}" + system HOMEBREW_BREW_FILE, "cask", "install", new_name else ohai "#{name} has been moved to Homebrew-Cask.", <<-EOS.undent To uninstall the formula and install the cask run: brew uninstall --force #{name} - brew cask install #{name} + brew cask install #{new_name} EOS end else diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 40370cec3a..fadd894570 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -186,6 +186,8 @@ class Formulary name = new_name new_name = @tap.core_tap? ? name : "#{@tap}/#{name}" elsif (new_tap_name = @tap.tap_migrations[name]) + new_tap_user, new_tap_repo, = new_tap_name.split("/") + new_tap_name = "#{new_tap_user}/#{new_tap_repo}" new_tap = Tap.fetch new_tap_name new_tap.install unless new_tap.installed? new_tapped_name = "#{new_tap_name}/#{name}" From 0f8cb4ba277968fb24bf438468b37466075fd18a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 16 Dec 2016 19:39:12 +0100 Subject: [PATCH 023/176] Add option to disable methods on specific date. --- Library/Homebrew/test/utils_test.rb | 2 +- Library/Homebrew/utils.rb | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 146f57b495..d7c25683d7 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -216,7 +216,7 @@ class UtilTests < Homebrew::TestCase e = assert_raises(MethodDeprecatedError) do odeprecated("method", "replacement", caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], - die: true) + disable: true) end assert_match "method", e.message assert_match "replacement", e.message diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 4ad97c7d48..614d50eeae 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -11,6 +11,7 @@ require "utils/hash" require "utils/inreplace" require "utils/popen" require "utils/tty" +require "time" def ohai(title, *sput) title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? @@ -44,24 +45,32 @@ def odie(error) exit 1 end -def odeprecated(method, replacement = nil, options = {}) - verb = if options[:die] - "disabled" - else - "deprecated" - end - +def odeprecated(method, replacement = nil, disable: false, disable_on: nil, caller: send(:caller)) replacement_message = if replacement "Use #{replacement} instead." else "There is no replacement." end + unless disable_on.nil? + if disable_on > Time.now + will_be_disabled_message = " and will be disabled on #{disable_on.strftime("%Y-%m-%d")}" + else + disable = true + end + end + + verb = if disable + "disabled" + else + "deprecated#{will_be_disabled_message}" + end + # Try to show the most relevant location in message, i.e. (if applicable): # - Location in a formula. # - Location outside of 'compat/'. # - Location of caller of deprecated method (if all else fails). - backtrace = options.fetch(:caller, caller) + backtrace = caller tap_message = nil caller_message = backtrace.detect do |line| next unless line =~ %r{^#{Regexp.escape HOMEBREW_LIBRARY}/Taps/([^/]+/[^/]+)/} @@ -80,7 +89,7 @@ def odeprecated(method, replacement = nil, options = {}) #{caller_message}#{tap_message} EOS - if ARGV.homebrew_developer? || options[:die] || + if ARGV.homebrew_developer? || disable || Homebrew.raise_deprecation_exceptions? raise MethodDeprecatedError, message else @@ -89,7 +98,7 @@ def odeprecated(method, replacement = nil, options = {}) end def odisabled(method, replacement = nil, options = {}) - options = { die: true, caller: caller }.merge(options) + options = { disable: true, caller: caller }.merge(options) odeprecated(method, replacement, options) end From a1154e9fabcca4feca629f86e86d139768f0de48 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 16 Dec 2016 19:40:10 +0100 Subject: [PATCH 024/176] Deprecate `brew cask update`. --- Library/Homebrew/cask/lib/hbc/cli.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/update.rb | 20 -------------------- Library/Homebrew/compat/hbc/cli/update.rb | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 Library/Homebrew/cask/lib/hbc/cli/update.rb create mode 100644 Library/Homebrew/compat/hbc/cli/update.rb diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index c9625c7e20..f1057566ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -19,7 +19,7 @@ require "hbc/cli/reinstall" require "hbc/cli/search" require "hbc/cli/style" require "hbc/cli/uninstall" -require "hbc/cli/update" +require "compat/hbc/cli/update" require "hbc/cli/zap" require "hbc/cli/internal_use_base" diff --git a/Library/Homebrew/cask/lib/hbc/cli/update.rb b/Library/Homebrew/cask/lib/hbc/cli/update.rb deleted file mode 100644 index 86d02bb55b..0000000000 --- a/Library/Homebrew/cask/lib/hbc/cli/update.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Hbc - class CLI - class Update < Base - def self.run(*_ignored) - result = SystemCommand.run(HOMEBREW_BREW_FILE, - args: ["update"]) - # TODO: separating stderr/stdout is undesirable here. - # Hbc::SystemCommand should have an option for plain - # unbuffered output. - print result.stdout - $stderr.print result.stderr - exit result.exit_status - end - - def self.help - "a synonym for 'brew update'" - end - end - end -end diff --git a/Library/Homebrew/compat/hbc/cli/update.rb b/Library/Homebrew/compat/hbc/cli/update.rb new file mode 100644 index 0000000000..32186472bf --- /dev/null +++ b/Library/Homebrew/compat/hbc/cli/update.rb @@ -0,0 +1,17 @@ +module Hbc + class CLI + class Update < Base + def self.run(*_ignored) + odeprecated "`brew cask update`", "`brew update`", disable_on: Time.utc(2017, 7, 1) + result = SystemCommand.run(HOMEBREW_BREW_FILE, args: ["update"], + print_stderr: true, + print_stdout: true) + exit result.exit_status + end + + def self.help + "a synonym for 'brew update'" + end + end + end +end From 1745997a305d92b5fd26e2a557ca5f061684773a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 17 Dec 2016 17:11:31 +0100 Subject: [PATCH 025/176] Remove `brew cask update` from manpage. --- Library/Homebrew/manpages/brew-cask.1.md | 3 --- manpages/brew-cask.1 | 3 --- 2 files changed, 6 deletions(-) diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md index feab9f76e6..f0a70d4a76 100644 --- a/Library/Homebrew/manpages/brew-cask.1.md +++ b/Library/Homebrew/manpages/brew-cask.1.md @@ -104,9 +104,6 @@ names, and other aspects of this manual are still subject to change. Uninstall the given Cask. With `--force`, uninstall even if the Cask does not appear to be present. - * `update`: - For convenience. `brew cask update` is a synonym for `brew update`. - * `zap` [ ... ]: Unconditionally remove _all_ files associated with the given Cask. diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index af5335f796..9eaaf027a0 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -89,9 +89,6 @@ If \fItoken\fR is given, summarize the staged files associated with the given Ca \fBuninstall\fR or \fBrm\fR or \fBremove\fR [\-\-force] \fItoken\fR [ \fItoken\fR \.\.\. ]: Uninstall the given Cask\. With \fB\-\-force\fR, uninstall even if the Cask does not appear to be present\. . .IP "\(bu" 4 -\fBupdate\fR: For convenience\. \fBbrew cask update\fR is a synonym for \fBbrew update\fR\. -. -.IP "\(bu" 4 \fBzap\fR \fItoken\fR [ \fItoken\fR \.\.\. ]: Unconditionally remove \fIall\fR files associated with the given Cask\. . .IP From b11f38659a9799b3670655677216e0176de3a765 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 17 Dec 2016 17:13:04 +0100 Subject: [PATCH 026/176] Add warning to `brew cask help`. --- Library/Homebrew/compat/hbc/cli/update.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/compat/hbc/cli/update.rb b/Library/Homebrew/compat/hbc/cli/update.rb index 32186472bf..ab161ea652 100644 --- a/Library/Homebrew/compat/hbc/cli/update.rb +++ b/Library/Homebrew/compat/hbc/cli/update.rb @@ -10,7 +10,7 @@ module Hbc end def self.help - "a synonym for 'brew update'" + Formatter.warning("deprecated: use `brew update` instead") end end end From ddaf17396e4d0888ed2429821a94990800bd0814 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 30 Dec 2016 10:40:21 +0100 Subject: [PATCH 027/176] Remove `brew cask update` from ZSH completions. --- completions/zsh/_brew_cask | 1 - 1 file changed, 1 deletion(-) diff --git a/completions/zsh/_brew_cask b/completions/zsh/_brew_cask index bb64a2e32b..1e493fc2a6 100644 --- a/completions/zsh/_brew_cask +++ b/completions/zsh/_brew_cask @@ -43,7 +43,6 @@ __brew_cask_commands() { 'search:searches all known Casks' 'style:checks Cask style using RuboCop' 'uninstall:uninstalls the given Cask' - "update:a synonym for 'brew update'" 'zap:zaps all files associated with the given Cask' ) _describe -t commands "brew cask command" commands From e4497a2b4261c0d89de6c016aa5f8d89967a80d4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Dec 2016 14:31:05 +0000 Subject: [PATCH 028/176] cc: always filter flags on deps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This has been tested by `brew test-bot` since March and there’s been no issues so let’s turn it on by default. --- Library/Homebrew/shims/super/cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index b0ea705e8c..1400788ba3 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -206,10 +206,6 @@ class Cmd end def keep?(path) - # The logic in this method will eventually become the default, - # but is currently opt-in. - return keep_orig?(path) unless ENV["HOMEBREW_EXPERIMENTAL_FILTER_FLAGS_ON_DEPS"] - # Allow references to self if formula_prefix && path.start_with?("#{formula_prefix}/") true @@ -226,11 +222,6 @@ class Cmd end end - # The original less-smart version of keep_orig; will eventually be removed - def keep_orig?(path) - path.start_with?(prefix, cellar, tmpdir) || !path.start_with?("/opt/local", "/opt/boxen/homebrew", "/opt/X11", "/sw", "/usr/X11") - end - def cflags args = [] From 7f75b02133b10748ae9c26a0369f230782f974d5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Dec 2016 14:36:53 +0000 Subject: [PATCH 029/176] formula_installer: optional deps version check. Require `HOMEBREW_CHECK_RECURSIVE_VERSION_DEPENDENCIES` to be specified (which will be by `brew test-bot`) to avoid this being inflicted on end-users unnecessarily. --- Library/Homebrew/formula_installer.rb | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index c701aeb398..90e283c9b8 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -148,18 +148,24 @@ class FormulaInstaller recursive_deps = formula.recursive_dependencies recursive_formulae = recursive_deps.map(&:to_formula) - version_hash = {} - version_conflicts = Set.new - recursive_formulae.each do |f| - name = f.name - unversioned_name, = name.split("@") - version_hash[unversioned_name] ||= Set.new - version_hash[unversioned_name] << name - next if version_hash[unversioned_name].length < 2 - version_conflicts += version_hash[unversioned_name] - end - unless version_conflicts.empty? - raise CannotInstallFormulaError, "#{formula.full_name} contains conflicting version dependencies (#{version_conflicts.to_a.join " "}) so cannot be installed" + if ENV["HOMEBREW_CHECK_RECURSIVE_VERSION_DEPENDENCIES"] + version_hash = {} + version_conflicts = Set.new + recursive_formulae.each do |f| + name = f.name + unversioned_name, = name.split("@") + version_hash[unversioned_name] ||= Set.new + version_hash[unversioned_name] << name + next if version_hash[unversioned_name].length < 2 + version_conflicts += version_hash[unversioned_name] + end + unless version_conflicts.empty? + raise CannotInstallFormulaError, <<-EOS.undent + #{formula.full_name} contains conflicting version recursive dependencies: + #{version_conflicts.to_a.join ", "} + View these with `brew deps --tree #{formula.full_name}`. + EOS + end end unlinked_deps = recursive_formulae.select do |dep| From cea1d18f45608dda5d3185659b790df1c5d1b4e7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 30 Dec 2016 16:13:09 +0100 Subject: [PATCH 030/176] =?UTF-8?q?Do=20not=20require=20`compat/hbc/cli/up?= =?UTF-8?q?date`=20when=20`=E2=80=94no-compat`=20is=20specified.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/cask/lib/hbc/cli.rb | 2 +- Library/Homebrew/cask/lib/hbc/locations.rb | 2 ++ Library/Homebrew/compat/hbc.rb | 1 + Library/Homebrew/compat/hbc/cli/update.rb | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index f1057566ef..42c3982ba8 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -19,7 +19,6 @@ require "hbc/cli/reinstall" require "hbc/cli/search" require "hbc/cli/style" require "hbc/cli/uninstall" -require "compat/hbc/cli/update" require "hbc/cli/zap" require "hbc/cli/internal_use_base" @@ -77,6 +76,7 @@ module Hbc def self.command_classes @command_classes ||= constants.map(&method(:const_get)) .select { |sym| sym.respond_to?(:run) } + .sort_by(&:command_name) end def self.commands diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb index f28e84b2ef..292b45d0ca 100644 --- a/Library/Homebrew/cask/lib/hbc/locations.rb +++ b/Library/Homebrew/cask/lib/hbc/locations.rb @@ -1,3 +1,5 @@ +require "tap" + module Hbc module Locations def self.included(base) diff --git a/Library/Homebrew/compat/hbc.rb b/Library/Homebrew/compat/hbc.rb index a1d1414a59..179639953e 100644 --- a/Library/Homebrew/compat/hbc.rb +++ b/Library/Homebrew/compat/hbc.rb @@ -1 +1,2 @@ require "compat/hbc/cask_loader" +require "compat/hbc/cli/update" diff --git a/Library/Homebrew/compat/hbc/cli/update.rb b/Library/Homebrew/compat/hbc/cli/update.rb index ab161ea652..80f9612280 100644 --- a/Library/Homebrew/compat/hbc/cli/update.rb +++ b/Library/Homebrew/compat/hbc/cli/update.rb @@ -1,3 +1,5 @@ +require "cask/lib/hbc/cli/base" + module Hbc class CLI class Update < Base From c31f959ec1955999d4be4446914eaab2e715058a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 30 Dec 2016 16:46:27 +0100 Subject: [PATCH 031/176] Hide `update` from `brew cask help`. --- Library/Homebrew/compat/hbc/cli/update.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/compat/hbc/cli/update.rb b/Library/Homebrew/compat/hbc/cli/update.rb index 80f9612280..7820997cbb 100644 --- a/Library/Homebrew/compat/hbc/cli/update.rb +++ b/Library/Homebrew/compat/hbc/cli/update.rb @@ -11,8 +11,12 @@ module Hbc exit result.exit_status end + def self.visible + false + end + def self.help - Formatter.warning("deprecated: use `brew update` instead") + "a synonym for 'brew update'" end end end From a69997cab03988f381894b08d4b82d25014e8fed Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 16:15:04 +0000 Subject: [PATCH 032/176] tests: include homebrew version in receipt fixture --- Library/Homebrew/test/support/fixtures/receipt.json | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/test/support/fixtures/receipt.json b/Library/Homebrew/test/support/fixtures/receipt.json index b20626bbe2..a57d6d80d2 100644 --- a/Library/Homebrew/test/support/fixtures/receipt.json +++ b/Library/Homebrew/test/support/fixtures/receipt.json @@ -1,4 +1,5 @@ { + "homebrew_version": "1.1.6", "used_options": [ "--with-foo", "--without-bar" From bdbc19c614dd9f787c92ce3e0f62180d2238f177 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 16:16:28 +0000 Subject: [PATCH 033/176] tab: implement #reliable_runtime_dependencies? --- Library/Homebrew/tab.rb | 20 +++++++++++++ Library/Homebrew/test/tab_test.rb | 47 +++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 40626bad1e..332237a57f 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -242,6 +242,26 @@ class Tab < OpenStruct super || DevelopmentTools.default_compiler end + def homebrew_tag + homebrew_version.sub(/\-\d+\-g([a-f0-9]+)(?:\-dirty)?\Z/, "") + end + + def parsed_homebrew_version + return Version::NULL if homebrew_version.nil? + Version.new(homebrew_tag) + end + + # Whether there is reliable runtime dependency information in the receipt. + def reliable_runtime_dependencies? + return false if runtime_dependencies.nil? + + # Homebrew versions prior to 1.1.6 generated incorrect runtime dependency + # lists. + return false if parsed_homebrew_version < "1.1.6" + + true + end + def cxxstdlib # Older tabs won't have these values, so provide sensible defaults lib = stdlib.to_sym if stdlib diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 5d83b5907f..eecb111947 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -69,6 +69,53 @@ class TabTests < Homebrew::TestCase assert_predicate tab, :universal? end + def test_homebrew_tag + tab = Tab.new(homebrew_version: "1.2.3") + assert_equal "1.2.3", tab.homebrew_tag + + tab.homebrew_version = "1.2.4-567-g12789abdf" + assert_equal "1.2.4", tab.homebrew_tag + + tab.homebrew_version = "2.0.0-134-gabcdefabc-dirty" + assert_equal "2.0.0", tab.homebrew_tag + end + + def test_parsed_homebrew_version + tab = Tab.new + assert_same Version::NULL, tab.parsed_homebrew_version + + tab = Tab.new(homebrew_version: "1.2.3") + assert_equal "1.2.3", tab.parsed_homebrew_version + assert_kind_of Version, tab.parsed_homebrew_version + + tab = Tab.new(homebrew_version: "2.0.0-134-gabcdefabc-dirty") + assert_equal "2.0.0", tab.parsed_homebrew_version + assert_kind_of Version, tab.parsed_homebrew_version + end + + def test_reliable_runtime_dependencies? + tab = Tab.new + refute_predicate tab, :reliable_runtime_dependencies? + + tab.homebrew_version = "1.1.6" + refute_predicate tab, :reliable_runtime_dependencies? + + tab.runtime_dependencies = [] + assert_predicate tab, :reliable_runtime_dependencies? + + tab.homebrew_version = "1.1.5" + refute_predicate tab, :reliable_runtime_dependencies? + + tab.homebrew_version = "1.1.7" + assert_predicate tab, :reliable_runtime_dependencies? + + tab.homebrew_version = "1.1.10" + assert_predicate tab, :reliable_runtime_dependencies? + + tab.runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }] + assert_predicate tab, :reliable_runtime_dependencies? + end + def test_cxxstdlib assert_equal :clang, @tab.cxxstdlib.compiler assert_equal :libcxx, @tab.cxxstdlib.type From e5db7927c940e260fe10d4c88754b7b01384e427 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 16:16:53 +0000 Subject: [PATCH 034/176] keg: fall back for dependencies of buggy tabs Fixes #1554. --- Library/Homebrew/keg.rb | 8 +++++--- Library/Homebrew/test/keg_test.rb | 14 +++++++++++++- Library/Homebrew/test/uninstall_test.rb | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 756b272885..65ae3478c5 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -104,8 +104,10 @@ class Keg # so need them to be calculated now. # # This happens after the initial dependency check because it's sloooow. - remaining_formulae = Formula.installed.select do |f| - f.installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? } + remaining_formulae = Formula.installed.reject do |f| + f.installed_kegs.all? do |k| + Tab.for_keg(k).reliable_runtime_dependencies? + end end keg_names = kegs.map(&:name) @@ -360,7 +362,7 @@ class Keg tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) - next if tab.runtime_dependencies.nil? # no dependency information saved. + next unless tab.reliable_runtime_dependencies? tab.runtime_dependencies.any? do |dep| # Resolve formula rather than directly comparing names # in case of conflicts between formulae from different taps. diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 4fe7c6a3cf..034d102159 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -348,13 +348,18 @@ class InstalledDependantsTests < LinkTestCase tab.write end - def dependencies(deps) + def dependencies(deps, homebrew_version: "1.1.6") alter_tab do |tab| + tab.homebrew_version = homebrew_version tab.tabfile = @dependent.join("INSTALL_RECEIPT.json") tab.runtime_dependencies = deps end end + def unreliable_dependencies(deps) + dependencies(deps, homebrew_version: "1.1.5") + end + # Test with a keg whose formula isn't known. # This can happen if e.g. a formula is installed # from a file path or URL. @@ -406,4 +411,11 @@ class InstalledDependantsTests < LinkTestCase assert_equal [@dependent], @keg.installed_dependents assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) end + + def test_fallback_for_old_versions + unreliable_dependencies [{ "full_name" => "baz", "version" => "1.0" }] + Formula["bar"].class.depends_on "foo" + assert_empty @keg.installed_dependents + assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg]) + end end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 5c53988f24..e7849178b3 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -12,6 +12,7 @@ class UninstallTests < Homebrew::TestCase [@dependency, @dependent].each { |f| f.installed_prefix.mkpath } tab = Tab.empty + tab.homebrew_version = "1.1.6" tab.tabfile = @dependent.installed_prefix/Tab::FILENAME tab.runtime_dependencies = [ { "full_name" => "dependency", "version" => "1" }, From ea3a41e213f9462bc62099c607986356428dd55d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 17:44:18 +0000 Subject: [PATCH 035/176] uninstall: better example in dependency warning Previously, this only included a subset of all the kegs the user was trying to uninstall. With this change, all named formulae/kegs will be included in the example command. --- Library/Homebrew/cmd/uninstall.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index 505d4e4b2b..daae791a30 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -121,7 +121,7 @@ module Homebrew end def sample_command - "brew uninstall --ignore-dependencies #{list reqs.map(&:name)}" + "brew uninstall --ignore-dependencies #{list ARGV.named}" end def are_required_by_deps From bbf53ad4ab6afccb739828b5c7b5bcf905fd5160 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 17:45:37 +0000 Subject: [PATCH 036/176] uninstall: don't comma-seperate kegs in example The example command given in the dependency errors/warnings previously comma-seperated the kegs, which was incorrect syntax. This fixes that. --- Library/Homebrew/cmd/uninstall.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index daae791a30..c08b13dad9 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -121,7 +121,7 @@ module Homebrew end def sample_command - "brew uninstall --ignore-dependencies #{list ARGV.named}" + "brew uninstall --ignore-dependencies #{ARGV.named.join(" ")}" end def are_required_by_deps From ce454bd141ec4f97b2bfb9d71e0cea4389c78089 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 18:15:35 +0000 Subject: [PATCH 037/176] tab: parse full Homebrew version string It didn't occur to me that this would work, but it does! Magic. --- Library/Homebrew/tab.rb | 2 +- Library/Homebrew/test/tab_test.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 332237a57f..ced49b7b22 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -248,7 +248,7 @@ class Tab < OpenStruct def parsed_homebrew_version return Version::NULL if homebrew_version.nil? - Version.new(homebrew_tag) + Version.new(homebrew_version) end # Whether there is reliable runtime dependency information in the receipt. diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index eecb111947..bc0be85764 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -86,11 +86,18 @@ class TabTests < Homebrew::TestCase tab = Tab.new(homebrew_version: "1.2.3") assert_equal "1.2.3", tab.parsed_homebrew_version + assert tab.parsed_homebrew_version < "1.2.3-1-g12789abdf" assert_kind_of Version, tab.parsed_homebrew_version + tab.homebrew_version = "1.2.4-567-g12789abdf" + assert tab.parsed_homebrew_version > "1.2.4" + assert tab.parsed_homebrew_version > "1.2.4-566-g21789abdf" + assert tab.parsed_homebrew_version < "1.2.4-568-g01789abdf" + tab = Tab.new(homebrew_version: "2.0.0-134-gabcdefabc-dirty") - assert_equal "2.0.0", tab.parsed_homebrew_version - assert_kind_of Version, tab.parsed_homebrew_version + assert tab.parsed_homebrew_version > "2.0.0" + assert tab.parsed_homebrew_version > "2.0.0-133-g21789abdf" + assert tab.parsed_homebrew_version < "2.0.0-135-g01789abdf" end def test_reliable_runtime_dependencies? From c41d1d814868c9c7d58faf1bbcc88ed509d71229 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 18:16:49 +0000 Subject: [PATCH 038/176] tab: remove #homebrew_tag This method isn't used any more --- Library/Homebrew/tab.rb | 4 ---- Library/Homebrew/test/tab_test.rb | 11 ----------- 2 files changed, 15 deletions(-) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index ced49b7b22..97e3a05107 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -242,10 +242,6 @@ class Tab < OpenStruct super || DevelopmentTools.default_compiler end - def homebrew_tag - homebrew_version.sub(/\-\d+\-g([a-f0-9]+)(?:\-dirty)?\Z/, "") - end - def parsed_homebrew_version return Version::NULL if homebrew_version.nil? Version.new(homebrew_version) diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index bc0be85764..8ba36393bf 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -69,17 +69,6 @@ class TabTests < Homebrew::TestCase assert_predicate tab, :universal? end - def test_homebrew_tag - tab = Tab.new(homebrew_version: "1.2.3") - assert_equal "1.2.3", tab.homebrew_tag - - tab.homebrew_version = "1.2.4-567-g12789abdf" - assert_equal "1.2.4", tab.homebrew_tag - - tab.homebrew_version = "2.0.0-134-gabcdefabc-dirty" - assert_equal "2.0.0", tab.homebrew_tag - end - def test_parsed_homebrew_version tab = Tab.new assert_same Version::NULL, tab.parsed_homebrew_version From 4322c1c562d2c5695a43e96e88db44e57083cf50 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 18:19:26 +0000 Subject: [PATCH 039/176] tests: explain Homebrew version checking in tabs --- Library/Homebrew/test/keg_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 034d102159..16bfe461bb 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -348,6 +348,8 @@ class InstalledDependantsTests < LinkTestCase tab.write end + # 1.1.6 is the earliest version of Homebrew that generates correct runtime + # dependency lists in tabs. def dependencies(deps, homebrew_version: "1.1.6") alter_tab do |tab| tab.homebrew_version = homebrew_version @@ -357,6 +359,8 @@ class InstalledDependantsTests < LinkTestCase end def unreliable_dependencies(deps) + # 1.1.5 is (hopefully!) the last version of Homebrew that generates + # incorrect runtime dependency lists in tabs. dependencies(deps, homebrew_version: "1.1.5") end From 01e1f7d49e91b6f02037997ffb465b37d2426b80 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 17:41:57 +0000 Subject: [PATCH 040/176] keg: fix fallback dependencies with multiple kegs Fixes #1524. --- Library/Homebrew/keg.rb | 8 +++++++- Library/Homebrew/test/keg_test.rb | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 756b272885..43e2cbc4f6 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -105,7 +105,13 @@ class Keg # # This happens after the initial dependency check because it's sloooow. remaining_formulae = Formula.installed.select do |f| - f.installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? } + installed_kegs = f.installed_kegs + + # All installed kegs are going to be removed anyway, + # so it doesn't matter what they depend on. + next false if (installed_kegs - kegs).empty? + + installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? } end keg_names = kegs.map(&:name) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 4fe7c6a3cf..14cdc4304a 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -382,6 +382,13 @@ class InstalledDependantsTests < LinkTestCase assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg]) end + def test_uninstalling_dependent_and_dependency + dependencies nil + Formula["bar"].class.depends_on "foo" + assert_empty @keg.installed_dependents + assert_nil Keg.find_some_installed_dependents([@keg, @dependent]) + end + def test_empty_dependencies_in_tab dependencies [] assert_empty @keg.installed_dependents From 35ae78f43d45369f86b8c56c04ccca1119fdb1d1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Dec 2016 18:43:50 +0000 Subject: [PATCH 041/176] formula_versions: handle uncommitted formulae. Otherwise an uncommitted formula can trigger an invalid `brew audit` result. Fixes #1731. --- Library/Homebrew/formula_versions.rb | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 28c2a3be85..34b766fde1 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -15,6 +15,7 @@ class FormulaVersions @repository = formula.tap.path @entry_name = @path.relative_path_from(repository).to_s @max_depth = options[:max_depth] + @current_formula = formula end def rev_list(branch) @@ -64,25 +65,33 @@ class FormulaVersions attributes.each do |attribute| attributes_map[attribute] ||= {} + # Set the attributes for the current formula in case it's not been + # committed yet. + set_attribute_map(attributes_map[attribute], @current_formula, attribute) end rev_list(branch) do |rev| formula_at_revision(rev) do |f| attributes.each do |attribute| - map = attributes_map[attribute] - if f.stable - map[:stable] ||= {} - map[:stable][f.stable.version] ||= [] - map[:stable][f.stable.version] << f.send(attribute) - end - next unless f.devel - map[:devel] ||= {} - map[:devel][f.devel.version] ||= [] - map[:devel][f.devel.version] << f.send(attribute) + set_attribute_map(attributes_map[attribute], f, attribute) end end end attributes_map end + + private + + def set_attribute_map(map, f, attribute) + if f.stable + map[:stable] ||= {} + map[:stable][f.stable.version] ||= [] + map[:stable][f.stable.version] << f.send(attribute) + end + return unless f.devel + map[:devel] ||= {} + map[:devel][f.devel.version] ||= [] + map[:devel][f.devel.version] << f.send(attribute) + end end From b3c6334d3cde6d653427ae29892e3a14af9c5bd9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Dec 2016 20:17:34 +0000 Subject: [PATCH 042/176] audit: use new curl_args form. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will use Curl’s default user agent to reduce homepage errors and provides a function that can be used for other audits to perform similar tests on URLs. --- Library/Homebrew/dev-cmd/audit.rb | 42 +++++++++++++------ Library/Homebrew/development_tools.rb | 4 ++ .../extend/os/mac/development_tools.rb | 5 +++ 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 757cc0df4b..74ba987f63 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -169,6 +169,33 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end + def url_status_code(url, range: false) + # The system Curl is too old and unreliable with HTTPS homepages on + # Yosemite and below. + return "200" unless DevelopmentTools.curl_handles_most_https_homepages? + + extra_args = [ + "--connect-timeout", "15", + "--output", "/dev/null", + "--write-out", "%{http_code}" + ] + extra_args << "--range" << "0-0" if range + extra_args << url + + args = curl_args( + extra_args: extra_args, + show_output: true, + default_user_agent: true + ) + retries = 3 + status_code = nil + retries.times do + status_code = Open3.popen3(*args) { |_, stdout, _, _| stdout.read } + break if status_code.start_with? "20" + end + status_code + end + def audit_style return unless @style_offenses display_cop_names = ARGV.include?("--display-cop-names") @@ -570,19 +597,8 @@ class FormulaAuditor return unless @online - # The system Curl is too old and unreliable with HTTPS homepages on - # Yosemite and below. - return unless MacOS.version >= :el_capitan - - retries = 3 - retries.times do - status_code, = curl_output "--connect-timeout", "15", - "--output", "/dev/null", - "--range", "0-0", - "--write-out", "%{http_code}", - homepage - return if status_code.start_with? "20" - end + status_code = url_status_code(homepage) + return if status_code.start_with? "20" problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index bee2b86dea..0a2f127296 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -119,6 +119,10 @@ class DevelopmentTools @clang_version = @clang_build_version = nil @non_apple_gcc_version = {} end + + def curl_handles_most_https_homepages? + true + end end end diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index 381b26e661..8c0c48a516 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -76,5 +76,10 @@ class DevelopmentTools end end end + + def curl_handles_most_https_homepages? + # The system Curl is too old for some modern HTTPS homepages on Yosemite. + MacOS.version >= :el_capitan + end end end From e50102d91e5fc13fd59589967bb97bb6159bbad0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Dec 2016 20:20:13 +0000 Subject: [PATCH 043/176] ENV: deprecate old methods. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These should have been deprecated long ago but we didn’t really have the necessary framework to do so. --- Library/Homebrew/compat.rb | 3 ++ Library/Homebrew/compat/ENV/shared.rb | 6 +++ Library/Homebrew/compat/ENV/std.rb | 27 +++++++++++ Library/Homebrew/compat/ENV/super.rb | 47 +++++++++++++++++++ Library/Homebrew/compat/macos.rb | 16 +++---- Library/Homebrew/compilers.rb | 10 ++-- Library/Homebrew/development_tools.rb | 18 +++---- Library/Homebrew/extend/ENV/std.rb | 15 +----- Library/Homebrew/extend/ENV/super.rb | 21 +-------- .../extend/os/mac/development_tools.rb | 6 +-- .../extend/os/mac/extend/ENV/super.rb | 7 +-- Library/Homebrew/os/mac.rb | 14 +++--- Library/Homebrew/system_config.rb | 12 ++--- Library/Homebrew/test/ENV_test.rb | 2 +- Library/Homebrew/test/stdlib_test.rb | 7 +-- 15 files changed, 128 insertions(+), 83 deletions(-) create mode 100644 Library/Homebrew/compat/ENV/shared.rb create mode 100644 Library/Homebrew/compat/ENV/std.rb create mode 100644 Library/Homebrew/compat/ENV/super.rb diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb index 5d78c715f1..92b687725a 100644 --- a/Library/Homebrew/compat.rb +++ b/Library/Homebrew/compat.rb @@ -22,3 +22,6 @@ require "compat/json" require "compat/ARGV" require "compat/build_options" require "compat/tab" +require "compat/ENV/shared" +require "compat/ENV/std" +require "compat/ENV/super" diff --git a/Library/Homebrew/compat/ENV/shared.rb b/Library/Homebrew/compat/ENV/shared.rb new file mode 100644 index 0000000000..200e7b132b --- /dev/null +++ b/Library/Homebrew/compat/ENV/shared.rb @@ -0,0 +1,6 @@ +module SharedEnvExtension + def j1 + odeprecated "ENV.j1", "ENV.deparallelize" + deparallelize + end +end diff --git a/Library/Homebrew/compat/ENV/std.rb b/Library/Homebrew/compat/ENV/std.rb new file mode 100644 index 0000000000..26dabe440d --- /dev/null +++ b/Library/Homebrew/compat/ENV/std.rb @@ -0,0 +1,27 @@ +module Stdenv + def fast + odeprecated "ENV.fast" + end + + def O4 + odeprecated "ENV.O4" + end + + def Og + odeprecated "ENV.Og" + end + + def gcc_4_0_1 + odeprecated "ENV.gcc_4_0_1", "ENV.gcc_4_0" + gcc_4_0 + end + + def gcc + odeprecated "ENV.gcc", "ENV.gcc_4_2" + gcc_4_2 + end + + def libpng + odeprecated "ENV.libpng", "ENV.x11" + end +end diff --git a/Library/Homebrew/compat/ENV/super.rb b/Library/Homebrew/compat/ENV/super.rb new file mode 100644 index 0000000000..2020ad752c --- /dev/null +++ b/Library/Homebrew/compat/ENV/super.rb @@ -0,0 +1,47 @@ +module Superenv + def fast + odeprecated "ENV.fast" + end + + def O4 + odeprecated "ENV.O4" + end + + def Og + odeprecated "ENV.Og" + end + + def gcc_4_0_1 + odeprecated "ENV.gcc_4_0_1", "ENV.gcc_4_0" + gcc_4_0 + end + + def gcc + odeprecated "ENV.gcc", "ENV.gcc_4_2" + gcc_4_2 + end + + def libxml2 + odeprecated "ENV.libxml2" + end + + def minimal_optimization + odeprecated "ENV.minimal_optimization" + end + + def no_optimization + odeprecated "ENV.no_optimization" + end + + def enable_warnings + odeprecated "ENV.enable_warnings" + end + + def macosxsdk + odeprecated "ENV.macosxsdk" + end + + def remove_macosxsdk + odeprecated "ENV.remove_macosxsdk" + end +end diff --git a/Library/Homebrew/compat/macos.rb b/Library/Homebrew/compat/macos.rb index 17f4670cc7..3acd2f9ef7 100644 --- a/Library/Homebrew/compat/macos.rb +++ b/Library/Homebrew/compat/macos.rb @@ -100,23 +100,23 @@ module OS end def gcc_40_build_version - odeprecated "MacOS.gcc_40_build_version", "DevelopmentTools.gcc_40_build_version" - DevelopmentTools.gcc_40_build_version + odeprecated "MacOS.gcc_40_build_version", "DevelopmentTools.gcc_4_0_build_version" + DevelopmentTools.gcc_4_0_build_version end def gcc_4_0_build_version - odeprecated "MacOS.gcc_4_0_build_version", "DevelopmentTools.gcc_40_build_version" - DevelopmentTools.gcc_40_build_version + odeprecated "MacOS.gcc_4_0_build_version", "DevelopmentTools.gcc_4_0_build_version" + DevelopmentTools.gcc_4_0_build_version end def gcc_42_build_version - odeprecated "MacOS.gcc_42_build_version", "DevelopmentTools.gcc_42_build_version" - DevelopmentTools.gcc_42_build_version + odeprecated "MacOS.gcc_42_build_version", "DevelopmentTools.gcc_4_2_build_version" + DevelopmentTools.gcc_4_2_build_version end def gcc_build_version - odeprecated "MacOS.gcc_build_version", "DevelopmentTools.gcc_42_build_version" - DevelopmentTools.gcc_42_build_version + odeprecated "MacOS.gcc_build_version", "DevelopmentTools.gcc_4_2_build_version" + DevelopmentTools.gcc_4_2_build_version end def llvm_build_version diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index 9ee847db0e..628e71e9b8 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -4,7 +4,7 @@ module CompilerConstants GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/ COMPILER_SYMBOL_MAP = { "gcc-4.0" => :gcc_4_0, - "gcc-4.2" => :gcc, + "gcc-4.2" => :gcc_4_2, "clang" => :clang, "llvm_clang" => :llvm_clang, }.freeze @@ -68,7 +68,7 @@ class CompilerFailure COLLECTIONS = { cxx11: [ create(:gcc_4_0), - create(:gcc), + create(:gcc_4_2), create(:clang) { build 425 }, create(gcc: "4.3"), create(gcc: "4.4"), @@ -87,9 +87,9 @@ class CompilerSelector Compiler = Struct.new(:name, :version) COMPILER_PRIORITY = { - clang: [:clang, :gcc, :gnu, :gcc_4_0, :llvm_clang], - gcc: [:gcc, :gnu, :clang, :gcc_4_0], - gcc_4_0: [:gcc_4_0, :gcc, :gnu, :clang], + clang: [:clang, :gcc_4_2, :gnu, :gcc_4_0, :llvm_clang], + gcc_4_2: [:gcc_4_2, :gnu, :clang, :gcc_4_0], + gcc_4_0: [:gcc_4_0, :gcc_4_2, :gnu, :clang], }.freeze def self.select_for(formula, compilers = self.compilers) diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index ea7f5837d0..10020a2365 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -34,15 +34,11 @@ class DevelopmentTools end def default_compiler - if default_cc =~ /^gcc/ - :gcc - else - :clang - end + :clang end - def gcc_40_build_version - @gcc_40_build_version ||= begin + def gcc_4_0_build_version + @gcc_4_0_build_version ||= begin if (path = locate("gcc-4.0")) && build_version = `#{path} --version 2>/dev/null`[/build (\d{4,})/, 1] Version.new build_version @@ -51,10 +47,9 @@ class DevelopmentTools end end end - alias gcc_4_0_build_version gcc_40_build_version - def gcc_42_build_version - @gcc_42_build_version ||= begin + def gcc_4_2_build_version + @gcc_4_2_build_version ||= begin gcc = locate("gcc-4.2") || HOMEBREW_PREFIX.join("opt/apple-gcc42/bin/gcc-4.2") if gcc.exist? && !gcc.realpath.basename.to_s.start_with?("llvm")&& build_version = `#{gcc} --version 2>/dev/null`[/build (\d{4,})/, 1] @@ -64,7 +59,6 @@ class DevelopmentTools end end end - alias gcc_build_version gcc_42_build_version def clang_version @clang_version ||= begin @@ -115,7 +109,7 @@ class DevelopmentTools end def clear_version_cache - @gcc_40_build_version = @gcc_42_build_version = nil + @gcc_4_0_build_version = @gcc_4_2_build_version = nil @clang_version = @clang_build_version = nil @non_apple_gcc_version = {} end diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 14f9b81b8e..403ea19783 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -82,10 +82,6 @@ module Stdenv old end - alias j1 deparallelize - - # These methods are no-ops for compatibility. - %w[fast O4 Og].each { |opt| define_method(opt) {} } %w[O3 O2 O1 O0 Os].each do |opt| define_method opt do @@ -110,13 +106,11 @@ module Stdenv super set_cpu_cflags "-march=nocona -mssse3" end - alias gcc_4_0_1 gcc_4_0 - def gcc + def gcc_4_2 super set_cpu_cflags end - alias gcc_4_2 gcc GNU_GCC_VERSIONS.each do |n| define_method(:"gcc-#{n}") do @@ -144,13 +138,6 @@ module Stdenv end alias generic_no_optimization no_optimization - def libxml2 - end - - def x11 - end - alias libpng x11 - # we've seen some packages fail to build when warnings are disabled! def enable_warnings remove_from_cflags "-w" diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index a75cba406d..7503e88768 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -16,9 +16,7 @@ module Superenv # @private attr_accessor :keg_only_deps, :deps - attr_accessor :x11 - alias x11? x11 def self.extended(base) base.keg_only_deps = [] @@ -263,7 +261,6 @@ module Superenv old end - alias j1 deparallelize def make_jobs self["MAKEFLAGS"] =~ /-\w*j(\d+)/ @@ -329,23 +326,9 @@ module Superenv def set_x11_env_if_installed end + # This method does nothing in superenv since there's no custom CFLAGS API # @private - def noop(*_args); end - - # These methods are no longer necessary under superenv, but are needed to - # maintain an interface compatible with stdenv. - alias fast noop - alias O4 noop - alias Og noop - alias libxml2 noop - alias set_cpu_flags noop - - # These methods provide functionality that has not yet been ported to - # superenv. - alias gcc_4_0_1 noop - alias minimal_optimization noop - alias no_optimization noop - alias enable_warnings noop + def set_cpu_flags; end end class Array diff --git a/Library/Homebrew/extend/os/mac/development_tools.rb b/Library/Homebrew/extend/os/mac/development_tools.rb index 7c97b9d69e..b80d70d5bf 100644 --- a/Library/Homebrew/extend/os/mac/development_tools.rb +++ b/Library/Homebrew/extend/os/mac/development_tools.rb @@ -64,15 +64,15 @@ class DevelopmentTools case default_cc # if GCC 4.2 is installed, e.g. via Tigerbrew, prefer it # over the system's GCC 4.0 - when /^gcc-4\.0/ then gcc_42_build_version ? :gcc : :gcc_4_0 - when /^gcc/ then :gcc + when /^gcc-4\.0/ then gcc_4_2_build_version ? :gcc_4_2 : :gcc_4_0 + when /^gcc/ then :gcc_4_2 when "clang" then :clang else # guess :( if MacOS::Xcode.version >= "4.3" :clang else - :gcc + :gcc_4_2 end end end diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index 5f4a3e4aa8..f97a2dbbbf 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -1,4 +1,6 @@ module Superenv + alias x11? x11 + # @private def self.bin return unless DevelopmentTools.installed? @@ -120,9 +122,4 @@ module Superenv def no_weak_imports append "HOMEBREW_CCCFG", "w" if no_weak_imports_support? end - - # These methods are no longer necessary under superenv, but are needed to - # maintain an interface compatible with stdenv. - alias macosxsdk noop - alias remove_macosxsdk noop end diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index b2f0515a0a..9468a6c1e7 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -152,13 +152,13 @@ module OS end STANDARD_COMPILERS = { - "2.0" => { gcc_40_build: 4061 }, - "2.5" => { gcc_40_build: 5370 }, - "3.1.4" => { gcc_40_build: 5493, gcc_42_build: 5577 }, - "3.2.6" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "1.7", clang_build: 77 }, - "4.0" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, - "4.0.1" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, - "4.0.2" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, + "2.0" => { gcc_4_0_build: 4061 }, + "2.5" => { gcc_4_0_build: 5370 }, + "3.1.4" => { gcc_4_0_build: 5493, gcc_4_2_build: 5577 }, + "3.2.6" => { gcc_4_0_build: 5494, gcc_4_2_build: 5666, clang: "1.7", clang_build: 77 }, + "4.0" => { gcc_4_0_build: 5494, gcc_4_2_build: 5666, clang: "2.0", clang_build: 137 }, + "4.0.1" => { gcc_4_0_build: 5494, gcc_4_2_build: 5666, clang: "2.0", clang_build: 137 }, + "4.0.2" => { gcc_4_0_build: 5494, gcc_4_2_build: 5666, clang: "2.0", clang_build: 137 }, "4.2" => { clang: "3.0", clang_build: 211 }, "4.3" => { clang: "3.1", clang_build: 318 }, "4.3.1" => { clang: "3.1", clang_build: 318 }, diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index 9c7a8d1b01..043f609193 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -6,12 +6,12 @@ require "development_tools" class SystemConfig class << self - def gcc_42 - @gcc_42 ||= DevelopmentTools.gcc_42_build_version if DevelopmentTools.installed? + def gcc_4_2 + @gcc_4_2 ||= DevelopmentTools.gcc_4_2_build_version if DevelopmentTools.installed? end - def gcc_40 - @gcc_40 ||= DevelopmentTools.gcc_40_build_version if DevelopmentTools.installed? + def gcc_4_0 + @gcc_4_0 ||= DevelopmentTools.gcc_4_0_build_version if DevelopmentTools.installed? end def clang @@ -143,8 +143,8 @@ class SystemConfig f.puts "HOMEBREW_BOTTLE_DOMAIN: #{BottleSpecification::DEFAULT_DOMAIN}" f.puts hardware if hardware f.puts "Homebrew Ruby: #{describe_homebrew_ruby}" - f.puts "GCC-4.0: build #{gcc_40}" unless gcc_40.null? - f.puts "GCC-4.2: build #{gcc_42}" unless gcc_42.null? + f.puts "GCC-4.0: build #{gcc_4_0}" unless gcc_4_0.null? + f.puts "GCC-4.2: build #{gcc_4_2}" unless gcc_4_2.null? f.puts "Clang: #{clang.null? ? "N/A" : "#{clang} build #{clang_build}"}" f.puts "Git: #{describe_git}" f.puts "Perl: #{describe_perl}" diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb index 6c0e68a9e3..dd60250842 100644 --- a/Library/Homebrew/test/ENV_test.rb +++ b/Library/Homebrew/test/ENV_test.rb @@ -133,7 +133,7 @@ module SharedEnvTests end def test_switching_compilers_updates_compiler - [:clang, :gcc, :gcc_4_0].each do |compiler| + [:clang, :gcc_4_2, :gcc_4_0].each do |compiler| @env.send(compiler) assert_equal compiler, @env.compiler end diff --git a/Library/Homebrew/test/stdlib_test.rb b/Library/Homebrew/test/stdlib_test.rb index ee53e7c8cd..3babfd58af 100644 --- a/Library/Homebrew/test/stdlib_test.rb +++ b/Library/Homebrew/test/stdlib_test.rb @@ -6,7 +6,8 @@ class CxxStdlibTests < Homebrew::TestCase def setup @clang = CxxStdlib.create(:libstdcxx, :clang) @gcc = CxxStdlib.create(:libstdcxx, :gcc) - @gcc4 = CxxStdlib.create(:libstdcxx, :gcc_4_0) + @gcc40 = CxxStdlib.create(:libstdcxx, :gcc_4_0) + @gcc42 = CxxStdlib.create(:libstdcxx, :gcc_4_2) @gcc48 = CxxStdlib.create(:libstdcxx, "gcc-4.8") @gcc49 = CxxStdlib.create(:libstdcxx, "gcc-4.9") @lcxx = CxxStdlib.create(:libcxx, :clang) @@ -15,7 +16,7 @@ class CxxStdlibTests < Homebrew::TestCase def test_apple_libstdcxx_intercompatibility assert @clang.compatible_with?(@gcc) - assert @clang.compatible_with?(@gcc4) + assert @clang.compatible_with?(@gcc42) end def test_compatibility_same_compilers_and_type @@ -42,7 +43,7 @@ class CxxStdlibTests < Homebrew::TestCase def test_apple_compiler_reporting assert_predicate @clang, :apple_compiler? assert_predicate @gcc, :apple_compiler? - assert_predicate @gcc4, :apple_compiler? + assert_predicate @gcc42, :apple_compiler? refute_predicate @gcc48, :apple_compiler? end From d998a3fcce579b087dee76c5aeb9956713e81b62 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 20:34:14 +0000 Subject: [PATCH 044/176] tab: remove #reliable_runtime_dependencies? See https://github.com/Homebrew/brew/pull/1750#discussion_r94243825 for discussion. Removes Tab#reliable_runtime_dependencies? in favour of returning nil from Tab#runtime_dependencies if the list is unreliable. Because Homebrew 1.1.6 hasn't been tagged yet, tabs created in tests aren't created with a homebrew_version that marks the runtime_dependencies in the Tab as reliable, so there are some tests that fail. To work around this, I've had to add a line to some tests that explicitly overrides the homebrew_version in the Tab. This is really ugly though, so they should be removed as soon as possible after 1.1.6 is released. --- Library/Homebrew/keg.rb | 8 +++----- Library/Homebrew/tab.rb | 9 ++------- Library/Homebrew/test/tab_test.rb | 25 +++++++++++++++++-------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 65ae3478c5..4a02dc8e04 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -104,10 +104,8 @@ class Keg # so need them to be calculated now. # # This happens after the initial dependency check because it's sloooow. - remaining_formulae = Formula.installed.reject do |f| - f.installed_kegs.all? do |k| - Tab.for_keg(k).reliable_runtime_dependencies? - end + remaining_formulae = Formula.installed.select do |f| + f.installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? } end keg_names = kegs.map(&:name) @@ -362,7 +360,7 @@ class Keg tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) - next unless tab.reliable_runtime_dependencies? + next if tab.runtime_dependencies.nil? tab.runtime_dependencies.any? do |dep| # Resolve formula rather than directly comparing names # in case of conflicts between formulae from different taps. diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 97e3a05107..669846dfc9 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -247,15 +247,10 @@ class Tab < OpenStruct Version.new(homebrew_version) end - # Whether there is reliable runtime dependency information in the receipt. - def reliable_runtime_dependencies? - return false if runtime_dependencies.nil? - + def runtime_dependencies # Homebrew versions prior to 1.1.6 generated incorrect runtime dependency # lists. - return false if parsed_homebrew_version < "1.1.6" - - true + super unless parsed_homebrew_version < "1.1.6" end def cxxstdlib diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 8ba36393bf..526e1f79e3 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -32,6 +32,11 @@ class TabTests < Homebrew::TestCase def test_defaults tab = Tab.empty + + # FIXME: remove this line after Homebrew 1.1.6 is released. + # See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622 + tab.homebrew_version = "1.1.6" + assert_empty tab.unused_options assert_empty tab.used_options assert_nil tab.changed_files @@ -89,27 +94,27 @@ class TabTests < Homebrew::TestCase assert tab.parsed_homebrew_version < "2.0.0-135-g01789abdf" end - def test_reliable_runtime_dependencies? + def test_runtime_dependencies tab = Tab.new - refute_predicate tab, :reliable_runtime_dependencies? + assert_nil tab.runtime_dependencies tab.homebrew_version = "1.1.6" - refute_predicate tab, :reliable_runtime_dependencies? + assert_nil tab.runtime_dependencies tab.runtime_dependencies = [] - assert_predicate tab, :reliable_runtime_dependencies? + refute_nil tab.runtime_dependencies tab.homebrew_version = "1.1.5" - refute_predicate tab, :reliable_runtime_dependencies? + assert_nil tab.runtime_dependencies tab.homebrew_version = "1.1.7" - assert_predicate tab, :reliable_runtime_dependencies? + refute_nil tab.runtime_dependencies tab.homebrew_version = "1.1.10" - assert_predicate tab, :reliable_runtime_dependencies? + refute_nil tab.runtime_dependencies tab.runtime_dependencies = [{ "full_name" => "foo", "version" => "1.0" }] - assert_predicate tab, :reliable_runtime_dependencies? + refute_nil tab.runtime_dependencies end def test_cxxstdlib @@ -194,6 +199,10 @@ class TabTests < Homebrew::TestCase stdlib = :libcxx tab = Tab.create(f, compiler, stdlib) + # FIXME: remove this line after Homebrew 1.1.6 is released. + # See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622 + tab.homebrew_version = "1.1.6" + runtime_dependencies = [ { "full_name" => "bar", "version" => "2.0" }, { "full_name" => "user/repo/from_tap", "version" => "1.0" }, From b0a38c06bfce65292dafd8e43e04d9630d236218 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Dec 2016 22:16:18 +0000 Subject: [PATCH 045/176] docs: improve Keg.find_some_installed_dependencies See https://github.com/Homebrew/brew/pull/1752#discussion_r94257147 --- Library/Homebrew/keg.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 43e2cbc4f6..bdb618ba2f 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -87,11 +87,23 @@ class Keg mime-info pixmaps sounds postgresql ].freeze - # Will return some kegs, and some dependencies, if they're present. + # Given an array of kegs, this method will try to find some other kegs + # that depend on them. + # + # If it does, it returns: + # - some kegs in the passed array that have installed dependents + # - some installed dependents of those kegs. + # + # If it doesn't, it returns nil. + # + # Note that nil will be returned if the only installed dependents + # in the passed kegs are other kegs in the array. + # # For efficiency, we don't bother trying to get complete data. def self.find_some_installed_dependents(kegs) # First, check in the tabs of installed Formulae. kegs.each do |keg| + # Don't include dependencies of kegs that were in the given array. dependents = keg.installed_dependents - kegs dependents.map! { |d| "#{d.name} #{d.version}" } return [keg], dependents if dependents.any? @@ -107,8 +119,7 @@ class Keg remaining_formulae = Formula.installed.select do |f| installed_kegs = f.installed_kegs - # All installed kegs are going to be removed anyway, - # so it doesn't matter what they depend on. + # Don't include dependencies of kegs that were in the given array. next false if (installed_kegs - kegs).empty? installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? } From 49310667b4e6327d8276752a74fe480c1d7fb135 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 15 Nov 2016 21:56:42 +0000 Subject: [PATCH 046/176] Revert "uninstall: remove nil requireds/dependents" This reverts commit d7e72899e6f24dca5e02a734d5a4e64e39fc680e. --- Library/Homebrew/cmd/uninstall.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index c08b13dad9..5d02ebd1e8 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -102,8 +102,8 @@ module Homebrew attr_reader :reqs, :deps def initialize(requireds, dependents) - @reqs = requireds.compact - @deps = dependents.compact + @reqs = requireds + @deps = dependents end protected From fb920668c880778d9f539d9371ef12283e117903 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 31 Dec 2016 13:03:08 +0000 Subject: [PATCH 047/176] keg: don't return nil dependencies This is a proper fix to the problem addressed by #1510. The problem arises when f_kegs is nil, which can happen if the name and tap used to install a keg don't match the name and tap currently associated with its formula (i.e. if it's been renamed or moved). --- Library/Homebrew/keg.rb | 2 +- Library/Homebrew/test/keg_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 756b272885..b5e6bd81d1 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -119,7 +119,7 @@ class Keg next unless f_kegs f_kegs.sort_by(&:version).last - end + end.compact next unless required_kegs.any? diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 4fe7c6a3cf..adb30164e2 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -369,6 +369,19 @@ class InstalledDependantsTests < LinkTestCase assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) end + def test_a_dependency_with_no_tap_in_tab + @tap_dep = setup_test_keg("baz", "1.0") + + alter_tab(@keg) { |t| t.source["tap"] = nil } + + dependencies nil + Formula["bar"].class.depends_on "foo" + Formula["bar"].class.depends_on "baz" + + result = Keg.find_some_installed_dependents([@keg, @tap_dep]) + assert_equal [[@tap_dep], ["bar"]], result + end + def test_no_dependencies_anywhere dependencies nil assert_empty @keg.installed_dependents From a571965df9d5dc84d1a32630a111768fbac71b3b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 31 Dec 2016 16:38:05 +0000 Subject: [PATCH 048/176] formula: make prefix usually return opt_prefix. Return `opt_prefix` if it exists and `prefix` is not called from within the same formula's `install` or `post_install` methods. Otherwise, fall back to the existing functionality. This avoids the need to use `opt_prefix` etc. everywhere and generally means we don't expose an implementation detail (i.e. the full Cellar path) to dependents that have a habit of hard-coding it. --- Library/Homebrew/cmd/--prefix.rb | 2 +- Library/Homebrew/formula.rb | 21 ++++++++++++++++++--- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/keg.rb | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/--prefix.rb b/Library/Homebrew/cmd/--prefix.rb index c59830833b..f6e7d2ee29 100644 --- a/Library/Homebrew/cmd/--prefix.rb +++ b/Library/Homebrew/cmd/--prefix.rb @@ -11,7 +11,7 @@ module Homebrew if ARGV.named.empty? puts HOMEBREW_PREFIX else - puts ARGV.resolved_formulae.map { |f| f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix } + puts ARGV.resolved_formulae.map(&:installed_prefix) end end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bc1dbd9705..2d0a9c25e1 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -198,6 +198,7 @@ class Formula @build = active_spec.build @pin = FormulaPin.new(self) @follow_installed_alias = true + @versioned_prefix = false end # @private @@ -548,9 +549,16 @@ class Formula end # The directory in the cellar that the formula is installed to. - # This directory contains the formula's name and version. + # This directory points to {#opt_prefix} if it exists and if #{prefix} is not + # called from within the same formula's {#install} or {#post_install} methods. + # Otherwise, return the full path to the formula's versioned cellar. def prefix(v = pkg_version) - Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}") + prefix = rack/v + if !@versioned_prefix && prefix.directory? && Keg.new(prefix).optlinked? + opt_prefix + else + prefix + end end # Is the formula linked? @@ -579,7 +587,7 @@ class Formula # installed versions of this software # @private def rack - prefix.parent + Pathname.new("#{HOMEBREW_CELLAR}/#{name}") end # All currently installed prefix directories. @@ -994,6 +1002,7 @@ class Formula # @private def run_post_install + @versioned_prefix = true build = self.build self.build = Tab.for_formula(self) old_tmpdir = ENV["TMPDIR"] @@ -1008,6 +1017,7 @@ class Formula ENV["TMPDIR"] = old_tmpdir ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp + @versioned_prefix = false end # Tell the user about any caveats regarding this package. @@ -1110,6 +1120,7 @@ class Formula # where staging is a Mktemp staging context # @private def brew + @versioned_prefix = true stage do |staging| staging.retain! if ARGV.keep_tmp? prepare_patches @@ -1123,6 +1134,8 @@ class Formula cp Dir["config.log", "CMakeCache.txt"], logs end end + ensure + @versioned_prefix = false end # @private @@ -1624,6 +1637,7 @@ class Formula # @private def run_test + @versioned_prefix = true old_home = ENV["HOME"] old_curl_home = ENV["CURL_HOME"] old_tmpdir = ENV["TMPDIR"] @@ -1655,6 +1669,7 @@ class Formula ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp ENV["TERM"] = old_term + @versioned_prefix = false end # @private diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 90e283c9b8..24c068460b 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -546,7 +546,7 @@ class FormulaInstaller def summary s = "" s << "#{Emoji.install_badge} " if Emoji.enabled? - s << "#{formula.prefix}: #{formula.prefix.abv}" + s << "#{formula.prefix.resolved_path}: #{formula.prefix.abv}" s << ", built in #{pretty_duration build_time}" if build_time s end diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 756b272885..7ac3e9e636 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -147,6 +147,7 @@ class Keg protected :path def initialize(path) + path = path.resolved_path if path.to_s.start_with?("#{HOMEBREW_PREFIX}/opt/") raise "#{path} is not a valid keg" unless path.parent.parent.realpath == HOMEBREW_CELLAR.realpath raise "#{path} is not a directory" unless path.directory? @path = path From ed892243cdd5519f859bdfd7713ad089a06e3546 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 31 Dec 2016 18:02:42 +0100 Subject: [PATCH 049/176] Remove `:bsexec` parameter from `SystemCommand`. --- Library/Homebrew/cask/lib/hbc/artifact/base.rb | 2 +- Library/Homebrew/cask/lib/hbc/system_command.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb index 05dbedd8fc..b53c13f08e 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb @@ -46,7 +46,7 @@ module Hbc arguments = { executable: arguments } if arguments.is_a?(String) # key sanity - permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :bsexec, :print_stdout, :print_stderr] + permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :print_stdout, :print_stderr] unknown_keys = arguments.keys - permitted_keys unless unknown_keys.empty? opoo %Q{Unknown arguments to #{description} -- #{unknown_keys.inspect} (ignored). Running "brew update; brew cleanup; brew cask cleanup" will likely fix it.} diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index 6380693862..06ce276dfc 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -48,13 +48,11 @@ module Hbc def process_options! options.extend(HashValidator) - .assert_valid_keys :input, :print_stdout, :print_stderr, :args, :must_succeed, :sudo, :bsexec + .assert_valid_keys :input, :print_stdout, :print_stderr, :args, :must_succeed, :sudo sudo_prefix = %w[/usr/bin/sudo -E --] sudo_prefix = sudo_prefix.insert(1, "-A") unless ENV["SUDO_ASKPASS"].nil? - bsexec_prefix = ["/bin/launchctl", "bsexec", options[:bsexec] == :startup ? "/" : options[:bsexec]] @command = [executable] options[:print_stderr] = true unless options.key?(:print_stderr) - @command.unshift(*bsexec_prefix) if options[:bsexec] @command.unshift(*sudo_prefix) if options[:sudo] @command.concat(options[:args]) if options.key?(:args) && !options[:args].empty? @command[0] = Shellwords.shellescape(@command[0]) if @command.size == 1 From 82f441396422b44c5f293e2b6597163de2349733 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 31 Dec 2016 17:03:29 +0000 Subject: [PATCH 050/176] formula, ARGV: don't output duplicate formulae. If you specify a formula more than once or it exists in the Cellar with an alias name and the main name (e.g. `qt` and `qt5`) you can see the same formula showing up more than once. Instead, resolve these output lists of formulae such that they are unique based on their `name`. This doesn't use `full_name` as it's `name` that's use for the `Cellar`. --- Library/Homebrew/extend/ARGV.rb | 4 ++-- Library/Homebrew/formula.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index d361a99a8f..767ddc6e3e 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -44,7 +44,7 @@ module HomebrewArgvExtension else Formulary.find_with_priority(name, spec) end - end + end.uniq(&:name) end def resolved_formulae @@ -79,7 +79,7 @@ module HomebrewArgvExtension f.follow_installed_alias = false f - end + end.uniq(&:name) end def casks diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bc1dbd9705..02d4b09a0c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1406,7 +1406,7 @@ class Formula Formulary.from_rack(rack) rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError end - end.compact + end.compact.uniq(&:name) end def self.installed_with_alias_path(alias_path) From 8b30abe0600df5c9d3da5b4c31ca88a71a1c3e03 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 31 Dec 2016 13:14:27 +0000 Subject: [PATCH 051/176] keg: handle dependencies of moved/renamed formulae In #1497 I switched from Keg#to_formula for comparing kegs to formulae to comparing the name and tap in the keg's tab to the name and tap of the formula. However, this fails to match if the name and tap of the formula have changed since the keg was installed, so it's clearly better to use Keg#to_formula where possible, and fall back to the information in the tab when #to_formula can't be used. --- Library/Homebrew/keg.rb | 13 ++++++++++++- Library/Homebrew/test/keg_test.rb | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index e64fd9b335..74fd88c2e2 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -126,7 +126,18 @@ class Keg end keg_names = kegs.map(&:name) - kegs_by_source = kegs.group_by { |k| [k.name, Tab.for_keg(k).tap] } + kegs_by_source = kegs.group_by do |keg| + begin + # First, attempt to resolve the keg to a formula + # to get up-to-date name and tap information. + f = keg.to_formula + [f.name, f.tap] + rescue FormulaUnavailableError + # If the formula for the keg can't be found, + # fall back to the information in the tab. + [keg.name, Tab.for_keg(keg).tap] + end + end remaining_formulae.each do |dependent| required = dependent.missing_dependencies(hide: keg_names) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 45d63aa951..40beac887d 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -373,6 +373,7 @@ class InstalledDependantsTests < LinkTestCase t.source["tap"] = "some/tap" t.source["path"] = nil end + dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }] assert_equal [@dependent], @keg.installed_dependents assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) @@ -388,7 +389,7 @@ class InstalledDependantsTests < LinkTestCase Formula["bar"].class.depends_on "baz" result = Keg.find_some_installed_dependents([@keg, @tap_dep]) - assert_equal [[@tap_dep], ["bar"]], result + assert_equal [[@keg, @tap_dep], ["bar"]], result end def test_no_dependencies_anywhere @@ -411,6 +412,23 @@ class InstalledDependantsTests < LinkTestCase assert_nil Keg.find_some_installed_dependents([@keg, @dependent]) end + def test_renamed_dependency + dependencies nil + + stub_formula_loader Formula["foo"], "homebrew/core/foo-old" + renamed_path = HOMEBREW_CELLAR/"foo-old" + (HOMEBREW_CELLAR/"foo").rename(renamed_path) + renamed_keg = Keg.new(renamed_path.join("1.0")) + + Formula["bar"].class.depends_on "foo" + + result = Keg.find_some_installed_dependents([renamed_keg]) + assert_equal [[renamed_keg], ["bar"]], result + ensure + # Move it back to where it was so it'll be cleaned up. + (HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo") + end + def test_empty_dependencies_in_tab dependencies [] assert_empty @keg.installed_dependents From 524d9ce8f3b8553a62da7223a012b4e332bd02b3 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 31 Dec 2016 15:29:36 +0000 Subject: [PATCH 052/176] keg: test dep fallback with unknown formulae --- Library/Homebrew/test/keg_test.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 40beac887d..660ccd8829 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -377,6 +377,11 @@ class InstalledDependantsTests < LinkTestCase dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }] assert_equal [@dependent], @keg.installed_dependents assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) + + dependencies nil + # It doesn't make sense for a keg with no formula to have any dependents, + # so that can't really be tested. + assert_nil Keg.find_some_installed_dependents([@keg]) end def test_a_dependency_with_no_tap_in_tab From f0fbcf5022b13dc613f7acfca4fcf87894bd8a2a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 31 Dec 2016 22:43:42 +0000 Subject: [PATCH 053/176] ENV/super: fix set_cpu_flags stub. It should accept arguments. Fixes https://github.com/Homebrew/homebrew-core/issues/8362 --- Library/Homebrew/extend/ENV/super.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 7503e88768..39ddb66819 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -328,7 +328,8 @@ module Superenv # This method does nothing in superenv since there's no custom CFLAGS API # @private - def set_cpu_flags; end + def set_cpu_flags(*_args) + end end class Array From 9105ccece370f29b245f54247bbf8dff652b452f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 31 Dec 2016 22:43:55 +0000 Subject: [PATCH 054/176] rubocop_todo: autogenerate update. --- Library/Homebrew/.rubocop_todo.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index 3705170fdc..c1b2ba6e7e 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2016-10-24 17:14:14 +0200 using RuboCop version 0.44.1. +# on 2016-12-31 22:41:53 +0000 using RuboCop version 0.45.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -59,31 +59,24 @@ Lint/ShadowedException: Exclude: - 'utils/fork.rb' -# Offense count: 14 +# Offense count: 13 Metrics/BlockNesting: Max: 5 # Offense count: 19 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 367 + Max: 363 -# Offense count: 2 +# Offense count: 1 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 6 -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: percent_q, bare_percent -Style/BarePercentLiterals: +# Offense count: 1 +Style/AccessorMethodName: Exclude: - - 'dev-cmd/audit.rb' - - 'test/test_diagnostic.rb' - - 'test/test_exceptions.rb' - - 'test/test_patch.rb' - - 'test/test_string.rb' + - 'extend/ENV/super.rb' # Offense count: 6 Style/ClassVars: From 05b85a7bef112a2d3db7cd56c819a62d9bb34e1b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 17 Nov 2016 16:18:50 +0000 Subject: [PATCH 055/176] keg: update installed dependency resolution Closes #1525. (See there for a motivation for this change.) --- Library/Homebrew/keg.rb | 7 +++---- Library/Homebrew/test/keg_test.rb | 12 ++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 74fd88c2e2..b7af6427f3 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -385,6 +385,7 @@ class Keg end def installed_dependents + return [] unless linked? tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) @@ -394,12 +395,10 @@ class Keg # in case of conflicts between formulae from different taps. begin dep_formula = Formulary.factory(dep["full_name"]) - next false unless dep_formula == to_formula + dep_formula == to_formula rescue FormulaUnavailableError - next false unless "#{tap}/#{name}" == dep["full_name"] + next "#{tap}/#{name}" == dep["full_name"] end - - dep["version"] == version.to_s end end end diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 660ccd8829..7b396b5636 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -340,6 +340,7 @@ class InstalledDependantsTests < LinkTestCase def setup super @dependent = setup_test_keg("bar", "1.0") + @keg.link end def alter_tab(keg = @dependent) @@ -442,8 +443,8 @@ class InstalledDependantsTests < LinkTestCase def test_same_name_different_version_in_tab dependencies [{ "full_name" => "foo", "version" => "1.1" }] - assert_empty @keg.installed_dependents - assert_nil Keg.find_some_installed_dependents([@keg]) + assert_equal [@dependent], @keg.installed_dependents + assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) end def test_different_name_same_version_in_tab @@ -465,4 +466,11 @@ class InstalledDependantsTests < LinkTestCase assert_empty @keg.installed_dependents assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg]) end + + def test_unlinked + @keg.unlink + dependencies [{ "full_name" => "foo", "version" => "1.0" }] + assert_empty @keg.installed_dependents + assert_nil Keg.find_some_installed_dependents([@keg]) + end end From 94ead557723491306515a67138b649d67e8299e0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 17 Nov 2016 17:18:48 +0000 Subject: [PATCH 056/176] keg: keg_only kegs can have installed dependents --- Library/Homebrew/keg.rb | 2 +- Library/Homebrew/test/keg_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index b7af6427f3..511d79687a 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -385,7 +385,7 @@ class Keg end def installed_dependents - return [] unless linked? + return [] if !linked? && !to_formula.keg_only? tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 7b396b5636..de32c55e53 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -473,4 +473,12 @@ class InstalledDependantsTests < LinkTestCase assert_empty @keg.installed_dependents assert_nil Keg.find_some_installed_dependents([@keg]) end + + def test_keg_only + @keg.unlink + Formula["foo"].class.keg_only "a good reason" + dependencies [{ "full_name" => "foo", "version" => "1.1" }] # different version + assert_equal [@dependent], @keg.installed_dependents + assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg]) + end end From e4856143a6a43a306101abcbf0f2d71d00354a18 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 29 Nov 2016 00:50:00 +0000 Subject: [PATCH 057/176] keg: check installed dependencies iff optlinked --- Library/Homebrew/keg.rb | 2 +- Library/Homebrew/test/keg_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 511d79687a..f3aab7f977 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -385,7 +385,7 @@ class Keg end def installed_dependents - return [] if !linked? && !to_formula.keg_only? + return [] unless optlinked? tap = Tab.for_keg(self).source["tap"] Keg.all.select do |keg| tab = Tab.for_keg(keg) diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index de32c55e53..40b47b5e9d 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -467,8 +467,8 @@ class InstalledDependantsTests < LinkTestCase assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg]) end - def test_unlinked - @keg.unlink + def test_nonoptlinked + @keg.remove_opt_record dependencies [{ "full_name" => "foo", "version" => "1.0" }] assert_empty @keg.installed_dependents assert_nil Keg.find_some_installed_dependents([@keg]) From e1d7d44e5a13d16bc7773a7afb09c1a789878f5a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 23 Dec 2016 17:29:29 +0000 Subject: [PATCH 058/176] tests: optlink fake kegs in uninstall test --- Library/Homebrew/test/uninstall_test.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index e7849178b3..597e77e40d 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -9,7 +9,10 @@ class UninstallTests < Homebrew::TestCase depends_on "dependency" end - [@dependency, @dependent].each { |f| f.installed_prefix.mkpath } + [@dependency, @dependent].each do |f| + f.installed_prefix.mkpath + Keg.new(f.installed_prefix).optlink + end tab = Tab.empty tab.homebrew_version = "1.1.6" @@ -25,7 +28,10 @@ class UninstallTests < Homebrew::TestCase def teardown Homebrew.failed = false - [@dependency, @dependent].each { |f| f.rack.rmtree } + [@dependency, @dependent].each do |f| + f.installed_kegs.each(&:remove_opt_record) + f.rack.rmtree + end end def handle_unsatisfied_dependents From 294781cc9efb330af98e9dfa701a2b64d41bf819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Thu, 29 Dec 2016 18:56:19 +0000 Subject: [PATCH 059/176] cask depends_on arch: remove everything but 64-bit intel --- .../Homebrew/cask/lib/hbc/dsl/depends_on.rb | 26 ++----------------- .../cask/test/cask/depends_on_test.rb | 9 ------- .../Casks/with-depends-on-arch-failure.rb | 12 --------- .../support/Casks/with-depends-on-arch.rb | 2 +- 4 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 Library/Homebrew/cask/test/support/Casks/with-depends-on-arch-failure.rb diff --git a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb index 2168b70900..a8c1a1b738 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/depends_on.rb @@ -13,30 +13,9 @@ module Hbc ].freeze VALID_ARCHES = { - intel: { type: :intel, bits: [32, 64] }, - ppc: { type: :ppc, bits: [32, 64] }, + intel: { type: :intel, bits: 64 }, # specific - i386: { type: :intel, bits: 32 }, x86_64: { type: :intel, bits: 64 }, - ppc_7400: { type: :ppc, bits: 32 }, - ppc_64: { type: :ppc, bits: 64 }, - }.freeze - - # Intentionally undocumented: catch variant spellings. - ARCH_SYNONYMS = { - x86_32: :i386, - x8632: :i386, - x8664: :x86_64, - intel_32: :i386, - intel32: :i386, - intel_64: :x86_64, - intel64: :x86_64, - amd_64: :x86_64, - amd64: :x86_64, - ppc7400: :ppc_7400, - ppc_32: :ppc_7400, - ppc32: :ppc_7400, - ppc64: :ppc_64, }.freeze attr_accessor :java @@ -100,8 +79,7 @@ module Hbc def arch=(*args) @arch ||= [] arches = args.map do |elt| - elt = elt.to_s.downcase.sub(/^:/, "").tr("-", "_").to_sym - ARCH_SYNONYMS.key?(elt) ? ARCH_SYNONYMS[elt] : elt + elt.to_s.downcase.sub(/^:/, "").tr("-", "_").to_sym end invalid_arches = arches - VALID_ARCHES.keys raise "invalid 'depends_on arch' values: #{invalid_arches.inspect}" unless invalid_arches.empty? diff --git a/Library/Homebrew/cask/test/cask/depends_on_test.rb b/Library/Homebrew/cask/test/cask/depends_on_test.rb index ce2e541783..4516dad37e 100644 --- a/Library/Homebrew/cask/test/cask/depends_on_test.rb +++ b/Library/Homebrew/cask/test/cask/depends_on_test.rb @@ -79,15 +79,6 @@ describe "Satisfy Dependencies and Requirements" do Hbc::Installer.new(arch_cask).install end end - - it "raises an exception when depends_on arch is not satisfied" do - arch_cask = Hbc.load("with-depends-on-arch-failure") - lambda { - shutup do - Hbc::Installer.new(arch_cask).install - end - }.must_raise(Hbc::CaskError) - end end describe "depends_on x11" do diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch-failure.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch-failure.rb deleted file mode 100644 index 14c9165735..0000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch-failure.rb +++ /dev/null @@ -1,12 +0,0 @@ -test_cask 'with-depends-on-arch-failure' do - version '1.2.3' - sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94' - - url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" - homepage 'http://example.com/with-depends-on-arch-failure' - - # guarantee mismatched hardware - depends_on arch: Hardware::CPU.intel? ? :ppc : :intel - - app 'Caffeine.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb b/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb index fe5e4ba032..e0c4e3fa7c 100644 --- a/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb +++ b/Library/Homebrew/cask/test/support/Casks/with-depends-on-arch.rb @@ -6,7 +6,7 @@ test_cask 'with-depends-on-arch' do homepage 'http://example.com/with-depends-on-arch' # covers all known hardware; always succeeds - depends_on arch: [:ppc, :intel] + depends_on arch: :intel app 'Caffeine.app' end From b9cc52db455b879fa048421851d7bd43bddde817 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Mon, 2 Jan 2017 12:56:20 +0900 Subject: [PATCH 060/176] New feature: GitHubReleaseDownloadStrategy GitHubReleaseDownloadStrategy downloads tarballs from GitHub Release assets. To use it, add ":using => GitHubReleaseDownloadStrategy" to the URL section of your formula. This download strategy uses GitHub access tokens (in the environment variables GITHUB_TOKEN) to sign the request. This strategy is suitable for corporate use just like S3DownloadStrategy, because it lets you use a private GttHub repository for internal distribution. It works with public one, but in that case simply use CurlDownloadStrategy. --- Library/Homebrew/download_strategy.rb | 76 +++++++++++++++++++ .../Homebrew/test/download_strategies_test.rb | 47 +++++++++++- 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 9f9b2ababe..fa54ef7166 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -532,6 +532,82 @@ class S3DownloadStrategy < CurlDownloadStrategy end end +# GitHubReleaseDownloadStrategy downloads tarballs from GitHub Release assets. +# To use it, add ":using => GitHubReleaseDownloadStrategy" to the URL section +# of your formula. This download strategy uses GitHub access tokens (in the +# environment variables GITHUB_TOKEN) to sign the request. +# This strategy is suitable for corporate use just like S3DownloadStrategy, +# because it lets you use a private GttHub repository for internal distribution. +# It works with public one, but in that case simply use CurlDownloadStrategy. +class GitHubReleaseDownloadStrategy < CurlDownloadStrategy + require 'open-uri' + + def initialize(name, resource) + super + + @github_token = ENV["GITHUB_TOKEN"] + unless @github_token + puts "Environmental variable GITHUB_TOKEN is required." + raise CurlDownloadStrategyError, @url + end + + url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)| + unless @url =~ url_pattern + puts "Invalid url pattern for GitHub Release." + raise CurlDownloadStrategyError, @url + end + + _, @owner, @repo, @tag, @filename = *(@url.match(url_pattern)) + end + + def _fetch + puts "Download asset_id: #{asset_id}" + # HTTP request header `Accept: application/octet-stream` is required. + # Without this, the GitHub API will respond with metadata, not binary. + curl asset_url, "-C", downloaded_size, "-o", temporary_path, "-H", 'Accept: application/octet-stream' + end + + private + + def asset_url + "https://#{@github_token}@api.github.com/repos/#{@owner}/#{@repo}/releases/assets/#{asset_id}" + end + + def asset_id + @asset_id ||= resolve_asset_id + end + + def resolve_asset_id + release_metadata = fetch_release_metadata + assets = release_metadata["assets"].select{ |a| a["name"] == @filename } + if assets.empty? + puts "Asset file not found." + raise CurlDownloadStrategyError, @url + end + + return assets.first["id"] + end + + def release_url + "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}" + end + + def fetch_release_metadata + begin + release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read + rescue OpenURI::HTTPError => e + if e.message == '404 Not Found' + puts "GitHub Release not found." + raise CurlDownloadStrategyError, @url + else + raise e + end + end + + return JSON.parse(release_response) + end +end + class SubversionDownloadStrategy < VCSDownloadStrategy def initialize(name, resource) super diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 87218fb12b..1df0267af3 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -2,11 +2,12 @@ require "testing_env" require "download_strategy" class ResourceDouble - attr_reader :url, :specs, :version + attr_reader :url, :specs, :version, :mirrors def initialize(url = "http://example.com/foo.tar.gz", specs = {}) @url = url @specs = specs + @mirrors = [] end end @@ -60,6 +61,50 @@ class VCSDownloadStrategyTests < Homebrew::TestCase end end +class GitHubReleaseDownloadStrategyTests < Homebrew::TestCase + def setup + resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") + ENV["GITHUB_TOKEN"] = "token" + @strategy = GitHubReleaseDownloadStrategy.new("foo", resource) + end + + def test_initialize + assert_equal "token", @strategy.instance_variable_get(:@github_token) + assert_equal "owner", @strategy.instance_variable_get(:@owner) + assert_equal "repo", @strategy.instance_variable_get(:@repo) + assert_equal "tag", @strategy.instance_variable_get(:@tag) + assert_equal "foo_v0.1.0_darwin_amd64.tar.gz", @strategy.instance_variable_get(:@filename) + end + + def test_asset_url + @strategy.stubs(:resolve_asset_id).returns(456) + expected = "https://token@api.github.com/repos/owner/repo/releases/assets/456" + assert_equal expected, @strategy.send(:asset_url) + end + + def test_resolve_asset_id + release_metadata = { + "assets" => [ + { + "id" => 123, + "name" => "foo_v0.1.0_linux_amd64.tar.gz", + }, + { + "id" => 456, + "name" => "foo_v0.1.0_darwin_amd64.tar.gz", + }, + ] + } + @strategy.stubs(:fetch_release_metadata).returns(release_metadata) + assert_equal 456, @strategy.send(:resolve_asset_id) + end + + def test_release_url + expected = "https://api.github.com/repos/owner/repo/releases/tags/tag" + assert_equal expected, @strategy.send(:release_url) + end +end + class GitDownloadStrategyTests < Homebrew::TestCase include FileUtils From 2c6516ef59747ae8af91922d289c5ba1f3160ad2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 31 Dec 2016 21:44:42 +0100 Subject: [PATCH 061/176] Disallow file separator in version strings. --- Library/Homebrew/cask/lib/hbc/audit.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index ab2f1bce54..955ecdbb00 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -60,6 +60,7 @@ module Hbc def check_version return unless cask.version check_no_string_version_latest + check_no_file_separator_in_version end def check_no_string_version_latest @@ -68,6 +69,13 @@ module Hbc add_error "you should use version :latest instead of version 'latest'" end + def check_no_file_separator_in_version + odebug "Verifying version does not contain '#{File::SEPARATOR}'" + return unless cask.version.raw_version.is_a?(String) + return unless cask.version.raw_version.include?(File::SEPARATOR) + add_error "version should not contain '#{File::SEPARATOR}'" + end + def check_sha256 return unless cask.sha256 check_sha256_no_check_if_latest From 79f9896d2ffd03819236318c9f0742d40f1826ac Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 2 Jan 2017 16:05:14 +0000 Subject: [PATCH 062/176] bottles: --force-bottle feigns or_later. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When reproducing issues with software that hasn’t been bottled yet on your version of macOS it can sometimes be helpful to use `or_later` bottle functionality i.e. just use the bottle for the latest version of macOS available. This maps well to the existing `--force-bottle` argument so it will now act as if the latest bottle has a `or_later` ending. --- Library/Homebrew/cmd/fetch.rb | 5 +++-- Library/Homebrew/cmd/install.rb | 8 ++++---- Library/Homebrew/extend/os/mac/utils/bottles.rb | 2 ++ docs/brew.1.html | 9 +++++++-- manpages/brew-cask.1 | 2 +- manpages/brew.1 | 7 +++++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index f92ef03b23..820a27e316 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -18,8 +18,9 @@ #: If `--build-from-source` is passed, download the source rather than a #: bottle. #: -#: If `--force-bottle` is passed, download a bottle if it exists for the current -#: version of macOS, even if it would not be used during installation. +#: If `--force-bottle` is passed, download a bottle if it exists for the +#: current or newest version of macOS, even if it would not be used during +#: installation. require "formula" diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 700cd9c3d0..6f578caf63 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -32,10 +32,10 @@ #: passed, then both and the dependencies installed as part of this process #: are built from source even if bottles are available. #: -# Hidden developer option: -# If `--force-bottle` is passed, install from a bottle if it exists -# for the current version of macOS, even if custom options are given. -# +#: If `--force-bottle` is passed, install from a bottle if it exists for the +#: current or newest version of macOS, even if it would not normally be used +#: for installation. +#: #: If `--devel` is passed, and defines it, install the development version. #: #: If `--HEAD` is passed, and defines it, install the HEAD version, diff --git a/Library/Homebrew/extend/os/mac/utils/bottles.rb b/Library/Homebrew/extend/os/mac/utils/bottles.rb index 18312c9fa8..c54e4e5b77 100644 --- a/Library/Homebrew/extend/os/mac/utils/bottles.rb +++ b/Library/Homebrew/extend/os/mac/utils/bottles.rb @@ -49,6 +49,8 @@ module Utils if key.to_s.end_with?("_or_later") later_tag = key.to_s[/(\w+)_or_later$/, 1].to_sym MacOS::Version.from_symbol(later_tag) <= tag_version + elsif ARGV.force_bottle? + true end end end diff --git a/docs/brew.1.html b/docs/brew.1.html index 8a24e499b7..d69c141bba 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -127,8 +127,9 @@ checksum of a previously cached version no longer matches.

If --build-from-source is passed, download the source rather than a bottle.

-

If --force-bottle is passed, download a bottle if it exists for the current -version of macOS, even if it would not be used during installation.

+

If --force-bottle is passed, download a bottle if it exists for the +current or newest version of macOS, even if it would not be used during +installation.

gist-logs [--new-issue|-n] formula

Upload logs for a failed build of formula to a new Gist.

formula is usually the name of the formula to install, but it can be specified @@ -185,6 +186,10 @@ from bottles if they are available.

passed, then both formula and the dependencies installed as part of this process are built from source even if bottles are available.

+

If --force-bottle is passed, install from a bottle if it exists for the +current or newest version of macOS, even if it would not normally be used +for installation.

+

If --devel is passed, and formula defines it, install the development version.

If --HEAD is passed, and formula defines it, install the HEAD version, diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index 9eaaf027a0..63aad2c56c 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW\-CASK" "1" "December 2016" "Homebrew" "brew-cask" +.TH "BREW\-CASK" "1" "January 2017" "Homebrew" "brew-cask" . .SH "NAME" \fBbrew\-cask\fR \- a friendly binary installer for macOS diff --git a/manpages/brew.1 b/manpages/brew.1 index c25f73af97..38dce5cfdd 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "December 2016" "Homebrew" "brew" +.TH "BREW" "1" "January 2017" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for macOS @@ -171,7 +171,7 @@ If \fB\-\-deps\fR is passed, also download dependencies for any listed \fIformul If \fB\-\-build\-from\-source\fR is passed, download the source rather than a bottle\. . .IP -If \fB\-\-force\-bottle\fR is passed, download a bottle if it exists for the current version of macOS, even if it would not be used during installation\. +If \fB\-\-force\-bottle\fR is passed, download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation\. . .TP \fBgist\-logs\fR [\fB\-\-new\-issue\fR|\fB\-n\fR] \fIformula\fR @@ -247,6 +247,9 @@ If \fB\-\-build\-from\-source\fR or \fB\-s\fR is passed, compile the specified \ If \fBHOMEBREW_BUILD_FROM_SOURCE\fR is set, regardless of whether \fB\-\-build\-from\-source\fR was passed, then both \fIformula\fR and the dependencies installed as part of this process are built from source even if bottles are available\. . .IP +If \fB\-\-force\-bottle\fR is passed, install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation\. +. +.IP If \fB\-\-devel\fR is passed, and \fIformula\fR defines it, install the development version\. . .IP From ed66fa3ae567f4500232341af4a9432fc03d8272 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 2 Jan 2017 17:24:52 +0000 Subject: [PATCH 063/176] update-report: handle homebrew/versions imports. Imports from homebrew/versions are migrated from that tap and then renamed immediately when they hit homebrew/core. This did not trigger our previous rename detection so address these to improve the output and handle migration correctly. --- Library/Homebrew/cmd/update-report.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index caa1e01adf..7865701969 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -387,7 +387,7 @@ class Reporter end end - renamed_formulae = [] + renamed_formulae = Set.new @report[:D].each do |old_full_name| old_name = old_full_name.split("/").last new_name = tap.formula_renames[old_name] @@ -402,10 +402,24 @@ class Reporter renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name end + @report[:A].each do |new_full_name| + new_name = new_full_name.split("/").last + old_name = tap.formula_renames.key(new_name) + next unless old_name + + if tap.core_tap? + old_full_name = old_name + else + old_full_name = "#{tap}/#{old_name}" + end + + renamed_formulae << [old_full_name, new_full_name] + end + unless renamed_formulae.empty? @report[:A] -= renamed_formulae.map(&:last) @report[:D] -= renamed_formulae.map(&:first) - @report[:R] = renamed_formulae + @report[:R] = renamed_formulae.to_a end @report From 91c09c5b11beb0f9ff9915b6e949f17c3973c9a5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 2 Jan 2017 18:29:00 +0000 Subject: [PATCH 064/176] General documentation updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mostly related to the newer ways we’re handling versions and the incoming deprecation of devel-only, head-only and versions. --- docs/Acceptable-Formulae.md | 6 +----- docs/Custom-GCC-and-cross-compilers.md | 3 +-- docs/FAQ.md | 19 ++----------------- docs/Formula-Cookbook.md | 6 +++--- ...mebrew-Pull-Request-(and-get-it-merged).md | 3 +++ docs/Interesting-Taps-&-Forks.md | 6 ------ docs/Tips-N'-Tricks.md | 4 +--- 7 files changed, 11 insertions(+), 36 deletions(-) diff --git a/docs/Acceptable-Formulae.md b/docs/Acceptable-Formulae.md index b827403d8a..ac65d0802b 100644 --- a/docs/Acceptable-Formulae.md +++ b/docs/Acceptable-Formulae.md @@ -67,12 +67,8 @@ Formulae in the core repository must have a stable version tagged by the upstream project. Tarballs are preferred to git checkouts, and tarballs should include the version in the filename whenever possible. -Software that only provides a development/beta, tagged version should be put in -[homebrew/devel-only](https://github.com/Homebrew/homebrew-devel-only). We don’t accept software without a tagged version because they regularly break -due to upstream changes; we can’t provide [bottles](Bottles.md) for them; and -we don’t have an automatic update mechanism for `head-only` formulae which -makes them very quickly outdated. +due to upstream changes and we can’t provide [bottles](Bottles.md) for them. ### Bindings First check that there is not already a binding available via diff --git a/docs/Custom-GCC-and-cross-compilers.md b/docs/Custom-GCC-and-cross-compilers.md index 1d662c1587..43b8dfc01f 100644 --- a/docs/Custom-GCC-and-cross-compilers.md +++ b/docs/Custom-GCC-and-cross-compilers.md @@ -15,7 +15,6 @@ GCC or cross-compiler suite, please link it in here. * Homebrew provides a `gcc` formula for use with Xcode 4.2+ or when needing C++11 support on earlier versions. -* [Homebrew-versions](https://github.com/homebrew/homebrew-versions) provides an -up to date GCC duplicates e.g. `brew install homebrew/versions/gcc48` +* Homebrew provides older GCC formulae e.g. `gcc@4.8` and `gcc@6` * [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V toolchain including binutils and gcc. diff --git a/docs/FAQ.md b/docs/FAQ.md index b9cbcd2259..82efbf4547 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -212,23 +212,8 @@ Linking /usr/local/Cellar/foo/0.1… 17 symlinks created ``` ### Where was a formula deleted? -Use `brew log $FORMULA` to find out! - -Sometimes formulae are moved to specialized repositories. These are the -likely candidates: - -* [homebrew/dupes](https://github.com/Homebrew/homebrew-dupes) -* [homebrew/games](https://github.com/Homebrew/homebrew-games) -* [homebrew/versions](https://github.com/Homebrew/homebrew-versions) - -You can use `brew tap` to access these formulae: - -```bash -brew tap homebrew/games -brew install … -``` - -Note that brew search still finds formula in taps. +Use `brew log $FORMULA` to find out! Likely because it had unresolved issues or +our analytics identified it was not widely used. ### Homebrew is a poor name, it is generic, why was it chosen? @mxcl was too concerned with the beer theme and didn’t consider that the diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 6657b97668..72afa387ed 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -9,11 +9,11 @@ A formula is a package definition written in Ruby. It can be created with `brew | **Keg** | The installation prefix of a **Formula** | `/usr/local/Cellar/foo/0.1` | | **opt prefix** | A symlink to the active version of a **Keg** | `/usr/local/opt/foo ` | | **Cellar** | All **Kegs** are installed here | `/usr/local/Cellar` | -| **Tap** | An optional Git repository of **Formulae** and/or commands | `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-versions` | +| **Tap** | An Git repository of **Formulae** and/or commands | `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` | | **Bottle** | Pre-built **Keg** used instead of building from source | `qt-4.8.4.mavericks.bottle.tar.gz` | | **Cask** | An [extension of homebrew](https://github.com/caskroom/homebrew-cask) to install macOS native apps | `/Applications/MacDown.app/Contents/SharedSupport/bin/macdown` | | **Brew Bundle**| An [extension of homebrew](https://github.com/Homebrew/homebrew-bundle) to describe dependencies | `brew 'myservice', restart_service: true` | - + ## An Introduction Homebrew uses Git for downloading updates and contributing to the project. @@ -33,7 +33,7 @@ Before submitting a new formula make sure your package: * isn't in another official [Homebrew tap](https://github.com/Homebrew) * isn't already waiting to be merged (check the [issue tracker](https://github.com/Homebrew/homebrew-core/pulls)) * is still supported by upstream (i.e. doesn't require extensive patching) -* has a stable, tagged version (i.e. not just a GitHub repository with no versions). See [Interesting-Taps-&-Forks](Interesting-Taps-&-Forks.md) for where pre-release versions belong. +* has a stable, tagged version (i.e. not just a GitHub repository with no versions). * passes all `brew audit --new-formula $FORMULA` tests. Before submitting a new formula make sure you read over our [contribution guidelines](https://github.com/Homebrew/brew/blob/master/CONTRIBUTING.md). diff --git a/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md b/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md index a3497abcaf..ef6091e2c9 100644 --- a/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md +++ b/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md @@ -4,6 +4,9 @@ The following commands are used by Homebrew contributors to set up a fork of Hom Depending on the change you want to make, you need to send the pull request to the appropriate one of Homebrew's main repositories. If you want to submit a change to Homebrew core code (the `brew` implementation), you should open the pull request on [Homebrew/brew](https://github.com/Homebrew/brew). If you want to submit a change for a formula, you should open the pull request on [the `homebrew/core` tap](https://github.com/Homebrew/homebrew-core) or another [official tap](https://github.com/Homebrew), based on the formula type. +## Submit a new version of an existing formula +1. Use `brew bump-formula-pr` to do everything (i.e. forking, committing, pushing) with a single command. Run `brew bump-formula-pr --help` to learn more. + ## Set up your own fork of the Homebrew repository ### Core `brew` code related pull request diff --git a/docs/Interesting-Taps-&-Forks.md b/docs/Interesting-Taps-&-Forks.md index d42a97f54d..dcb860a23c 100644 --- a/docs/Interesting-Taps-&-Forks.md +++ b/docs/Interesting-Taps-&-Forks.md @@ -12,16 +12,12 @@ Homebrew has the capability to add (and remove) multiple taps to your local inst * [homebrew/completions](https://github.com/Homebrew/homebrew-completions): Shell completion formulae. -* [homebrew/devel-only](https://github.com/Homebrew/homebrew-devel-only): A tap for brews that only have pre-release/development versions. - * [homebrew/dupes](https://github.com/Homebrew/homebrew-dupes): Need GDB or a newer Tk? System duplicates go here. * [homebrew/emacs](https://github.com/Homebrew/homebrew-emacs): A tap for Emacs packages. * [homebrew/games](https://github.com/Homebrew/homebrew-games): Game or gaming-emulation related formulae. -* [homebrew/head-only](https://github.com/Homebrew/homebrew-head-only): A tap for brews that only have unstable, unreleased versions. This tap is **deprecated** and doesn’t accept new formulae. - * [homebrew/nginx](https://github.com/Homebrew/homebrew-nginx): Feature rich Nginx tap for modules. * [homebrew/php](https://github.com/Homebrew/homebrew-php): Repository for php-related formulae. @@ -32,8 +28,6 @@ Homebrew has the capability to add (and remove) multiple taps to your local inst * [homebrew/services](https://github.com/Homebrew/homebrew-services): A tool to start Homebrew formulae's plists with `launchctl`. -* [homebrew/versions](https://github.com/Homebrew/homebrew-versions): Need e.g. older or newer versions of Postgresql? Older versions of GCC? - * [homebrew/x11](https://github.com/Homebrew/homebrew-x11): Formulae with hard X11 dependencies. `brew search` looks in these main taps as well as in [homebrew/core](https://github.com/Homebrew/homebrew-core). So don't worry about missing stuff. We will add other taps to the search as they become well maintained and popular. diff --git a/docs/Tips-N'-Tricks.md b/docs/Tips-N'-Tricks.md index fc532c0199..e2257e5340 100644 --- a/docs/Tips-N'-Tricks.md +++ b/docs/Tips-N'-Tricks.md @@ -3,9 +3,7 @@ ## Installing previous versions of formulae The preferred and supported method of installing specific versions of -formulae is to use the -[homebrew/versions](https://github.com/Homebrew/homebrew-versions) -tap. If the version you’re looking for isn’t available, consider [opening a +formulae is to use formula like e.g. `gcc@6`. If the version you’re looking for isn’t available, consider [opening a pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)! ### Installing directly from pull-requests From 248beb9bf6ce0b9afc97dfc72067b6acfcb5eeb8 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Tue, 3 Jan 2017 14:36:08 +0900 Subject: [PATCH 065/176] Move error messages in GitHubReleaseDownloadStrategy to raise argument --- Library/Homebrew/download_strategy.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index fa54ef7166..6e618f720e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -546,16 +546,10 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy super @github_token = ENV["GITHUB_TOKEN"] - unless @github_token - puts "Environmental variable GITHUB_TOKEN is required." - raise CurlDownloadStrategyError, @url - end + raise CurlDownloadStrategyError, "Environmental variable GITHUB_TOKEN is required." unless @github_token url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)| - unless @url =~ url_pattern - puts "Invalid url pattern for GitHub Release." - raise CurlDownloadStrategyError, @url - end + raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." unless @url =~ url_pattern _, @owner, @repo, @tag, @filename = *(@url.match(url_pattern)) end @@ -580,10 +574,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy def resolve_asset_id release_metadata = fetch_release_metadata assets = release_metadata["assets"].select{ |a| a["name"] == @filename } - if assets.empty? - puts "Asset file not found." - raise CurlDownloadStrategyError, @url - end + raise CurlDownloadStrategyError, "Asset file not found." if assets.empty? return assets.first["id"] end @@ -597,8 +588,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read rescue OpenURI::HTTPError => e if e.message == '404 Not Found' - puts "GitHub Release not found." - raise CurlDownloadStrategyError, @url + raise CurlDownloadStrategyError, "GitHub Release not found." else raise e end From a4330f458a09e946ef7bac912fba63628dbf67ca Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Tue, 3 Jan 2017 14:58:08 +0900 Subject: [PATCH 066/176] Use util/github insted of open-uri in GitHubReleaseDownloadStrategy --- Library/Homebrew/download_strategy.rb | 21 ++++++------------- .../Homebrew/test/download_strategies_test.rb | 2 +- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 6e618f720e..19af8820c5 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -535,18 +535,19 @@ end # GitHubReleaseDownloadStrategy downloads tarballs from GitHub Release assets. # To use it, add ":using => GitHubReleaseDownloadStrategy" to the URL section # of your formula. This download strategy uses GitHub access tokens (in the -# environment variables GITHUB_TOKEN) to sign the request. +# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. # This strategy is suitable for corporate use just like S3DownloadStrategy, # because it lets you use a private GttHub repository for internal distribution. # It works with public one, but in that case simply use CurlDownloadStrategy. class GitHubReleaseDownloadStrategy < CurlDownloadStrategy - require 'open-uri' + require "utils/formatter" + require 'utils/github' def initialize(name, resource) super - @github_token = ENV["GITHUB_TOKEN"] - raise CurlDownloadStrategyError, "Environmental variable GITHUB_TOKEN is required." unless @github_token + @github_token = ENV["HOMEBREW_GITHUB_API_TOKEN"] + raise CurlDownloadStrategyError, "Environmental variable HOMEBREW_GITHUB_API_TOKEN is required." unless @github_token url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)| raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." unless @url =~ url_pattern @@ -584,17 +585,7 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy end def fetch_release_metadata - begin - release_response = open(release_url, {:http_basic_authentication => [@github_token]}).read - rescue OpenURI::HTTPError => e - if e.message == '404 Not Found' - raise CurlDownloadStrategyError, "GitHub Release not found." - else - raise e - end - end - - return JSON.parse(release_response) + GitHub.open(release_url) end end diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 1df0267af3..e69bdfda23 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -64,7 +64,7 @@ end class GitHubReleaseDownloadStrategyTests < Homebrew::TestCase def setup resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") - ENV["GITHUB_TOKEN"] = "token" + ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" @strategy = GitHubReleaseDownloadStrategy.new("foo", resource) end From 824768e26ff34a63c0ff809b500c2f3910b982ed Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 3 Jan 2017 15:59:15 +0000 Subject: [PATCH 067/176] Set theme jekyll-theme-cayman --- docs/_config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/_config.yml diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000000..c4192631f2 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file From cd1579a51a0455f0e7dee1eeddc2191f67780ce6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 3 Jan 2017 17:50:09 +0000 Subject: [PATCH 068/176] Deprecate Homebrew/versions, Homebrew/devel-only. Don't use Homebrew/versions in a test and remove them both from the OFFICIAL_TAPS list (i.e. `brew search`). --- Library/Homebrew/official_taps.rb | 2 -- Library/Homebrew/test/tap_test.rb | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index a220c92396..c1ef431b68 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -1,7 +1,6 @@ OFFICIAL_TAPS = %w[ apache completions - devel-only dupes emacs fuse @@ -12,7 +11,6 @@ OFFICIAL_TAPS = %w[ python science tex - versions x11 ].freeze diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index b950cd1666..7114cdf228 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -16,7 +16,7 @@ class IntegrationCommandTestTap < IntegrationCommandTestCase end assert_match "homebrew/foo", cmd("tap") - assert_match "homebrew/versions", cmd("tap", "--list-official") + assert_match "homebrew/science", cmd("tap", "--list-official") assert_match "2 taps", cmd("tap-info") assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") @@ -162,17 +162,17 @@ class TapTest < Homebrew::TestCase assert_raises(TapUnavailableError) { Tap.new("Homebrew", "bar").remote } refute_predicate @tap, :custom_remote? - version_tap = Tap.new("Homebrew", "versions") - version_tap.path.mkpath - version_tap.path.cd do + services_tap = Tap.new("Homebrew", "services") + services_tap.path.mkpath + services_tap.path.cd do shutup do system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-versions" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-services" end end - refute_predicate version_tap, :private? + refute_predicate services_tap, :private? ensure - version_tap.path.rmtree if version_tap + services_tap.path.rmtree if services_tap end def test_remote_not_git_repo From bc0aa4e64ce4eaf53476aa448b71b711feb9939e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 3 Jan 2017 18:01:03 +0000 Subject: [PATCH 069/176] Add versions documentation. --- docs/Formula-Cookbook.md | 2 +- docs/Tips-N'-Tricks.md | 4 ++-- docs/Versions.md | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 docs/Versions.md diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 72afa387ed..69a47b2111 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -9,7 +9,7 @@ A formula is a package definition written in Ruby. It can be created with `brew | **Keg** | The installation prefix of a **Formula** | `/usr/local/Cellar/foo/0.1` | | **opt prefix** | A symlink to the active version of a **Keg** | `/usr/local/opt/foo ` | | **Cellar** | All **Kegs** are installed here | `/usr/local/Cellar` | -| **Tap** | An Git repository of **Formulae** and/or commands | `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` | +| **Tap** | A Git repository of **Formulae** and/or commands | `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` | | **Bottle** | Pre-built **Keg** used instead of building from source | `qt-4.8.4.mavericks.bottle.tar.gz` | | **Cask** | An [extension of homebrew](https://github.com/caskroom/homebrew-cask) to install macOS native apps | `/Applications/MacDown.app/Contents/SharedSupport/bin/macdown` | | **Brew Bundle**| An [extension of homebrew](https://github.com/Homebrew/homebrew-bundle) to describe dependencies | `brew 'myservice', restart_service: true` | diff --git a/docs/Tips-N'-Tricks.md b/docs/Tips-N'-Tricks.md index e2257e5340..3adf26b87a 100644 --- a/docs/Tips-N'-Tricks.md +++ b/docs/Tips-N'-Tricks.md @@ -2,8 +2,8 @@ ## Installing previous versions of formulae -The preferred and supported method of installing specific versions of -formulae is to use formula like e.g. `gcc@6`. If the version you’re looking for isn’t available, consider [opening a +The supported method of installing specific versions of +some formulae is to see if there is a versions formula like e.g. `gcc@6` available. If the version you’re looking for isn’t available, consider [opening a pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)! ### Installing directly from pull-requests diff --git a/docs/Versions.md b/docs/Versions.md new file mode 100644 index 0000000000..87bc9f5662 --- /dev/null +++ b/docs/Versions.md @@ -0,0 +1,15 @@ +# Versions +Now that [Homebrew/versions](https://github.com/homebrew/homebrew-versions) has been deprecated [Homebrew/core](https://github.com/homebrew/homebrew-core) supports multiple versions of formulae with a new naming format. + +In [Homebrew/versions](https://github.com/homebrew/homebrew-versions) the formula for GCC 6 was named `gcc6.rb` and began `class Gcc6 < Formula`. In [Homebrew/core](https://github.com/homebrew/homebrew-core) this same formula is named `gcc@6.rb` and begins `class GccAT6 < Formula`. + +## Acceptable Versioned Formulae +Homebrew's versions are not intended to be used for any old versions you personally require for your project; formulae submitted should be expected to be used by a large number of people and still supported by their upstream projects. + +Versioned formulae we include must meet the following standards: + +* 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. +* 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 strive to be linked at the same time as their non-versioned counterpart (without patching). If this is not possible, favour either `conflicts_with` or `keg_only` depending on whether users expect to have multiple versions installed at once or not. + +You should create your own [tap](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for formulae you or your organisation wishes to control the versioning of or those that do not meet the above standards. From 6ecf2ca0135bb79b92d21cc8ccbed9dd5cce1b03 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 3 Jan 2017 18:04:29 +0000 Subject: [PATCH 070/176] cask: remove license See https://github.com/Homebrew/brew/pull/1771#issuecomment-270179479. --- Library/Homebrew/cask/LICENSE | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 Library/Homebrew/cask/LICENSE diff --git a/Library/Homebrew/cask/LICENSE b/Library/Homebrew/cask/LICENSE deleted file mode 100644 index 62542ae576..0000000000 --- a/Library/Homebrew/cask/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright © 2013-2016, Paul Hinze & Contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, this - list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From a175a1241efbec95f442257919fffe867bdf26cf Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 3 Jan 2017 18:05:30 +0000 Subject: [PATCH 071/176] license: remove copyright ending year See https://github.com/Homebrew/brew/pull/1771#issuecomment-270143292. --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 1efd08cffe..12500f7e56 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ BSD 2-Clause License -Copyright (c) 2009-2016, Homebrew contributors +Copyright (c) 2009-present, Homebrew contributors All rights reserved. Redistribution and use in source and binary forms, with or without From d7ab913f312a3dd0852ba874d7585c4aad3c6166 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 3 Jan 2017 22:12:21 +0000 Subject: [PATCH 072/176] audit: deprecate env :std/:userpaths for strict. This should apply only for new formulae but we should start gradually phasing it out for older ones too. --- Library/Homebrew/dev-cmd/audit.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 74ba987f63..601031d6e0 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1048,6 +1048,8 @@ class FormulaAuditor return unless @strict + problem "`#{$1}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/ + if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/ bad_system = $1 unless %w[| < > & ; *].any? { |c| bad_system.include? c } From b7e10ba23972e3ebfdc4a75da1b6e2016d3e99c9 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 4 Jan 2017 00:46:44 +0000 Subject: [PATCH 073/176] tests: remove temp tab homebrew_version override This had to be added in #1750 to work around special-casing for tabs generated with Homebrew versions < 1.1.6. Now that 1.1.6 is the current version, we can remove this hack. --- Library/Homebrew/test/tab_test.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 526e1f79e3..baa1dec84e 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -33,10 +33,6 @@ class TabTests < Homebrew::TestCase def test_defaults tab = Tab.empty - # FIXME: remove this line after Homebrew 1.1.6 is released. - # See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622 - tab.homebrew_version = "1.1.6" - assert_empty tab.unused_options assert_empty tab.used_options assert_nil tab.changed_files @@ -199,10 +195,6 @@ class TabTests < Homebrew::TestCase stdlib = :libcxx tab = Tab.create(f, compiler, stdlib) - # FIXME: remove this line after Homebrew 1.1.6 is released. - # See https://github.com/Homebrew/brew/pull/1750#discussion_r94254622 - tab.homebrew_version = "1.1.6" - runtime_dependencies = [ { "full_name" => "bar", "version" => "2.0" }, { "full_name" => "user/repo/from_tap", "version" => "1.0" }, From 56d6695bf36805bb32a960e377a564fc4df5d716 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 4 Jan 2017 00:56:06 +0000 Subject: [PATCH 074/176] tab: set homebrew_version in Tab.empty --- Library/Homebrew/tab.rb | 1 + Library/Homebrew/test/tab_test.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 669846dfc9..746c3dd928 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -168,6 +168,7 @@ class Tab < OpenStruct def self.empty attributes = { + "homebrew_version" => HOMEBREW_VERSION, "used_options" => [], "unused_options" => [], "built_as_bottle" => false, diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index baa1dec84e..f9824ba2a8 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -33,6 +33,7 @@ class TabTests < Homebrew::TestCase def test_defaults tab = Tab.empty + assert_equal HOMEBREW_VERSION, tab.homebrew_version assert_empty tab.unused_options assert_empty tab.used_options assert_nil tab.changed_files From 127e9def5084063cf33e8acb26a970556ef51148 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 4 Jan 2017 10:53:21 +0000 Subject: [PATCH 075/176] Cleanup documentation site GitHub now nicely generates a documentation site for us at http://brew.sh/brew based on our docs folder. Optimise the output of this and the GitHub docs directory for readability and the various user groupings. --- .gitignore | 7 + README.md | 11 +- docs/.ruby-version | 1 + docs/Acceptable-Formulae.md | 23 ++-- docs/Analytics.md | 4 +- docs/Bottles.md | 25 ++-- docs/Brew-Test-Bot-For-Core-Contributors.md | 2 +- docs/CNAME | 1 + docs/Checksum_Deprecation.md | 3 +- docs/Custom-GCC-and-cross-compilers.md | 2 +- docs/External-Commands.md | 80 +++++------- docs/FAQ.md | 45 +++---- docs/Gemfile | 6 + docs/Homebrew-and-Python.md | 14 +- ...=> How-To-Open-a-Homebrew-Pull-Request.md} | 0 docs/Installation.md | 5 +- docs/New-Maintainer-Checklist.md | 24 ++-- docs/Python-for-Formula-Authors.md | 2 + docs/Querying-Brew.md | 2 +- docs/README.md | 65 ++++++---- docs/Tips-N'-Tricks.md | 23 +--- docs/Xcode.md | 120 +++++++++--------- docs/_config.yml | 3 +- docs/brew-tap.md | 5 +- docs/brew.1.html | 4 +- manpages/brew.1 | 4 +- 26 files changed, 234 insertions(+), 247 deletions(-) create mode 100644 docs/.ruby-version create mode 100644 docs/CNAME create mode 100644 docs/Gemfile rename docs/{How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md => How-To-Open-a-Homebrew-Pull-Request.md} (100%) diff --git a/.gitignore b/.gitignore index 201be91d83..7b1678561d 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,13 @@ !/docs !/manpages +# Ignore generated documentation site +/docs/_site +/docs/.bundle +/docs/bin +/docs/vendor +/docs/Gemfile.lock + # Unignore our shell completion !/completions diff --git a/README.md b/README.md index 8e3efd1fdb..a3d613ce98 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew updat 3. Or use `brew search --desc ` to browse packages from the command line. ## More Documentation -`brew help`, `man brew` or check [our documentation](https://github.com/Homebrew/brew/tree/master/docs#readme). +`brew help`, `man brew` or check [our documentation](https://brew.sh/brew/). ## Troubleshooting First, please run `brew update` and `brew doctor`. @@ -40,9 +40,14 @@ This is our PGP key which is valid until May 24, 2017. ## Who Are You? Homebrew's lead maintainer is [Mike McQuaid](https://github.com/mikemcquaid). -Homebrew's current maintainers are [Misty De Meo](https://github.com/mistydemeo), [Andrew Janke](https://github.com/apjanke), [Xu Cheng](https://github.com/xu-cheng), [Tomasz Pajor](https://github.com/nijikon), [Josh Hagins](https://github.com/jawshooah), [Baptiste Fontaine](https://github.com/bfontaine), [Markus Reiter](https://github.com/reitermarkus), [ilovezfs](https://github.com/ilovezfs), [Martin Afanasjew](https://github.com/UniqMartin), [Tom Schoonjans](https://github.com/tschoonj), [Uladzislau Shablinski](https://github.com/vladshablinsky), [Tim Smith](https://github.com/tdsmith) and [Alex Dunn](https://github.com/dunn). +Homebrew's current maintainers are [Misty De Meo](https://github.com/mistydemeo), [Andrew Janke](https://github.com/apjanke), [Xu Cheng](https://github.com/xu-cheng), [Tomasz Pajor](https://github.com/nijikon), [Josh Hagins](https://github.com/jawshooah), [Baptiste Fontaine](https://github.com/bfontaine), [Markus Reiter](https://github.com/reitermarkus), [ilovezfs](https://github.com/ilovezfs), [Tom Schoonjans](https://github.com/tschoonj), [Uladzislau Shablinski](https://github.com/vladshablinsky), [Tim Smith](https://github.com/tdsmith) and [Alex Dunn](https://github.com/dunn). -Former maintainers with significant contributions include [Dominyk Tiller](https://github.com/DomT4), [Brett Koonce](https://github.com/asparagui), [Jack Nagel](https://github.com/jacknagel), [Adam Vandenberg](https://github.com/adamv) and Homebrew's creator: [Max Howell](https://github.com/mxcl). +Former maintainers with significant contributions include [Martin Afanasjew](https://github.com/UniqMartin), [Dominyk Tiller](https://github.com/DomT4), [Brett Koonce](https://github.com/asparagui), [Jack Nagel](https://github.com/jacknagel), [Adam Vandenberg](https://github.com/adamv) and Homebrew's creator: [Max Howell](https://github.com/mxcl). + +## Community +- [discourse.brew.sh (forum)](http://discourse.brew.sh) +- [freenode.net\#machomebrew (IRC)](irc://irc.freenode.net/#machomebrew) +- [@MacHomebrew (Twitter)](https://twitter.com/MacHomebrew) ## License Code is under the [BSD 2-clause "Simplified" License](https://github.com/Homebrew/brew/tree/master/LICENSE.txt). diff --git a/docs/.ruby-version b/docs/.ruby-version new file mode 100644 index 0000000000..bec3a35ee8 --- /dev/null +++ b/docs/.ruby-version @@ -0,0 +1 @@ +system diff --git a/docs/Acceptable-Formulae.md b/docs/Acceptable-Formulae.md index ac65d0802b..12084fad76 100644 --- a/docs/Acceptable-Formulae.md +++ b/docs/Acceptable-Formulae.md @@ -29,16 +29,16 @@ There are exceptions: #### Examples - Formula | Reason - --- | --- - ruby, python, perl | People want newer versions - bash | macOS's bash is stuck at 3.2 because newer versions are licensed under GPLv3 - zsh | This was a mistake, but it’s too late to remove it - emacs, vim | [Too popular to move to dupes](https://github.com/Homebrew/homebrew/pull/21594#issuecomment-21968819) - subversion | Originally added for 10.5, but people want the latest version - libcurl | Some formulae require a newer version than macOS provides - openssl | macOS's openssl is deprecated & outdated. - libxml2 | Historically, macOS's libxml2 has been buggy +| Formula | Reason | +|--------------------|-------------------------------------------------------------------------------------------------------| +| ruby, python, perl | People want newer versions | +| bash | macOS's bash is stuck at 3.2 because newer versions are licensed under GPLv3 | +| zsh | This was a mistake, but it’s too late to remove it | +| emacs, vim | [Too popular to move to dupes](https://github.com/Homebrew/homebrew/pull/21594#issuecomment-21968819) | +| subversion | Originally added for 10.5, but people want the latest version | +| libcurl | Some formulae require a newer version than macOS provides | +| openssl | macOS's openssl is deprecated & outdated. | +| libxml2 | Historically, macOS's libxml2 has been buggy | We also maintain [a tap](https://github.com/Homebrew/homebrew-dupes) that contains many duplicates not otherwise found in Homebrew. @@ -80,7 +80,8 @@ useful to people. Just install the stuff! Having to faff around with foo-ruby foo-perl etc. sucks. ### Niche (or self-submitted) Stuff -The software in question must be +The software in question must be: + * maintained (e.g. upstream is still making new releases) * known * stable (e.g. not declared "unstable" or "beta" by upstream) diff --git a/docs/Analytics.md b/docs/Analytics.md index 83386b3eea..80515d0799 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -1,4 +1,4 @@ -# Homebrew's Anonymous Aggregate User Behaviour Analytics +# Anonymous Aggregate User Behaviour Analytics Homebrew has begun gathering anonymous aggregate user behaviour analytics and reporting these to Google Analytics. You will be notified the first time you run `brew update` or install Homebrew. ## Why? @@ -41,7 +41,7 @@ Homebrew's analytics are sent throughout Homebrew's execution to Google Analytic Homebrew's analytics are accessible to Homebrew's current maintainers. Contact @mikemcquaid if you are a maintainer and need access. ## How? -The code is viewable in https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/analytics.rb and https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/analytics.sh. They are done in a separate background process and fail fast to avoid delaying any execution. They will fail immediately and silently if you have no network connection. +The code is viewable in [analytics.rb](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/analytics.rb) and [analytics.sh](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/analytics.sh). They are done in a separate background process and fail fast to avoid delaying any execution. They will fail immediately and silently if you have no network connection. ## Opting out Homebrew analytics helps us maintainers and leaving it on is appreciated. However, if you want to opt out of Homebrew's analytics, you can set this variable in your environment: diff --git a/docs/Bottles.md b/docs/Bottles.md index 196b36e1fb..7d2982c142 100644 --- a/docs/Bottles.md +++ b/docs/Bottles.md @@ -1,23 +1,24 @@ -# Bottles -Bottles are Homebrew's binary packages. They are produced by installing a formula with `brew install --build-bottle $FORMULA` and then bottling it with `brew bottle $FORMULA`. This outputs the bottle DSL which should be inserted into the formula file. +# Bottles (binary packages) +Bottles are produced by installing a formula with `brew install --build-bottle $FORMULA` and then bottling it with `brew bottle $FORMULA`. This outputs the bottle DSL which should be inserted into the formula file. -## Bottle Usage +## Usage If a bottle is available and usable it will be downloaded and poured automatically when you `brew install `. If you wish to disable this you can do it by specifying `--build-from-source`. Bottles will not be used if the user requests it (see above), if the formula requests it (with `pour_bottle?`), if any options are specified on installation (bottles are all compiled with default options), if the bottle is not up to date (e.g. lacking a checksum) or the bottle's `cellar` is not `:any` or equal to the current `HOMEBREW_CELLAR`. -## Bottle Creation +## Creation Bottles are created using the [Brew Test Bot](Brew-Test-Bot.md). This happens mostly when people submit pull requests to Homebrew and the `bottle do` block is updated by maintainers when they `brew pull --bottle` the contents of a pull request. For the Homebrew organisations' taps they are uploaded to and downloaded from [Bintray](https://bintray.com/homebrew). By default, bottles will be built for the oldest CPU supported by the OS/architecture you're building for. (That's Core 2 for 64-bit OSs, Core for 32-bit.) This ensures that bottles are compatible with all computers you might distribute them to. If you *really* want your bottles to be optimized for something else, you can pass the `--bottle-arch=` option to build for another architecture - for example, `brew install foo --bottle-arch=penryn`. Just remember that if you build for a newer architecture some of your users might get binaries they can't run and that would be sad! -## Bottle Format +## Format Bottles are simple gzipped tarballs of compiled binaries. Any metadata is stored in a formula's bottle DSL and in the bottle filename (i.e. MacOS version, revision). ## Bottle DSL (Domain Specific Language) Bottles have a DSL to be used in formulae which is contained in the `bottle do ... end` block. A simple (and typical) example: + ```ruby bottle do sha256 "4921af80137af9cc3d38fd17c9120da882448a090b0a8a3a19af3199b415bfca" => :sierra @@ -27,6 +28,7 @@ end ``` A full example: + ```ruby bottle do root_url "https://example.com" @@ -39,33 +41,34 @@ bottle do end ``` -### `root_url` +### Root URL (`root_url`) Optionally contains the URL root used to calculate bottle URLs. By default this is omitted and the Homebrew default bottle URL root is used. This may be useful for taps which wish to provide bottles for their formulae or to cater for a non-default `HOMEBREW_CELLAR`. -### `cellar` +### Cellar (`cellar`) Optionally contains the value of `HOMEBREW_CELLAR` in which the bottles were built. Most compiled software contains references to its compiled location so cannot be simply relocated anywhere on disk. If this value is `:any` or `:any_skip_relocation` this means that the bottle can be safely installed in any Cellar as it did not contain any references to its installation Cellar. This can be omitted if a bottle is compiled (as all default Homebrew ones are) for the default `HOMEBREW_CELLAR` of `/usr/local/Cellar` -### `prefix` +### Prefix (`prefix`) Optionally contains the value of `HOMEBREW_PREFIX` in which the bottles were built. See description of `cellar`. When `cellar` is `:any` or `:any_skip_relocation` prefix should be omitted. -### `rebuild` +### Rebuild version (`rebuild`) Optionally contains the rebuild version of the bottle. Sometimes bottles may need be updated without bumping the version of the formula e.g. a new patch was applied. In that case the rebuild will have a value of 1 or more. -### `sha256` +### Checksum (`sha256`) Contains the SHA-256 of bottle for a particular version of macOS. ## Formula DSL Additionally there is a method available in the formula DSL. -### `pour_bottle?` +### Pour Bottle (`pour_bottle?`) Optionally returns a boolean to decide whether a bottle should be used for this formula. For example a bottle may break if another formula has been compiled with non-default options so this method could check for that case and return `false`. A full example: + ```ruby pour_bottle? do reason "The bottle needs the Xcode CLT to be installed." diff --git a/docs/Brew-Test-Bot-For-Core-Contributors.md b/docs/Brew-Test-Bot-For-Core-Contributors.md index 8e264ea7e9..4b697066c4 100644 --- a/docs/Brew-Test-Bot-For-Core-Contributors.md +++ b/docs/Brew-Test-Bot-For-Core-Contributors.md @@ -4,7 +4,7 @@ If a build has run and passed on `brew test-bot` then it can be used to quickly There are two types of Jenkins jobs you will interact with: ## [Homebrew Pull Requests](https://bot.brew.sh/job/Homebrew%20Core%20Pull%20Requests/) -This job automatically builds any pull requests submitted to Homebrew/homebrew-core. On success or failure it updates the pull request status (see more details on the [main Brew Test Bot wiki page](Brew-Test-Bot.md)). On a successful build it automatically uploads bottles. +This job automatically builds any pull requests submitted to Homebrew/homebrew-core. On success or failure it updates the pull request status (see more details on the [main Brew Test Bot documentation page](Brew-Test-Bot.md)). On a successful build it automatically uploads bottles. ## [Homebrew Testing](https://bot.brew.sh/job/Homebrew%20Testing/) This job is manually triggered to run [`brew test-bot`](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/test-bot.rb) with user-specified parameters. On a successful build it automatically uploads bottles. diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000000..01a3ad9d8c --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +docs.brew.sh diff --git a/docs/Checksum_Deprecation.md b/docs/Checksum_Deprecation.md index 62985848bd..c86f3a1a36 100644 --- a/docs/Checksum_Deprecation.md +++ b/docs/Checksum_Deprecation.md @@ -1,5 +1,4 @@ -# Checksum Deprecation - +# MD5 and SHA-1 Deprecation During early 2015 Homebrew started the process of deprecating _SHA1_ for package integrity verification. Since then every formulae under the Homebrew organisation has been moved onto _SHA256_ verification; this includes both source packages diff --git a/docs/Custom-GCC-and-cross-compilers.md b/docs/Custom-GCC-and-cross-compilers.md index 43b8dfc01f..99b52c060b 100644 --- a/docs/Custom-GCC-and-cross-compilers.md +++ b/docs/Custom-GCC-and-cross-compilers.md @@ -1,4 +1,4 @@ -# Custom GCC and cross compilers +# Custom GCC and Cross Compilers Homebrew depends on having an up-to-date version of Xcode because it comes with specific versions of build tools e.g. `clang`. diff --git a/docs/External-Commands.md b/docs/External-Commands.md index 8fe6932b05..b88ba3fa56 100644 --- a/docs/External-Commands.md +++ b/docs/External-Commands.md @@ -7,78 +7,56 @@ $ brew mycommand --option1 --option3 formula without modifying Homebrew's internals. -## COMMAND TYPES +## Command Types External commands come in two flavors: Ruby commands and shell scripts. In both cases, the command file should be executable (`chmod +x`) and live somewhere in `$PATH`. -### RUBY COMMANDS +### Ruby Commands An external command `extcmd` implemented as a Ruby command should be named `brew-extcmd.rb`. The command is executed by doing a `require` on the full pathname. As the command is `require`d, it has full access to the Homebrew "environment", i.e. all global variables and modules that any internal command has access to. The command may `Kernel.exit` with a status code if it needs to; if it doesn't explicitly exit then Homebrew will return 0. -### SHELL SCRIPTS +### Shell Scripts A shell script for an command named `extcmd` should be named `brew-extcmd`. This file will be run via `exec` with some Homebrew variables set as environmental variables, and passed any additional command-line arguments. - - - - - - - - - - - - - - - - - - - - - - - - - -
VariableDescription
HOMEBREW_CACHEWhere Homebrew caches downloaded tarballs to, by default ~/Library/Caches/Homebrew.
HOMEBREW_CELLARThe location of the Homebrew Cellar, where software is staged. This will be $HOMEBREW_PREFIX/Cellar if that directory exists, or $HOMEBREW_REPOSITORY/Cellar otherwise.
HOMEBREW_LIBRARY_PATHThe directory containing Homebrew’s own application code.
HOMEBREW_PREFIXWhere Homebrew installs software. This is always the grandparent directory of the `brew` executable, /usr/local by default.
HOMEBREW_REPOSITORYIf installed from a Git clone, the repo directory (i.e., where Homebrew’s .git directory lives).
+| Variable | Description | +|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| HOMEBREW_CACHE | Where Homebrew caches downloaded tarballs to, by default ~/Library/Caches/Homebrew. | +| HOMEBREW_CELLAR | The location of the Homebrew Cellar, where software is staged. This will be $HOMEBREW_PREFIX/Cellar if that directory exists, or $HOMEBREW_REPOSITORY/Cellar otherwise. | +| HOMEBREW_LIBRARY_PATH | The directory containing Homebrew’s own application code. | +| HOMEBREW_PREFIX | Where Homebrew installs software. This is always the grandparent directory of the `brew` executable, /usr/local by default. | +| HOMEBREW_REPOSITORY | If installed from a Git clone, the repo directory (i.e., where Homebrew’s .git directory lives). | + Note that the script itself can use any suitable shebang (`#!`) line, so an external “shell script” can be written for sh, bash, Ruby, or anything else. -## USER-SUBMITTED COMMANDS +## User-submitted Commands These commands have been contributed by Homebrew users but are not included in the main Homebrew repository, nor are they installed by the installer script. You can install them manually, as outlined above. ->*NOTE:* They are largely untested, and as always, be careful about running untested code on your machine. +Note they are largely untested, and as always, be careful about running untested code on your machine. ### brew-livecheck -> Check if there is a new upstream version of a formula. -> -> See the [`README`](https://github.com/youtux/homebrew-livecheck/blob/master/README.md) for more info and usage. -> -> Install using: -> ``` -> $ brew tap youtux/livecheck -> ``` +Check if there is a new upstream version of a formula. +See the [`README`](https://github.com/youtux/homebrew-livecheck/blob/master/README.md) for more info and usage. + +Install using: +```sh +brew tap youtux/livecheck +``` ### brew-gem ->Install any gem package into a self-contained Homebrew cellar location: -> ->*Note:* This can also be installed with `brew install brew-gem`. +Install any gem package into a self-contained Homebrew cellar location: [https://github.com/sportngin/brew-gem](https://github.com/sportngin/brew-gem). + +Note this can also be installed with `brew install brew-gem`. ### brew-growl ->Get Growl notifications for Homebrew https://github.com/secondplanet/brew-growl +Get Growl notifications for Homebrew https://github.com/secondplanet/brew-growl ### brew-services ->Simple support to start formulae using launchctl, has out of the box support for any formula which defines `startup_plist` (e.g. mysql, postgres, redis u.v.m.): [https://github.com/Homebrew/homebrew-services](https://github.com/Homebrew/homebrew-services) +Simple support to start formulae using launchctl, has out of the box support for any formula which defines `startup_plist` (e.g. mysql, postgres, redis u.v.m.): [https://github.com/Homebrew/homebrew-services](https://github.com/Homebrew/homebrew-services) -> Install using: -> ``` - $ brew tap homebrew/services -> ``` - -## SEE ALSO -Homebrew Docs: +Install using: +```sh +brew tap homebrew/services +``` diff --git a/docs/FAQ.md b/docs/FAQ.md index 82efbf4547..7a32cf9262 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -1,5 +1,6 @@ # FAQ -### How do I update my local packages? + +## How do I update my local packages? First update the formulae and Homebrew itself: brew update @@ -18,7 +19,7 @@ Or upgrade a specific formula with: -### How do I stop certain formulae from being updated? +## How do I stop certain formulae from being updated? To stop something from being updated/upgraded: brew pin $FORMULA @@ -27,7 +28,7 @@ To allow that formulae to update again: brew unpin $FORMULA -### How do I uninstall old versions of a formula? +## How do I uninstall old versions of a formula? By default, Homebrew does not uninstall old versions of a formula, so over time you will accumulate old versions. To remove them, simply use: @@ -43,7 +44,7 @@ to see what would be cleaned up: -### How do I uninstall Homebrew? +## How do I uninstall Homebrew? To uninstall Homebrew, paste the command below in a terminal prompt. ```bash @@ -54,7 +55,7 @@ and run `./uninstall --help` to view more uninstall options. -### How do I uninstall a formula? +## How do I uninstall a formula? If you do not uninstall all of the versions that Homebrew has installed, Homebrew will continue to attempt to install the newest version it knows about when you do (`brew upgrade --all`). This can be surprising. @@ -64,13 +65,13 @@ To remove a formula entirely, you may do Be careful as this is a destructive operation. -### Where does stuff get downloaded? +## Where does stuff get downloaded? brew --cache Which is usually: `~/Library/Caches/Homebrew` -### My Mac `.app`s don’t find `/usr/local/bin` utilities! +## My Mac `.app`s don’t find `/usr/local/bin` utilities! GUI apps on macOS don’t have `/usr/local/bin` in their `PATH` by default. If you’re on Mountain Lion, you can fix this by running `launchctl setenv PATH "/usr/local/bin:$PATH"`. [More details @@ -79,10 +80,10 @@ including how to set this across reboots. If you’re pre-Mountain Lion, [here’s an official alternative](https://developer.apple.com/legacy/library/qa/qa1067/_index.html). -### How do I contribute to Homebrew? +## How do I contribute to Homebrew? Read [CONTRIBUTING.md](/CONTRIBUTING.md). -### Why do you compile everything? +## Why do you compile everything? Homebrew provides pre-compiled versions for many formulae. These pre-compiled versions are referred to as **bottles** and are available at: @@ -107,7 +108,7 @@ your profile. We aim to bottle everything. -### How do I get a formula from someone else’s branch? +## How do I get a formula from someone else’s branch? brew install hub brew update @@ -122,7 +123,7 @@ Or: `brew pull https://github.com/Homebrew/homebrew-core/pull/1234` -### Why does Homebrew prefer I install to `/usr/local`? +## Why does Homebrew prefer I install to `/usr/local`? 1. **It’s easier**
`/usr/local/bin` is already in your @@ -142,7 +143,7 @@ brews then save yourself a bunch of hassle and install to It is not always straightforward to tell `gem` to look in non-standard directories for headers and libraries. If you choose `/usr/local`, many things will "just work". -### Why does Homebrew say sudo is bad? +## Why does Homebrew say sudo is bad? **tl;dr** Sudo is dangerous, and you installed TextMate.app without sudo anyway. @@ -168,17 +169,17 @@ not. So is it that important to `chown root wget`? If you need to run Homebrew in a multi-user environment, consider creating a separate user account especially for use of Homebrew. -### Why isn’t a particular command documented? +## Why isn’t a particular command documented? If it’s not in `man brew`, it’s probably an external command. These are documented [here](External-Commands.md). -### Why haven’t you pulled my pull request? +## Why haven’t you pulled my pull request? If it’s been a while, bump it with a “bump” comment. Sometimes we miss requests and there are plenty of them. Maybe we were thinking on something. It will encourage consideration. In the meantime if you could rebase the pull request so that it can be cherry-picked more easily we will love you for a long time. -### Can I edit formulae myself? +## Can I edit formulae myself? Yes! It’s easy! Just `brew edit $FORMULA`. You don’t have to submit modifications back to *Homebrew/homebrew-core*, just edit the formula as you personally need it and `brew install`. As a bonus `brew update` will merge your changes with upstream so you can still keep the formula up-to-date **with** your personal modifications! -### Can I make new formulae? +## Can I make new formulae? Yes! It’s easy! Just `brew create URL` Homebrew will then open the formula in `$EDITOR` so you can edit it, but it probably already installs; try it: `brew install $FORMULA`. If you come up with any issues, @@ -188,7 +189,7 @@ which drops you into a debugging shell. If you want your new formula to be part of *homebrew/core* or want to learn more about writing formulae, then please read the [Formula Cookbook](Formula-Cookbook.md). -### Can I install my own stuff to `/usr/local`? +## Can I install my own stuff to `/usr/local`? Yes, brew is designed to not get in your way so you can use it how you like. @@ -211,25 +212,25 @@ $ brew link foo Linking /usr/local/Cellar/foo/0.1… 17 symlinks created ``` -### Where was a formula deleted? +## Why was a formula deleted? Use `brew log $FORMULA` to find out! Likely because it had unresolved issues or our analytics identified it was not widely used. -### Homebrew is a poor name, it is generic, why was it chosen? +## Homebrew is a poor name, it is generic, why was it chosen? @mxcl was too concerned with the beer theme and didn’t consider that the project may actually prove popular. By the time he realized it was too late. However, today, the first google hit for “homebrew” is not beer related ;-) -### What does *keg-only* mean? +## What does *keg-only* mean? It means the formula is installed only into the Cellar; it is not linked into `/usr/local`. This means most tools will not find it. We don’t do this for stupid reasons. You can still link in the formula if you need to with `brew link`. -### How can I specify different configure arguments for a formula? +## How can I specify different configure arguments for a formula? `brew edit $FORMULA` and edit the formula. Currently there is no other way to do this. -### Is there a glossary of terms around? +## Is there a glossary of terms around? All your terminology needs can be [found here](Formula-Cookbook.md#homebrew-terminology). diff --git a/docs/Gemfile b/docs/Gemfile new file mode 100644 index 0000000000..fac2f802d4 --- /dev/null +++ b/docs/Gemfile @@ -0,0 +1,6 @@ +source "https://rubygems.org" + +gem "github-pages", group: :jekyll_plugins + +# Nokogiri >=1.7 requires Ruby >=2.1 +gem "nokogiri", "<1.7" diff --git a/docs/Homebrew-and-Python.md b/docs/Homebrew-and-Python.md index 2500b85921..0757b5d244 100644 --- a/docs/Homebrew-and-Python.md +++ b/docs/Homebrew-and-Python.md @@ -1,6 +1,4 @@ -# Homebrew and Python -## Overview - +# Python This page describes how Python is handled in Homebrew for users. See [Python for Formula Authors](Python-for-Formula-Authors.md) for advice on writing formulae to install packages written in Python. Homebrew should work with any [CPython](https://stackoverflow.com/questions/2324208/is-there-any-difference-between-cpython-and-python) and defaults to the macOS system Python. @@ -11,14 +9,12 @@ Homebrew provides formulae to brew a more up-to-date Python 2.7.x (and 3.x). ## Python 2.x or Python 3.x - Homebrew provides a formula for Python 2.7.x and one for Python 3.x. They don't conflict, so they can both be installed. The executable `python` will always point to the 2.x and `python3` to the 3.x version. ([Wondering which one to choose?](https://wiki.python.org/moin/Python2orPython3)) ## Setuptools, Pip, etc. - The Python formulae install [`pip`](http://www.pip-installer.org) and [Setuptools](https://pypi.python.org/pypi/setuptools). Setuptools can be updated via Pip, without having to re-brew Python: @@ -30,7 +26,6 @@ Similarly, Pip can be used to upgrade itself via: pip install --upgrade pip ### Note on `pip install --user` - The normal `pip install --user` is disabled for brewed Python. This is because of a bug in distutils, because Homebrew writes a `distutils.cfg` which sets the package `prefix`. A possible workaround (which puts executable scripts in `~/Library/Python/./bin`) is: @@ -38,7 +33,6 @@ A possible workaround (which puts executable scripts in `~/Library/Python/. ## `site-packages` and the `PYTHONPATH` - The `site-packages` is a directory that contains Python modules (especially bindings installed by other formulae). Homebrew creates it here: $(brew --prefix)/lib/pythonX.Y/site-packages @@ -53,11 +47,9 @@ Python 2.7 also searches for modules in: Homebrew's `site-packages` directory is first created if (1) any Homebrew formula with Python bindings are installed, or (2) upon `brew install python`. ### Why here? - The reasoning for this location is to preserve your modules between (minor) upgrades or re-installations of Python. Additionally, Homebrew has a strict policy never to write stuff outside of the `brew --prefix`, so we don't spam your system. ## Homebrew-provided Python bindings - Some formulae provide python bindings. Sometimes a `--with-python` or `--with-python3` option has to be passed to `brew install` in order to build the python bindings. (Check with `brew options `.) Homebrew builds bindings against the first `python` (and `python-config`) in your `PATH`. (Check with `which python`). @@ -65,12 +57,10 @@ Homebrew builds bindings against the first `python` (and `python-config`) in you **Warning!** Python may crash (see [Common Issues](Common-Issues.md)) if you `import ` from a brewed Python if you ran `brew install ` against the system Python. If you decide to switch to the brewed Python, then reinstall all formulae with python bindings (e.g. `pyside`, `wxwidgets`, `pygtk`, `pygobject`, `opencv`, `vtk` and `boost-python`). ## Policy for non-brewed Python bindings - These should be installed via `pip install `. To discover, you can use `pip search` or . (**Note:** System Python does not provide `pip`. Follow the instructions at https://pip.readthedocs.org/en/stable/installing/#install-pip to install it for your system Python if you would like it.) ## Brewed Python modules - For brewed Python, modules installed with `pip` or `python setup.py install` will be installed to `$(brew --prefix)/lib/pythonX.Y/site-packages` directory (explained above). Executable python scripts will be in `$(brew --prefix)/bin`. The system Python may not know which compiler flags to set in order to build bindings for software installed in Homebrew so you may need to: @@ -79,7 +69,6 @@ The system Python may not know which compiler flags to set in order to build bin ## Virtualenv - **WARNING:** When you `brew install` formulae that provide Python bindings, you should **not be in an active virtual environment**. Activate the virtualenv *after* you've brewed, or brew in a fresh Terminal window. @@ -88,5 +77,4 @@ Homebrew will still install Python modules into Homebrew's `site-packages` and * Virtualenv has a switch to allow "global" (i.e. Homebrew's) `site-packages` to be accessible from within the virtualenv. ## Why is Homebrew's Python being installed as a dependency? - Formulae that depend on the special :python target are bottled against the Homebrew Python and require it to be installed. You can avoid installing Homebrew's Python by building these formulae with `--build-from-source`. diff --git a/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md b/docs/How-To-Open-a-Homebrew-Pull-Request.md similarity index 100% rename from docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md rename to docs/How-To-Open-a-Homebrew-Pull-Request.md diff --git a/docs/Installation.md b/docs/Installation.md index 15ea71b088..ff5649a722 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -3,7 +3,7 @@ The suggested and easiest way to install Homebrew is on the [homepage](http://brew.sh). The standard script installs Homebrew to `/usr/local` so that -[you don’t need sudo](FAQ.md#why-does-homebrew-say-sudo-is-bad-) when you +[you don’t need sudo](FAQ.md) when you `brew install`. It is a careful script, it can be run even if you have stuff installed to `/usr/local` already. It tells you exactly what it will do before it does it too. And you have to confirm everything it will do before it starts. @@ -12,11 +12,12 @@ it does it too. And you have to confirm everything it will do before it starts. * An Intel CPU [1](#1) * OS X 10.10 or higher [2](#2) * Command Line Tools (CLT) for Xcode: `xcode-select --install`, - https://developer.apple.com/downloads or + [developer.apple.com/downloads](https://developer.apple.com/downloads) or [Xcode](https://itunes.apple.com/us/app/xcode/id497799835) [3](#3) * A Bourne-compatible shell for installation (e.g. bash or zsh) [4](#4) ## Alternative Installs + ### Untar anywhere Just extract (or `git clone`) Homebrew wherever you want. Just avoid: diff --git a/docs/New-Maintainer-Checklist.md b/docs/New-Maintainer-Checklist.md index 8745f9b91e..b1117ce9bc 100644 --- a/docs/New-Maintainer-Checklist.md +++ b/docs/New-Maintainer-Checklist.md @@ -18,10 +18,10 @@ A few requests: non-trivial (e.g. not a test or audit improvement or version bump) changes to formulae code and don't merge them unless you get at least one approval and passing tests. -- use `brew pull` for formulae changes that require new bottles or change - multiple formulae and let it auto-close issues wherever possible (it may - take ~5m). When this isn't necessary use GitHub's "Merge pull request" - button in "create a merge commit" mode for Homebrew/brew or "squash and +- use `brew pull` for formulae changes that require new bottles or change + multiple formulae and let it auto-close issues wherever possible (it may + take ~5m). When this isn't necessary use GitHub's "Merge pull request" + button in "create a merge commit" mode for Homebrew/brew or "squash and merge" for a single formulae change. If in doubt, check with e.g. GitX that you've not accidentally added merge commits - still create your branches on your fork rather than in the main repository @@ -38,14 +38,14 @@ Thanks for all your work so far! If they accept, follow a few steps to get them set up: -- [x] Invite them to the [**@Homebrew/maintainers** team](https://github.com/orgs/Homebrew/teams/maintainers) to give them write access to all repositories (but don't make them owners yet). They will need to enable [GitHub's Two Factor Authentication](https://help.github.com/articles/about-two-factor-authentication/). -- [x] Ask them to sign in to [Bintray](https://bintray.com) using their GitHub account and they should auto-sync to [Bintray's Homebrew organisation](https://bintray.com/homebrew/organization/edit/members) as a member so they can publish new bottles -- [x] Add them to the [Jenkins' GitHub Authorization Settings admin user names](https://bot.brew.sh/configureSecurity/) so they can adjust settings and restart jobs -- [x] Add them to the [Jenkins' GitHub Pull Request Builder admin list](https://bot.brew.sh/configure) to enable `@BrewTestBot test this please` for them -- [x] Invite them to the [`homebrew-dev` private maintainers mailing list](https://groups.google.com/forum/#!managemembers/homebrew-dev/invite) -- [x] Invite them to the [`machomebrew` private maintainers Slack](https://machomebrew.slack.com/admin/invites) -- [x] Invite them to the [`homebrew` private maintainers 1Password](https://homebrew.1password.com/signin) -- [x] Add them to [Homebrew's README](https://github.com/Homebrew/brew/edit/master/README.md) +- Invite them to the [**@Homebrew/maintainers** team](https://github.com/orgs/Homebrew/teams/maintainers) to give them write access to all repositories (but don't make them owners yet). They will need to enable [GitHub's Two Factor Authentication](https://help.github.com/articles/about-two-factor-authentication/). +- Ask them to sign in to [Bintray](https://bintray.com) using their GitHub account and they should auto-sync to [Bintray's Homebrew organisation](https://bintray.com/homebrew/organization/edit/members) as a member so they can publish new bottles +- Add them to the [Jenkins' GitHub Authorization Settings admin user names](https://bot.brew.sh/configureSecurity/) so they can adjust settings and restart jobs +- Add them to the [Jenkins' GitHub Pull Request Builder admin list](https://bot.brew.sh/configure) to enable `@BrewTestBot test this please` for them +- Invite them to the [`homebrew-dev` private maintainers mailing list](https://groups.google.com/forum/#!managemembers/homebrew-dev/invite) +- Invite them to the [`machomebrew` private maintainers Slack](https://machomebrew.slack.com/admin/invites) +- Invite them to the [`homebrew` private maintainers 1Password](https://homebrew.1password.com/signin) +- Add them to [Homebrew's README](https://github.com/Homebrew/brew/edit/master/README.md) After a few weeks/months with no problems consider making them [owners on the Homebrew GitHub organisation](https://github.com/orgs/Homebrew/people). diff --git a/docs/Python-for-Formula-Authors.md b/docs/Python-for-Formula-Authors.md index 716a3b3595..93830a6c7b 100644 --- a/docs/Python-for-Formula-Authors.md +++ b/docs/Python-for-Formula-Authors.md @@ -45,6 +45,7 @@ If you submit a formula with this syntax to core, you may be asked to rewrite it ## Python declarations Applications that are compatible with Python 2 **should** use the Apple-provided system Python in /usr/bin on systems that provide Python 2.7. To do this, declare: + ```ruby depends_on :python if MacOS.version <= :snow_leopard ``` @@ -159,6 +160,7 @@ Bindings should follow the same advice for Python module dependencies as librari ## Installing bindings If the bindings are installed by invoking a `setup.py`, do something like: + ```ruby cd "source/python" do system "python", *Language::Python.setup_install_args(prefix) diff --git a/docs/Querying-Brew.md b/docs/Querying-Brew.md index 84a2ba4ebd..70fe6bb06e 100644 --- a/docs/Querying-Brew.md +++ b/docs/Querying-Brew.md @@ -1,4 +1,4 @@ -# Querying Brew +# Querying `brew` _In this document we will be using [jq](https://stedolan.github.io/jq/) to parse JSON, available from Homebrew using `brew install jq`._ ## Overview diff --git a/docs/README.md b/docs/README.md index ac9dbcd79d..0e3e0f0fdd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,34 +1,43 @@ -# README -Homebrew installs the stuff you need that Apple didn’t. +# Documentation -- [Install Homebrew](Installation.md) +## Users +- [Troubleshooting](Troubleshooting.md) +- [Installation](Installation.md) - [Frequently Asked Questions](FAQ.md) +- [Common Issues](Common-Issues.md) + - [Tips and Tricks](Tips-N'-Tricks.md) -- [Gems, Eggs and Perl Modules](Gems,-Eggs-and-Perl-Modules.md) -- [Homebrew and Python](Homebrew-and-Python.md) +- [Bottles (binary packages)](Bottles.md) +- [Taps (third-party repositories)](brew-tap.md) +- [Interesting Taps and Forks](Interesting-Taps-&-Forks.md) +- [Anonymous Aggregate User Behaviour Analytics](Analytics.md) -Please note: Homebrew generally works well, but when it doesn’t we’d hope you -report the bug. +- [Querying `brew`](Querying-Brew.md) +- [C++ Standard Libraries](C++-Standard-Libraries.md) +- [MD5 and SHA-1 Deprecation](Checksum_Deprecation.md) +- [Custom GCC and Cross Compilers](Custom-GCC-and-cross-compilers.md) +- [External Commands](External-Commands.md) +- [Ruby Gems, Python Eggs and Perl Modules](Gems,-Eggs-and-Perl-Modules.md) +- [Python](Homebrew-and-Python.md) +- [How To Build Software Outside Homebrew With Homebrew `keg_only` dependencies](How-to-build-software-outside-Homebrew-with-Homebrew-keg-only-dependencies.md) +- [Xcode](Xcode.md) +- [Kickstarter Supporters](Kickstarter-Supporters.md) -## Troubleshooting -First, please run `brew update` (twice) and `brew doctor`. +## Contributors +- [How To Open A Pull Request (and get it merged)](How-To-Open-a-Homebrew-Pull-Request.md) +- [Formula Cookbook](Formula-Cookbook.md) +- [Acceptable Formulae](Acceptable-Formulae.md) +- [Node for Formula Authors](Node-for-Formula-Authors.md) +- [Python for Formula Authors](Python-for-Formula-Authors.md) +- [Migrating A Formula To A Tap](Migrating-A-Formula-To-A-Tap.md) +- [Rename A Formula](Rename-A-Formula.md) +- [How To Create (And Maintain) A Tap](How-to-Create-and-Maintain-a-Tap.md) +- [Brew Test Bot](Brew-Test-Bot.md) +- [Prose Style Guidelines](Prose-Style-Guidelines.md) -Second, please read the [Troubleshooting Checklist](Troubleshooting.md). - -**If you don’t follow these steps it will take us far longer to help you with -your problem.** - -However! Fixing build issues is easier than you think: try -`brew edit $FORMULA` and see how you fare. - -## Contributing -Read [CONTRIBUTING.md](/CONTRIBUTING.md). - -### Community Forums -- [@MacHomebrew](https://twitter.com/MacHomebrew) -- [homebrew-discuss@googlegroups.com](mailto:homebrew-discuss@googlegroups.com) ([archive](https://groups.google.com/forum/#!forum/homebrew-discuss)) - subscribe by sending a mail to [homebrew-discuss+subscribe@googlegroups.com](mailto:homebrew-discuss+subscribe@googlegroups.com) -- [freenode.net\#machomebrew](irc://irc.freenode.net/#machomebrew) - -## Supporters -[A list of the awesome people who gave £5 or more to our -Kickstarter](./Kickstarter-Supporters.md). +## Maintainers +- [New Maintainer Checklist](New-Maintainer-Checklist.md) +- [Maintainers Avoiding Burnout](Maintainers-Avoiding-Burnout.md) +- [Maintainer Guidelines](Maintainer-Guidelines.md) +- [Brew Test Bot For Maintainers](Brew-Test-Bot-For-Core-Contributors.md) +- [Common Issues for Maintainers](Common-Issues-for-Core-Contributors.md) diff --git a/docs/Tips-N'-Tricks.md b/docs/Tips-N'-Tricks.md index 3adf26b87a..3e14158d46 100644 --- a/docs/Tips-N'-Tricks.md +++ b/docs/Tips-N'-Tricks.md @@ -1,4 +1,4 @@ -# Tips N' Tricks +# Tips and Tricks ## Installing previous versions of formulae @@ -7,16 +7,14 @@ some formulae is to see if there is a versions formula like e.g. `gcc@6` availab pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)! ### Installing directly from pull-requests - -You can browse pull requests https://github.com/Homebrew/homebrew-core/pulls -and install through the direct link. For example Python 3.3.0 pull request https://github.com/Homebrew/homebrew/pull/15199 +You can [browse pull requests](https://github.com/Homebrew/homebrew-core/pulls) +and install through the direct link. For example Python 3.3.0 pull request [Homebrew/homebrew#15199](https://github.com/Homebrew/homebrew/pull/15199) ```sh brew install https://raw.github.com/dsr/homebrew/9b22d42f50fcbc5e52c764448b3ac002bc153bd7/Library/Formula/python3.rb ``` ## Quickly remove something from /usr/local - ```sh brew unlink $FORMULA ``` @@ -26,7 +24,6 @@ This can be useful if a package can't build against the version of something you And of course, you can simply `brew link $FORMULA` again afterwards! ## Activate a previously installed version of a formula - ```sh brew info $FORMULA brew switch $FORMULA $VERSION @@ -35,21 +32,18 @@ brew switch $FORMULA $VERSION Use `brew info $FORMULA` to check what versions are installed but not currently activated, then `brew switch $FORMULA $VERSION` to activate the desired version. This can be useful if you would like to switch between versions of a formula. ## Install into Homebrew without formulae - ```sh ./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo ``` ## Pre-downloading a file for a formula - Sometimes it's faster to download a file via means other than those strategies that are available as part of Homebrew. For example, Erlang provides a torrent that'll let you download at 4–5× the normal HTTP method. Download the file and drop it in `~/Library/Caches/Homebrew`, but -watch the file name. Homebrew downloads files as {{ formula -name }}-{{ version }}. In the case of Erlang, this requires +watch the file name. Homebrew downloads files as ${FORMULA_NAME}-${VERSION}. In the case of Erlang, this requires renaming the file from otp_src_R13B03 to erlang-R13B03. @@ -60,7 +54,6 @@ run `mv the_tarball $(brew --cache -s $FORMULA)`. You can also pre-cache the download by using the command `brew fetch formula` which also displays the SHA256 value. This can be useful for updating formulae to new versions. ## Using Homebrew behind a proxy - Behind the scenes, Homebrew uses several commands for downloading files (e.g. curl, git, svn). Many of these tools can download via a proxy. It's a common (though not universal) convention for these command-line tools to observe getting the proxy parameters from environment variables (e.g. `http_proxy`). Unfortunately, most tools are inconsistent in their use of these environment parameters (e.g. curl supports `http_proxy`, `HTTPS_PROXY`, `FTP_PROXY`, `GOPHER_PROXY`, `ALL_PROXY`, `NO_PROXY`). Luckily, for the majority of cases setting `http_proxy` is enough. @@ -72,13 +65,11 @@ http_proxy=http://: brew install $FORMULA ``` ### Proxy Authentication - ```sh http_proxy=http://:@: brew install $FORMULA ``` ## Installing stuff without the Xcode-CLT - ```sh $ brew sh # or: eval $(brew --env) $ gem install ronn # or c-programs @@ -87,13 +78,11 @@ $ gem install ronn # or c-programs This imports the brew environment into your existing shell, gem will pick up the environment variables and be able to build. As a bonus brew's automatically determined optimization flags are set. ## Install only a formula's dependencies (not the formula) - ```sh brew install --only-dependencies $FORMULA ``` ## Interactive Homebrew Shell - ```sh $ brew irb 1.8.7 :001 > Formula.factory("ace").methods - Object.methods @@ -102,7 +91,6 @@ $ brew irb ``` ## Hiding the beer mug emoji when finishing a build - ```sh export HOMEBREW_NO_EMOJI=1 ``` @@ -125,12 +113,10 @@ In Sublime Text 2/3, you can use Package Control to install which adds highlighting for inline patches. ### Vim - [brew.vim](https://github.com/xu-cheng/brew.vim) adds highlighting to inline patches in Vim. ### Emacs - [homebrew-mode](https://github.com/dunn/homebrew-mode) provides syntax highlighting for inline patches as well as a number of helper functions for editing formula files. @@ -139,7 +125,6 @@ for editing formula files. for emacs shell-mode and eshell-mode. ### Atom - [language-homebrew-formula](https://atom.io/packages/language-homebrew-formula) adds highlighting and diff support (with the [language-diff](https://atom.io/packages/language-diff) plugin). diff --git a/docs/Xcode.md b/docs/Xcode.md index 7697a9c550..025cee9d7f 100644 --- a/docs/Xcode.md +++ b/docs/Xcode.md @@ -1,71 +1,71 @@ # Xcode + ## Supported Xcode Versions Homebrew supports and recommends the latest Xcode and/or Command Line Tools available for your platform: - macOS | Xcode | Command Line Tools - ----- | ----- | ---------------------------- - 10.6 | 3.2.6 | N/A - 10.7 | 4.6.3 | April 2013 - 10.8 | 5.1.1 | April 2014 - 10.9 | 6.2 | 6.2 - 10.10 | 7.2.1 | 7.2 - 10.11 | 8.0 | 7.3 - 10.12 | 8.0 | 8.0 - +| macOS | Xcode | Command Line Tools | +|-------|-------|--------------------| +| 10.6 | 3.2.6 | N/A | +| 10.7 | 4.6.3 | April 2013 | +| 10.8 | 5.1.1 | April 2014 | +| 10.9 | 6.2 | 6.2 | +| 10.10 | 7.2.1 | 7.2 | +| 10.11 | 8.0 | 7.3 | +| 10.12 | 8.0 | 8.0 | ## Compiler Version Database - Xcode | GCC 4.0 | GCC 4.2 | LLVM-GCC 4.2 | LLVM | Clang | LLVM (SVN) - --------- | ----------- | ----------- | ---------------- | ----------- | --------------- | ---------- - 2.5.0 | 5370 | — | — | — | — | — - 3.1.4 | 5493 | 5577 | 5555 | 2064.3 | — | — - 3.2.0 | 5493 | 5646 | 5646 | 2118 | — | — - 3.2.1 | 5493 | 5646 | 5646 | 2206 | — | — - 3.2.2 | 5493 | 5659 | 5646 | 2207.5 | 1.0.2 | — - 3.2.3 | 5494 | 5664 | 5658 | 2326.10 | 1.5 (60) | — - 3.2.4 | 5494 | 5664 | 5658 | 2326.10 | 1.5 (60) | — - 3.2.5 | 5494 | 5664 | 5658 | 2333.4 | 1.6 (70) | — - 3.2.6 | 5494 | 5666 | 5658 | 2335.6 | 1.7 (77) | 2.9 - 4.0.0 | 5494 | 5666 | 5658 | 2335.9 | 2.0 (137) | 2.9 - 4.0.2 | 5494 | 5666 | 5658 | 2335.9 | 2.0 (137) | 2.9 - 4.1.0 | — | 5666 | 5658 | 2335.15.00 | 2.1 (163.7.1) | 3.0 - 4.2.0 | — | — | 5658 | 2336.1.00 | 3.0 (211.10.1) | 3.0 - 4.3.0 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.45) | 3.1 - 4.3.1 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.54) | 3.1 - 4.3.2 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.58) | 3.1 - 4.3.3 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.61) | 3.1 - 4.4.0 | — | — | 5658 | 2336.11.00 | 4.0 (421.0.57) | 3.1 - 4.4.1 | — | — | 5658 | 2336.11.00 | 4.0 (421.0.60) | 3.1 - 4.5.0 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.65) | 3.1 - 4.5.1 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.66) | 3.1 - 4.5.2 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.66) | 3.1 - 4.6.0 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.24) | 3.2 - 4.6.1 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.27) | 3.2 - 4.6.2 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.28) | 3.2 - 4.6.3 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.28) | 3.2 - 5.0.0 | — | — | — | — | 5.0 (500.2.76) | 3.3 - 5.0.1 | — | — | — | — | 5.0 (500.2.78) | 3.3 - 5.0.1 | — | — | — | — | 5.0 (500.2.79) | 3.3 - 5.1 | — | — | — | — | 5.1 (503.0.38) | 3.4 - 5.1.1 | — | — | — | — | 5.1 (503.0.40) | 3.4 - 6.0 | — | — | — | — | 6.0 (600.0.51) | 3.5 - 6.0.1 | — | — | — | — | 6.0 (600.0.51) | 3.5 - 6.1 | — | — | — | — | 6.0 (600.0.54) | 3.5 - 6.2 | — | — | — | — | 6.0 (600.0.57) | 3.5 - 6.3 | — | — | — | — | 6.1 (602.0.49) | 3.6 - 6.3.1 | — | — | — | — | 6.1 (602.0.49) | 3.6 - 6.3.2 | — | — | — | — | 6.1 (602.0.53) | 3.6 - 6.4 | — | — | — | — | 6.1 (602.0.53) | 3.6 - 7.0 | — | — | — | — | 7.0 (700.0.72) | - - 7.0.1 | — | — | — | — | 7.0 (700.0.72) | - - 7.1 | — | — | — | — | 7.0 (700.1.76) | - - 7.1.1 | — | — | — | — | 7.0 (700.1.76) | - - 7.2 | — | — | — | — | 7.0 (700.1.81) | - - 7.2.1 | — | — | — | — | 7.0 (700.1.81) | - - 7.3 | — | — | — | — | 7.3 (703.0.29) | - - 7.3.1 | — | — | — | — | 7.3 (703.0.31) | - - 8.0 | — | — | — | — | 8.0 (800.0.38) | - + | Xcode | GCC 4.0 | GCC 4.2 | LLVM-GCC 4.2 | LLVM | Clang | LLVM (SVN) | + |-------|---------|---------|--------------|------------|-----------------|------------| + | 2.5.0 | 5370 | — | — | — | — | — | + | 3.1.4 | 5493 | 5577 | 5555 | 2064.3 | — | — | + | 3.2.0 | 5493 | 5646 | 5646 | 2118 | — | — | + | 3.2.1 | 5493 | 5646 | 5646 | 2206 | — | — | + | 3.2.2 | 5493 | 5659 | 5646 | 2207.5 | 1.0.2 | — | + | 3.2.3 | 5494 | 5664 | 5658 | 2326.10 | 1.5 (60) | — | + | 3.2.4 | 5494 | 5664 | 5658 | 2326.10 | 1.5 (60) | — | + | 3.2.5 | 5494 | 5664 | 5658 | 2333.4 | 1.6 (70) | — | + | 3.2.6 | 5494 | 5666 | 5658 | 2335.6 | 1.7 (77) | 2.9 | + | 4.0.0 | 5494 | 5666 | 5658 | 2335.9 | 2.0 (137) | 2.9 | + | 4.0.2 | 5494 | 5666 | 5658 | 2335.9 | 2.0 (137) | 2.9 | + | 4.1.0 | — | 5666 | 5658 | 2335.15.00 | 2.1 (163.7.1) | 3.0 | + | 4.2.0 | — | — | 5658 | 2336.1.00 | 3.0 (211.10.1) | 3.0 | + | 4.3.0 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.45) | 3.1 | + | 4.3.1 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.54) | 3.1 | + | 4.3.2 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.58) | 3.1 | + | 4.3.3 | — | — | 5658 | 2336.9.00 | 3.1 (318.0.61) | 3.1 | + | 4.4.0 | — | — | 5658 | 2336.11.00 | 4.0 (421.0.57) | 3.1 | + | 4.4.1 | — | — | 5658 | 2336.11.00 | 4.0 (421.0.60) | 3.1 | + | 4.5.0 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.65) | 3.1 | + | 4.5.1 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.66) | 3.1 | + | 4.5.2 | — | — | 5658 | 2336.11.00 | 4.1 (421.11.66) | 3.1 | + | 4.6.0 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.24) | 3.2 | + | 4.6.1 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.27) | 3.2 | + | 4.6.2 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.28) | 3.2 | + | 4.6.3 | — | — | 5658 | 2336.11.00 | 4.2 (425.0.28) | 3.2 | + | 5.0.0 | — | — | — | — | 5.0 (500.2.76) | 3.3 | + | 5.0.1 | — | — | — | — | 5.0 (500.2.78) | 3.3 | + | 5.0.1 | — | — | — | — | 5.0 (500.2.79) | 3.3 | + | 5.1 | — | — | — | — | 5.1 (503.0.38) | 3.4 | + | 5.1.1 | — | — | — | — | 5.1 (503.0.40) | 3.4 | + | 6.0 | — | — | — | — | 6.0 (600.0.51) | 3.5 | + | 6.0.1 | — | — | — | — | 6.0 (600.0.51) | 3.5 | + | 6.1 | — | — | — | — | 6.0 (600.0.54) | 3.5 | + | 6.2 | — | — | — | — | 6.0 (600.0.57) | 3.5 | + | 6.3 | — | — | — | — | 6.1 (602.0.49) | 3.6 | + | 6.3.1 | — | — | — | — | 6.1 (602.0.49) | 3.6 | + | 6.3.2 | — | — | — | — | 6.1 (602.0.53) | 3.6 | + | 6.4 | — | — | — | — | 6.1 (602.0.53) | 3.6 | + | 7.0 | — | — | — | — | 7.0 (700.0.72) | - | + | 7.0.1 | — | — | — | — | 7.0 (700.0.72) | - | + | 7.1 | — | — | — | — | 7.0 (700.1.76) | - | + | 7.1.1 | — | — | — | — | 7.0 (700.1.76) | - | + | 7.2 | — | — | — | — | 7.0 (700.1.81) | - | + | 7.2.1 | — | — | — | — | 7.0 (700.1.81) | - | + | 7.3 | — | — | — | — | 7.3 (703.0.29) | - | + | 7.3.1 | — | — | — | — | 7.3 (703.0.31) | - | + | 8.0 | — | — | — | — | 8.0 (800.0.38) | - | ## References to Xcode and compiler versions in code When a new Xcode release is made, the following things need to be diff --git a/docs/_config.yml b/docs/_config.yml index c4192631f2..687739b4ad 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1,2 @@ -theme: jekyll-theme-cayman \ No newline at end of file +theme: jekyll-theme-cayman +exclude: [bin, vendor, CNAME, Gemfile, Gemfile.lock] diff --git a/docs/brew-tap.md b/docs/brew-tap.md index 624a83f33b..f73f1813e8 100644 --- a/docs/brew-tap.md +++ b/docs/brew-tap.md @@ -1,10 +1,9 @@ -# brew tap - +# Taps (third-party repositories) `brew tap` adds more repos to the list of formulae that `brew` tracks, updates, and installs from. By default, `tap` assumes that the repos come from GitHub, but the command isn't limited to any one location. -## The command +## The command (`brew tap`) * `brew tap` without arguments lists the currently tapped repositories. For example: diff --git a/docs/brew.1.html b/docs/brew.1.html index d69c141bba..e3a44ec87d 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -780,9 +780,9 @@ your shell profile, or you can use it before a brew command:

Homebrew's lead maintainer is Mike McQuaid.

-

Homebrew's current maintainers are Misty De Meo, Andrew Janke, Xu Cheng, Tomasz Pajor, Josh Hagins, Baptiste Fontaine, Markus Reiter, ilovezfs, Martin Afanasjew, Tom Schoonjans, Uladzislau Shablinski, Tim Smith and Alex Dunn.

+

Homebrew's current maintainers are Misty De Meo, Andrew Janke, Xu Cheng, Tomasz Pajor, Josh Hagins, Baptiste Fontaine, Markus Reiter, ilovezfs, Tom Schoonjans, Uladzislau Shablinski, Tim Smith and Alex Dunn.

-

Former maintainers with significant contributions include Dominyk Tiller, Brett Koonce, Jack Nagel, Adam Vandenberg and Homebrew's creator: Max Howell.

+

Former maintainers with significant contributions include Martin Afanasjew, Dominyk Tiller, Brett Koonce, Jack Nagel, Adam Vandenberg and Homebrew's creator: Max Howell.

BUGS

diff --git a/manpages/brew.1 b/manpages/brew.1 index 38dce5cfdd..e60972c18e 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1046,10 +1046,10 @@ Homebrew Documentation: \fIhttps://github\.com/Homebrew/brew/blob/master/docs/\f Homebrew\'s lead maintainer is Mike McQuaid\. . .P -Homebrew\'s current maintainers are Misty De Meo, Andrew Janke, Xu Cheng, Tomasz Pajor, Josh Hagins, Baptiste Fontaine, Markus Reiter, ilovezfs, Martin Afanasjew, Tom Schoonjans, Uladzislau Shablinski, Tim Smith and Alex Dunn\. +Homebrew\'s current maintainers are Misty De Meo, Andrew Janke, Xu Cheng, Tomasz Pajor, Josh Hagins, Baptiste Fontaine, Markus Reiter, ilovezfs, Tom Schoonjans, Uladzislau Shablinski, Tim Smith and Alex Dunn\. . .P -Former maintainers with significant contributions include Dominyk Tiller, Brett Koonce, Jack Nagel, Adam Vandenberg and Homebrew\'s creator: Max Howell\. +Former maintainers with significant contributions include Martin Afanasjew, Dominyk Tiller, Brett Koonce, Jack Nagel, Adam Vandenberg and Homebrew\'s creator: Max Howell\. . .SH "BUGS" See our issues on GitHub: From a3bffe70bcf33e6051140b1a93c9f48714605af6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 4 Jan 2017 11:13:41 +0000 Subject: [PATCH 076/176] Use docs.brew.sh links. --- CONTRIBUTING.md | 2 +- Library/Homebrew/README.md | 2 +- Library/Homebrew/cmd/analytics.rb | 2 +- Library/Homebrew/cmd/help.rb | 2 +- Library/Homebrew/cmd/info.rb | 2 +- Library/Homebrew/cmd/tap-info.rb | 2 +- Library/Homebrew/cmd/update-report.rb | 2 +- Library/Homebrew/dev-cmd/create.rb | 2 +- Library/Homebrew/formula.rb | 4 ++-- Library/Homebrew/manpages/brew.1.md.erb | 4 ++-- Library/Homebrew/os.rb | 2 +- Library/Homebrew/utils/analytics.rb | 2 +- Library/Homebrew/utils/analytics.sh | 2 +- README.md | 6 +++--- docs/Formula-Cookbook.md | 2 +- docs/Tips-N'-Tricks.md | 3 +-- docs/brew.1.html | 10 +++++----- manpages/brew.1 | 10 +++++----- 18 files changed, 30 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a2924fce1c..2875818caf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ First time contributing to Homebrew? Read our [Code of Conduct](https://github.c * run `brew update` (twice) * run and read `brew doctor` -* read [the Troubleshooting Checklist](https://github.com/Homebrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting) +* read [the Troubleshooting Checklist](http://docs.brew.sh/Troubleshooting.html) * open an issue on the formula's repository or on Homebrew/brew if it's not a formula-specific issue ### Propose a feature diff --git a/Library/Homebrew/README.md b/Library/Homebrew/README.md index b8bf5fd998..18a41e3636 100644 --- a/Library/Homebrew/README.md +++ b/Library/Homebrew/README.md @@ -3,6 +3,6 @@ This is the (partially) documented public API for Homebrew. The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private. -You may also find the [Formula Cookbook](https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md) and [Ruby Style Guide](https://github.com/styleguide/ruby) helpful in creating formulae. +You may also find the [Formula Cookbook](http://docs.brew.sh/Formula-Cookbook.html) and [Ruby Style Guide](https://github.com/styleguide/ruby) helpful in creating formulae. Good luck! diff --git a/Library/Homebrew/cmd/analytics.rb b/Library/Homebrew/cmd/analytics.rb index 2efa5a2d23..8a67a54a4c 100644 --- a/Library/Homebrew/cmd/analytics.rb +++ b/Library/Homebrew/cmd/analytics.rb @@ -1,6 +1,6 @@ #: * `analytics` [`state`]: #: Display anonymous user behaviour analytics state. -#: Read more at . +#: Read more at . #: #: * `analytics` (`on`|`off`): #: Turn on/off Homebrew's analytics. diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index 982e249655..1378e7b1f7 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -16,7 +16,7 @@ Troubleshooting: Developers: brew create [URL [--no-fetch]] brew edit [FORMULA...] - https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md + http://docs.brew.sh/Formula-Cookbook.html Further help: man brew diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index fc47e1731c..1850ae003e 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -14,7 +14,7 @@ #: information on all installed formulae. #: #: See the docs for examples of using the JSON: -#: +#: require "blacklist" require "caveats" diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb index 0d9f8db3d9..b46de30c12 100644 --- a/Library/Homebrew/cmd/tap-info.rb +++ b/Library/Homebrew/cmd/tap-info.rb @@ -13,7 +13,7 @@ #: Pass `--installed` to get information on installed taps. #: #: See the docs for examples of using the JSON: -#: +#: require "tap" diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 7865701969..dcf2891d90 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -35,7 +35,7 @@ module Homebrew ohai "Homebrew has enabled anonymous aggregate user behaviour analytics." puts <<-EOS.undent #{Tty.bold}Read the analytics documentation (and how to opt-out) here: - #{Formatter.url("https://git.io/brew-analytics")}#{Tty.reset} + #{Formatter.url("http://docs.brew.sh/Analytics.html")}#{Tty.reset} EOS diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index da855e3826..07dd1b3224 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -159,7 +159,7 @@ class FormulaCreator end def template; <<-EOS.undent - # Documentation: https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md + # Documentation: http://docs.brew.sh/Formula-Cookbook.html # http://www.rubydoc.info/github/Homebrew/brew/master/Formula # PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST! diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eb85f804f0..89c10b89a9 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -26,7 +26,7 @@ require "migrator" # @see SharedEnvExtension # @see FileUtils # @see Pathname -# @see https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md Formula Cookbook +# @see http://docs.brew.sh/Formula-Cookbook.html Formula Cookbook # @see https://github.com/styleguide/ruby Ruby Style Guide # #
class Wget < Formula
@@ -2059,7 +2059,7 @@ class Formula
     # and you haven't passed or previously used any options on this formula.
     #
     # If you maintain your own repository, you can add your own bottle links.
-    # https://github.com/Homebrew/brew/blob/master/docs/Bottles.md
+    # http://docs.brew.sh/Bottles.html
     # You can ignore this block entirely if submitting to Homebrew/Homebrew, It'll be
     # handled for you by the Brew Test Bot.
     #
diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb
index 7412d0a69d..2266f3e7ad 100644
--- a/Library/Homebrew/manpages/brew.1.md.erb
+++ b/Library/Homebrew/manpages/brew.1.md.erb
@@ -76,7 +76,7 @@ scripts that reside somewhere in the `PATH`, named `brew-` 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
 
@@ -197,7 +197,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/Library/Homebrew/os.rb b/Library/Homebrew/os.rb
index f6fe1eb811..dae8434070 100644
--- a/Library/Homebrew/os.rb
+++ b/Library/Homebrew/os.rb
@@ -15,7 +15,7 @@ module OS
     require "os/mac"
     # Don't tell people to report issues on unsupported versions of macOS.
     if !OS::Mac.prerelease? && !OS::Mac.outdated_release?
-      ISSUES_URL = "https://git.io/brew-troubleshooting".freeze
+      ISSUES_URL = "http://docs.brew.sh/Troubleshooting.html".freeze
     end
     PATH_OPEN = "/usr/bin/open".freeze
     # compatibility
diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb
index cc7ad54d27..7dd54d3f14 100644
--- a/Library/Homebrew/utils/analytics.rb
+++ b/Library/Homebrew/utils/analytics.rb
@@ -35,7 +35,7 @@ module Utils
         end
 
         # Send analytics. Don't send or store any personally identifiable information.
-        # https://github.com/Homebrew/brew/blob/master/docs/Analytics.md
+        # http://docs.brew.sh/Analytics.html
         # https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
         # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
         if ENV["HOMEBREW_ANALYTICS_DEBUG"]
diff --git a/Library/Homebrew/utils/analytics.sh b/Library/Homebrew/utils/analytics.sh
index 0f188fe9b1..35f91eabc0 100644
--- a/Library/Homebrew/utils/analytics.sh
+++ b/Library/Homebrew/utils/analytics.sh
@@ -107,7 +107,7 @@ report-analytics-screenview-command() {
   )
 
   # Send analytics. Don't send or store any personally identifiable information.
-  # https://github.com/Homebrew/brew/blob/master/docs/Analytics.md
+  # http://docs.brew.sh/Analytics.html
   # https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#screenView
   # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
   if [[ -z "$HOMEBREW_ANALYTICS_DEBUG" ]]
diff --git a/README.md b/README.md
index a3d613ce98..940b49878f 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ cd "$(brew --repo)" && git fetch && git reset --hard origin/master && brew updat
 ## Troubleshooting
 First, please run `brew update` and `brew doctor`.
 
-Second, read the [Troubleshooting Checklist](https://github.com/Homebrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting).
+Second, read the [Troubleshooting Checklist](http://docs.brew.sh/Troubleshooting.html).
 
 **If you don't read these it will take us far longer to help you with your problem.**
 
@@ -27,7 +27,7 @@ We'd love you to contribute to Homebrew. First, please read our [Contribution Gu
 
 We explicitly welcome contributions from people who have never contributed to open-source before: we were all beginners once! We can help build on a partially working pull request with the aim of getting it merged. We are also actively seeking to diversify our contributors and especially welcome contributions from women from all backgrounds and people of colour.
 
-A good starting point for contributing is running `brew audit` (or `brew audit --strict`) with some of the packages you use (e.g. `brew audit wget` if you use `wget`) and then read through the warnings, try to fix them until `brew audit` shows no results and [submit a pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md). If no formulae you use have warnings you can run `brew audit` without arguments to have it run on all packages and pick one. Good luck!
+A good starting point for contributing is running `brew audit` (or `brew audit --strict`) with some of the packages you use (e.g. `brew audit wget` if you use `wget`) and then read through the warnings, try to fix them until `brew audit` shows no results and [submit a pull request](http://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request.html). If no formulae you use have warnings you can run `brew audit` without arguments to have it run on all packages and pick one. Good luck!
 
 ## Security
 Please report security issues to security@brew.sh.
@@ -61,7 +61,7 @@ Please consider a regular donation through Patreon:
 [![Donate with Patreon](https://img.shields.io/badge/patreon-donate-green.svg)](https://www.patreon.com/homebrew)
 
 ## Sponsors
-Our CI infrastructure was paid for by [our Kickstarter supporters](https://github.com/Homebrew/brew/blob/master/docs/Kickstarter-Supporters.md).
+Our CI infrastructure was paid for by [our Kickstarter supporters](http://docs.brew.sh/Kickstarter-Supporters.html).
 
 Our CI infrastructure is hosted by [The Positive Internet Company](http://www.positive-internet.com).
 
diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md
index 69a47b2111..6304d7b0e5 100644
--- a/docs/Formula-Cookbook.md
+++ b/docs/Formula-Cookbook.md
@@ -352,7 +352,7 @@ If you have already forked Homebrew on GitHub, then you can manually push (just
 git push https://github.com/myname/homebrew-core/ 
 ```
 
-Now, please [open a pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md#how-to-open-a-homebrew-pull-request-and-get-it-merged) for your changes.
+Now, please [open a pull request](http://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request.html) for your changes.
 
 *   One formula per commit; one commit per formula
 *   Keep merge commits out of the pull request
diff --git a/docs/Tips-N'-Tricks.md b/docs/Tips-N'-Tricks.md
index 3e14158d46..8f67c9ca84 100644
--- a/docs/Tips-N'-Tricks.md
+++ b/docs/Tips-N'-Tricks.md
@@ -3,8 +3,7 @@
 ## Installing previous versions of formulae
 
 The supported method of installing specific versions of
-some formulae is to see if there is a versions formula like e.g. `gcc@6` available. If the version you’re looking for isn’t available, consider [opening a
-pull request](https://github.com/Homebrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request-(and-get-it-merged).md)!
+some formulae is to see if there is a versions formula like e.g. `gcc@6` available. If the version you’re looking for isn’t available, consider [opening a pull request](How-To-Open-a-Homebrew-Pull-Request.md)!
 
 ### Installing directly from pull-requests
 You can [browse pull requests](https://github.com/Homebrew/homebrew-core/pulls)
diff --git a/docs/brew.1.html b/docs/brew.1.html
index e3a44ec87d..8c81b1ddb0 100644
--- a/docs/brew.1.html
+++ b/docs/brew.1.html
@@ -36,7 +36,7 @@ If no search term is given, all locally available formulae are listed.

analytics [state]

Display anonymous user behaviour analytics state. -Read more at https://git.io/brew-analytics.

+Read more at http://docs.brew.sh/Analytics.html.

analytics (on|off)

Turn on/off Homebrew's analytics.

analytics regenerate-uuid

Regenerate UUID used in Homebrew's analytics.

cat formula

Display the source to formula.

@@ -152,7 +152,7 @@ for version is v1.

information on all installed formulae.

See the docs for examples of using the JSON: -https://github.com/Homebrew/brew/blob/master/docs/Querying-Brew.md

+http://docs.brew.sh/Querying-Brew.html

install [--debug] [--env=std|super] [--ignore-dependencies] [--only-dependencies] [--cc=compiler] [--build-from-source] [--devel|--HEAD] [--keep-tmp] formula

Install formula.

formula is usually the name of the formula to install, but it can be specified @@ -352,7 +352,7 @@ for version is v1.

Pass --installed to get information on installed taps.

See the docs for examples of using the JSON: -https://github.com/Homebrew/brew/blob/master/docs/Querying-Brew.md

+http://docs.brew.sh/Querying-Brew.html

tap-pin tap

Pin tap, prioritizing its formulae over core when formula names are supplied by the user. See also tap-unpin.

tap-unpin tap

Unpin tap so its formulae are no longer prioritized. See also tap-pin.

@@ -641,7 +641,7 @@ scripts that reside somewhere in the PATH, named brew- to create your own commands without modifying Homebrew's internals.

Instructions for creating your own commands can be found in the docs: -https://github.com/Homebrew/brew/blob/master/docs/External-Commands.md

+http://docs.brew.sh/External-Commands.html

SPECIFYING FORMULAE

@@ -720,7 +720,7 @@ Homebrew uses the GitHub API for features such as brew search.

the number of parallel jobs to run when building with make(1).

Default: the number of available CPU cores.

-
HOMEBREW_NO_ANALYTICS

If set, Homebrew will not send analytics. See: https://github.com/Homebrew/brew/blob/master/docs/Analytics.md#analytics

+
HOMEBREW_NO_ANALYTICS

If set, Homebrew will not send analytics. See: http://docs.brew.sh/Analytics.html

HOMEBREW_NO_AUTO_UPDATE

If set, Homebrew will not auto-update before running brew install, brew upgrade or brew tap.

HOMEBREW_NO_EMOJI

If set, Homebrew will not print the HOMEBREW_INSTALL_BADGE on a diff --git a/manpages/brew.1 b/manpages/brew.1 index e60972c18e..c9269e7b39 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -45,7 +45,7 @@ Perform a substring search of formula names for \fItext\fR\. If \fItext\fR is su . .TP \fBanalytics\fR [\fBstate\fR] -Display anonymous user behaviour analytics state\. Read more at \fIhttps://git\.io/brew\-analytics\fR\. +Display anonymous user behaviour analytics state\. Read more at \fIhttp://docs\.brew\.sh/Analytics\.html\fR\. . .TP \fBanalytics\fR (\fBon\fR|\fBoff\fR) @@ -213,7 +213,7 @@ Print a JSON representation of \fIformulae\fR\. Currently the only accepted valu Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to get information on all installed formulae\. . .IP -See the docs for examples of using the JSON: \fIhttps://github\.com/Homebrew/brew/blob/master/docs/Querying\-Brew\.md\fR +See the docs for examples of using the JSON: \fIhttp://docs\.brew\.sh/Querying\-Brew\.html\fR . .TP \fBinstall\fR [\fB\-\-debug\fR] [\fB\-\-env=\fR\fIstd\fR|\fIsuper\fR] [\fB\-\-ignore\-dependencies\fR] [\fB\-\-only\-dependencies\fR] [\fB\-\-cc=\fR\fIcompiler\fR] [\fB\-\-build\-from\-source\fR] [\fB\-\-devel\fR|\fB\-\-HEAD\fR] [\fB\-\-keep\-tmp\fR] \fIformula\fR @@ -479,7 +479,7 @@ Print a JSON representation of \fItaps\fR\. Currently the only accepted value fo Pass \fB\-\-installed\fR to get information on installed taps\. . .IP -See the docs for examples of using the JSON: \fIhttps://github\.com/Homebrew/brew/blob/master/docs/Querying\-Brew\.md\fR +See the docs for examples of using the JSON: \fIhttp://docs\.brew\.sh/Querying\-Brew\.html\fR . .TP \fBtap\-pin\fR \fItap\fR @@ -838,7 +838,7 @@ Integrates Homebrew formulae with macOS\'s \fBlaunchctl\fR manager: \fIhttps://g Homebrew, like \fBgit\fR(1), supports external commands\. These are executable scripts that reside somewhere in the \fBPATH\fR, named \fBbrew\-\fR\fIcmdname\fR or \fBbrew\-\fR\fIcmdname\fR\fB\.rb\fR, which can be invoked like \fBbrew\fR \fIcmdname\fR\. This allows you to create your own commands without modifying Homebrew\'s internals\. . .P -Instructions for creating your own commands can be found in the docs: \fIhttps://github\.com/Homebrew/brew/blob/master/docs/External\-Commands\.md\fR +Instructions for creating your own commands can be found in the docs: \fIhttp://docs\.brew\.sh/External\-Commands\.html\fR . .SH "SPECIFYING FORMULAE" Many Homebrew commands accept one or more \fIformula\fR arguments\. These arguments can take several different forms: @@ -957,7 +957,7 @@ If set, instructs Homebrew to use the value of \fBHOMEBREW_MAKE_JOBS\fR as the n . .TP \fBHOMEBREW_NO_ANALYTICS\fR -If set, Homebrew will not send analytics\. See: \fIhttps://github\.com/Homebrew/brew/blob/master/docs/Analytics\.md#analytics\fR +If set, Homebrew will not send analytics\. See: \fIhttp://docs\.brew\.sh/Analytics\.html\fR . .TP \fBHOMEBREW_NO_AUTO_UPDATE\fR From 6195d6592b7374e135440025c82ae19cf37f30af Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 4 Jan 2017 10:23:15 -0800 Subject: [PATCH 077/176] formula: realpath prefix before computing abv versioned prefix is a directory, but unversioned is a symlink, so realpath it before computing abv --- Library/Homebrew/formula.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eb85f804f0..dcee0de85c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -553,7 +553,7 @@ class Formula # called from within the same formula's {#install} or {#post_install} methods. # Otherwise, return the full path to the formula's versioned cellar. def prefix(v = pkg_version) - prefix = rack/v + prefix = FormulaPrefixPathname.new(rack/v) if !@versioned_prefix && prefix.directory? && Keg.new(prefix).optlinked? opt_prefix else @@ -938,7 +938,7 @@ class Formula # formula, as the path is stable even when the software is updated. #

args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline"
def opt_prefix - Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}") + FormulaPrefixPathname.new("#{HOMEBREW_PREFIX}/opt/#{name}") end def opt_bin @@ -2423,4 +2423,10 @@ class Formula @link_overwrite_paths ||= Set.new end end + + class FormulaPrefixPathname < Pathname + def abv + Pathname.new(realpath).abv + end + end end From a68d38743abc2351a9468dcec70174fdfe38cf94 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 4 Jan 2017 10:27:39 -0800 Subject: [PATCH 078/176] formula: make prefix_linked? use versioned prefix otherwise whenever prefix is unversioned, prefix_Linked will be false --- Library/Homebrew/formula.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index dcee0de85c..cad8a693fd 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -574,7 +574,10 @@ class Formula # Is formula's linked keg points to the prefix. def prefix_linked?(v = pkg_version) return false unless linked? - linked_keg.resolved_path == prefix(v) + @versioned_prefix = true + result = linked_keg.resolved_path == prefix(v) + @versioned_prefix = false + result end # {PkgVersion} of the linked keg for the formula. From 9a6cd9b83fc8596727df0157e89faee302907cda Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Wed, 4 Jan 2017 16:16:00 -0600 Subject: [PATCH 079/176] docs: fix titles on docs.brew.sh --- docs/Acceptable-Formulae.md | 1 + docs/Analytics.md | 1 + docs/Bottles.md | 1 + docs/Brew-Test-Bot-For-Core-Contributors.md | 1 + docs/Brew-Test-Bot.md | 1 + docs/C++-Standard-Libraries.md | 1 + docs/Checksum_Deprecation.md | 1 + docs/Common-Issues.md | 1 + docs/Custom-GCC-and-cross-compilers.md | 1 + docs/External-Commands.md | 1 + docs/Formula-Cookbook.md | 1 + docs/Gems,-Eggs-and-Perl-Modules.md | 1 + docs/Homebrew-and-Python.md | 1 + docs/How-to-Create-and-Maintain-a-Tap.md | 1 + docs/Installation.md | 1 + docs/Interesting-Taps-&-Forks.md | 1 + docs/Kickstarter-Supporters.md | 1 + docs/Maintainer-Guidelines.md | 1 + docs/Maintainers-Avoiding-Burnout.md | 1 + docs/Migrating-A-Formula-To-A-Tap.md | 1 + docs/New-Maintainer-Checklist.md | 1 + docs/Querying-Brew.md | 1 + docs/Versions.md | 1 + docs/brew-tap.md | 1 + 24 files changed, 24 insertions(+) diff --git a/docs/Acceptable-Formulae.md b/docs/Acceptable-Formulae.md index 12084fad76..9f4fb45dba 100644 --- a/docs/Acceptable-Formulae.md +++ b/docs/Acceptable-Formulae.md @@ -1,4 +1,5 @@ # Acceptable Formulae + Some formulae should not go in [homebrew/core](https://github.com/Homebrew/homebrew-core). But there are additional [Interesting Taps & Forks](Interesting-Taps-&-Forks.md) and anyone can start their diff --git a/docs/Analytics.md b/docs/Analytics.md index 80515d0799..b4e73f75df 100644 --- a/docs/Analytics.md +++ b/docs/Analytics.md @@ -1,4 +1,5 @@ # Anonymous Aggregate User Behaviour Analytics + Homebrew has begun gathering anonymous aggregate user behaviour analytics and reporting these to Google Analytics. You will be notified the first time you run `brew update` or install Homebrew. ## Why? diff --git a/docs/Bottles.md b/docs/Bottles.md index 7d2982c142..2752ebe032 100644 --- a/docs/Bottles.md +++ b/docs/Bottles.md @@ -1,4 +1,5 @@ # Bottles (binary packages) + Bottles are produced by installing a formula with `brew install --build-bottle $FORMULA` and then bottling it with `brew bottle $FORMULA`. This outputs the bottle DSL which should be inserted into the formula file. ## Usage diff --git a/docs/Brew-Test-Bot-For-Core-Contributors.md b/docs/Brew-Test-Bot-For-Core-Contributors.md index 4b697066c4..f4c9a0ec6e 100644 --- a/docs/Brew-Test-Bot-For-Core-Contributors.md +++ b/docs/Brew-Test-Bot-For-Core-Contributors.md @@ -1,4 +1,5 @@ # Brew Test Bot For Core Contributors + If a build has run and passed on `brew test-bot` then it can be used to quickly bottle formulae. There are two types of Jenkins jobs you will interact with: diff --git a/docs/Brew-Test-Bot.md b/docs/Brew-Test-Bot.md index 0a5f76bda9..db39327fac 100644 --- a/docs/Brew-Test-Bot.md +++ b/docs/Brew-Test-Bot.md @@ -1,4 +1,5 @@ # Brew Test Bot + `brew test-bot` is the name for the automated review and testing system funded by [our Kickstarter in 2013](https://www.kickstarter.com/projects/homebrew/brew-test-bot). diff --git a/docs/C++-Standard-Libraries.md b/docs/C++-Standard-Libraries.md index 0bb987def7..c1725f2020 100644 --- a/docs/C++-Standard-Libraries.md +++ b/docs/C++-Standard-Libraries.md @@ -1,4 +1,5 @@ # C++ Standard Libraries + There are two C++ standard libraries supported by Apple compilers. The default for 10.8 and earlier is **libstdc++**, supported by Apple GCC diff --git a/docs/Checksum_Deprecation.md b/docs/Checksum_Deprecation.md index c86f3a1a36..3ef0d41ecf 100644 --- a/docs/Checksum_Deprecation.md +++ b/docs/Checksum_Deprecation.md @@ -1,4 +1,5 @@ # MD5 and SHA-1 Deprecation + During early 2015 Homebrew started the process of deprecating _SHA1_ for package integrity verification. Since then every formulae under the Homebrew organisation has been moved onto _SHA256_ verification; this includes both source packages diff --git a/docs/Common-Issues.md b/docs/Common-Issues.md index 14f2836c41..8da622ab42 100644 --- a/docs/Common-Issues.md +++ b/docs/Common-Issues.md @@ -1,4 +1,5 @@ # Common Issues + This is a list of commonly encountered problems, known issues, and their solutions. ### `brew` complains about absence of "Command Line Tools" diff --git a/docs/Custom-GCC-and-cross-compilers.md b/docs/Custom-GCC-and-cross-compilers.md index 99b52c060b..08a8b2b194 100644 --- a/docs/Custom-GCC-and-cross-compilers.md +++ b/docs/Custom-GCC-and-cross-compilers.md @@ -1,4 +1,5 @@ # Custom GCC and Cross Compilers + Homebrew depends on having an up-to-date version of Xcode because it comes with specific versions of build tools e.g. `clang`. diff --git a/docs/External-Commands.md b/docs/External-Commands.md index b88ba3fa56..59622bd3ab 100644 --- a/docs/External-Commands.md +++ b/docs/External-Commands.md @@ -1,4 +1,5 @@ # External Commands + Homebrew, like Git, supports *external commands*. This lets you create new commands that can be run like: ```shell diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 69a47b2111..9d02a0f9a6 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -1,4 +1,5 @@ # Formula Cookbook + A formula is a package definition written in Ruby. It can be created with `brew create $URL`, installed with `brew install $FORMULA`, and debugged with `brew install --debug --verbose $FORMULA`. Formulae use the [Formula API](http://www.rubydoc.info/github/Homebrew/brew/master/Formula) which provides various Homebrew-specific helpers. ## Homebrew Terminology diff --git a/docs/Gems,-Eggs-and-Perl-Modules.md b/docs/Gems,-Eggs-and-Perl-Modules.md index dfbdc224f0..770d770f62 100644 --- a/docs/Gems,-Eggs-and-Perl-Modules.md +++ b/docs/Gems,-Eggs-and-Perl-Modules.md @@ -1,4 +1,5 @@ # Gems, Eggs and Perl Modules + On a fresh macOS installation there are three empty directories for add-ons available to all users: diff --git a/docs/Homebrew-and-Python.md b/docs/Homebrew-and-Python.md index 0757b5d244..e2f59c322e 100644 --- a/docs/Homebrew-and-Python.md +++ b/docs/Homebrew-and-Python.md @@ -1,4 +1,5 @@ # Python + This page describes how Python is handled in Homebrew for users. See [Python for Formula Authors](Python-for-Formula-Authors.md) for advice on writing formulae to install packages written in Python. Homebrew should work with any [CPython](https://stackoverflow.com/questions/2324208/is-there-any-difference-between-cpython-and-python) and defaults to the macOS system Python. diff --git a/docs/How-to-Create-and-Maintain-a-Tap.md b/docs/How-to-Create-and-Maintain-a-Tap.md index ff7de80299..5c8f3a8c42 100644 --- a/docs/How-to-Create-and-Maintain-a-Tap.md +++ b/docs/How-to-Create-and-Maintain-a-Tap.md @@ -1,4 +1,5 @@ # How to Create and Maintain a Tap + Taps are external sources of Homebrew formulae and/or external commands. They can be created by anyone to provide their own formulae and/or external commands to any Homebrew user. diff --git a/docs/Installation.md b/docs/Installation.md index ff5649a722..dbe8b9917a 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -1,4 +1,5 @@ # Installation + The suggested and easiest way to install Homebrew is on the [homepage](http://brew.sh). diff --git a/docs/Interesting-Taps-&-Forks.md b/docs/Interesting-Taps-&-Forks.md index dcb860a23c..a5c6094412 100644 --- a/docs/Interesting-Taps-&-Forks.md +++ b/docs/Interesting-Taps-&-Forks.md @@ -1,4 +1,5 @@ # Interesting Taps & Forks + A Tap is homebrew-speak for a git repository containing extra formulae. Homebrew has the capability to add (and remove) multiple taps to your local installation with the `brew tap` and `brew untap` command. Type `man brew` in your Terminal. The main repository https://github.com/Homebrew/homebrew-core, often called `homebrew/core`, is always built-in. diff --git a/docs/Kickstarter-Supporters.md b/docs/Kickstarter-Supporters.md index ae9556390f..3f39b435c0 100644 --- a/docs/Kickstarter-Supporters.md +++ b/docs/Kickstarter-Supporters.md @@ -1,4 +1,5 @@ # Kickstarter Supporters + This file contains a list of the awesome people who gave £5 or more to [our Kickstarter](https://www.kickstarter.com/projects/homebrew/brew-test-bot). diff --git a/docs/Maintainer-Guidelines.md b/docs/Maintainer-Guidelines.md index d83118642a..fdb7e88f9c 100644 --- a/docs/Maintainer-Guidelines.md +++ b/docs/Maintainer-Guidelines.md @@ -1,4 +1,5 @@ # Maintainer Guidelines + **This guide is for maintainers.** These special people have **write access** to Homebrew’s repository and help merge the contributions of others. You may find what is written here interesting, but it’s diff --git a/docs/Maintainers-Avoiding-Burnout.md b/docs/Maintainers-Avoiding-Burnout.md index f3ba3e346c..99353d946b 100644 --- a/docs/Maintainers-Avoiding-Burnout.md +++ b/docs/Maintainers-Avoiding-Burnout.md @@ -1,4 +1,5 @@ # Maintainers: Avoiding Burnout + **This guide is for maintainers.** These special people have **write access** to Homebrew’s repository and help merge the contributions of others. You may find what is written here interesting, but it’s diff --git a/docs/Migrating-A-Formula-To-A-Tap.md b/docs/Migrating-A-Formula-To-A-Tap.md index 7bc984f84a..ba55770563 100644 --- a/docs/Migrating-A-Formula-To-A-Tap.md +++ b/docs/Migrating-A-Formula-To-A-Tap.md @@ -1,4 +1,5 @@ # Migrating A Formula To A Tap + There are times when we may wish to migrate a formula from one tap into another tap. To do this: 1. Create a pull request to the new tap adding the formula file as-is from the original tap. Fix any test failures that may occur due to the stricter requirements for new formulae than existing formula (e.g. `brew audit --strict` must pass for that formula). diff --git a/docs/New-Maintainer-Checklist.md b/docs/New-Maintainer-Checklist.md index b1117ce9bc..29c2d4ece3 100644 --- a/docs/New-Maintainer-Checklist.md +++ b/docs/New-Maintainer-Checklist.md @@ -1,4 +1,5 @@ # New Maintainer Checklist + **This is a guide used by existing maintainers to invite new maintainers. You might find it interesting but there's nothing here users should have to know.** So, there's someone who has been making consistently high-quality contributions to Homebrew for a long time and shown themselves able to make slightly more advanced contributions than just e.g. formula updates? Let's invite them to be a maintainer! diff --git a/docs/Querying-Brew.md b/docs/Querying-Brew.md index 70fe6bb06e..6d37cb588d 100644 --- a/docs/Querying-Brew.md +++ b/docs/Querying-Brew.md @@ -1,4 +1,5 @@ # Querying `brew` + _In this document we will be using [jq](https://stedolan.github.io/jq/) to parse JSON, available from Homebrew using `brew install jq`._ ## Overview diff --git a/docs/Versions.md b/docs/Versions.md index 87bc9f5662..9e679db7dd 100644 --- a/docs/Versions.md +++ b/docs/Versions.md @@ -1,4 +1,5 @@ # Versions + Now that [Homebrew/versions](https://github.com/homebrew/homebrew-versions) has been deprecated [Homebrew/core](https://github.com/homebrew/homebrew-core) supports multiple versions of formulae with a new naming format. In [Homebrew/versions](https://github.com/homebrew/homebrew-versions) the formula for GCC 6 was named `gcc6.rb` and began `class Gcc6 < Formula`. In [Homebrew/core](https://github.com/homebrew/homebrew-core) this same formula is named `gcc@6.rb` and begins `class GccAT6 < Formula`. diff --git a/docs/brew-tap.md b/docs/brew-tap.md index f73f1813e8..15f8c79364 100644 --- a/docs/brew-tap.md +++ b/docs/brew-tap.md @@ -1,4 +1,5 @@ # Taps (third-party repositories) + `brew tap` adds more repos to the list of formulae that `brew` tracks, updates, and installs from. By default, `tap` assumes that the repos come from GitHub, but the command isn't limited to any one location. From 4c061fc1833521b3e943de2e2d16029966cd7164 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 5 Jan 2017 00:22:56 +0000 Subject: [PATCH 080/176] dependency: TapDependency#tap returns a Tap Previously, this returned a String, but a Tap instance seems much more sensible. I couldn't find anywhere this method was actually used, so the change shouldn't break anything. --- Library/Homebrew/dependency.rb | 2 +- Library/Homebrew/test/dependency_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 253ba4bee7..4a452440a7 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -175,7 +175,7 @@ class TapDependency < Dependency attr_reader :tap def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last]) - @tap = name.rpartition("/").first + @tap = Tap.fetch(name.rpartition("/").first) super(name, tags, env_proc, option_names) end diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 65255995ec..134e91d130 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -118,6 +118,11 @@ class DependencyTests < Homebrew::TestCase end class TapDependencyTests < Homebrew::TestCase + def test_tap + dep = TapDependency.new("foo/bar/dog") + assert_equal Tap.new("foo", "bar"), dep.tap + end + def test_option_names dep = TapDependency.new("foo/bar/dog") assert_equal %w[dog], dep.option_names From 536b6e2396042491068fda8536bfec5e38000985 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 5 Jan 2017 00:24:49 +0000 Subject: [PATCH 081/176] uses: properly handle recursive deps exceptions Fixes #1776. If any known formula had a dependency on an untapped tap, Formula#recursive_dependencies would throw an exception, which would be caught by the outer exception handler, causing the rest of the dependencies for that formula to be skipped and incomplete output to be generated. To fix this, I added a check to avoid analysing the dependencies of formulae from uninstalled taps. Additionally, I removed the aforementioned outer exception handler added in 5fdb89aed90f03413cdb21af430411c4a722876e, because the only other place that should be capable of throwing such an exception is the statement that was surrounded by another wider exception handler in Homebrew/legacy-homebrew#40682. --- Library/Homebrew/cmd/uses.rb | 79 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index fb11a31a74..f9af367549 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,48 +47,49 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - begin - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") - end + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") - end - end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } - end - end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name - end - end - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + # If a tap isn't installed, we can't find the dependencies of one + # its formulae, and an exception will be thrown if we try. + if dep.is_a?(TapDependency) && !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps + end end - rescue FormulaUnavailableError - # Silently ignore this case as we don't care about things used in - # taps that aren't currently tapped. + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end + end + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } + end + end + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end + end + + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) end end end From cd18536eff0bbd1c499f70091ac68777a2a6cebe Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Wed, 11 May 2016 14:41:11 -0700 Subject: [PATCH 082/176] PerlRequirement: version number might not be wrapped in parentheses For example: This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi --- Library/Homebrew/requirements/perl_requirement.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/requirements/perl_requirement.rb b/Library/Homebrew/requirements/perl_requirement.rb index 06e36ac0d6..70eb2a36c5 100644 --- a/Library/Homebrew/requirements/perl_requirement.rb +++ b/Library/Homebrew/requirements/perl_requirement.rb @@ -10,7 +10,7 @@ class PerlRequirement < Requirement satisfy(build_env: false) do which_all("perl").detect do |perl| - perl_version = Utils.popen_read(perl, "--version")[/\(v(\d+\.\d+)(?:\.\d+)?\)/, 1] + perl_version = Utils.popen_read(perl, "--version")[/v(\d+\.\d+)(?:\.\d+)?/, 1] next unless perl_version Version.create(perl_version.to_s) >= Version.create(@version) end From e466a65b8dfc24ab21a49d37dcd2ca3c1ffe34f2 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 5 Jan 2017 12:21:50 +0000 Subject: [PATCH 083/176] formula: correct grammar in comments --- Library/Homebrew/formula.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eb85f804f0..46d30bfff7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -326,13 +326,13 @@ class Formula active_spec.bottle_disable_reason end - # Does the currently active {SoftwareSpec} has any bottle? + # Does the currently active {SoftwareSpec} have any bottle? # @private def bottle_defined? active_spec.bottle_defined? end - # Does the currently active {SoftwareSpec} has an installable bottle? + # Does the currently active {SoftwareSpec} have an installable bottle? # @private def bottled? active_spec.bottled? From 6c2b614a04e375eea81490e906fd80a975c76f65 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 6 Jan 2017 08:50:20 +0000 Subject: [PATCH 084/176] pathname: make compute_disk_usage handle symlinks. --- Library/Homebrew/extend/pathname.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 976ea7dd83..cfb0287041 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -26,11 +26,17 @@ module DiskUsageExtension private def compute_disk_usage - if directory? + path = if symlink? + resolved_path + else + self + end + + if path.directory? scanned_files = Set.new @file_count = 0 @disk_usage = 0 - find do |f| + path.find do |f| if f.directory? @disk_usage += f.lstat.size else @@ -47,7 +53,7 @@ module DiskUsageExtension end else @file_count = 1 - @disk_usage = lstat.size + @disk_usage = path.lstat.size end end end From 1a4ff22447f73ddfda069453571bd91f8ebd367a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 6 Jan 2017 08:50:35 +0000 Subject: [PATCH 085/176] formula: tweak versioned prefix approach. --- Library/Homebrew/formula.rb | 40 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index cad8a693fd..85add1b43e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -198,7 +198,7 @@ class Formula @build = active_spec.build @pin = FormulaPin.new(self) @follow_installed_alias = true - @versioned_prefix = false + @prefix_returns_versioned_prefix = false end # @private @@ -553,11 +553,12 @@ class Formula # called from within the same formula's {#install} or {#post_install} methods. # Otherwise, return the full path to the formula's versioned cellar. def prefix(v = pkg_version) - prefix = FormulaPrefixPathname.new(rack/v) - if !@versioned_prefix && prefix.directory? && Keg.new(prefix).optlinked? + versioned_prefix = versioned_prefix(v) + if !@prefix_returns_versioned_prefix && v == pkg_version && + versioned_prefix.directory? && Keg.new(versioned_prefix).optlinked? opt_prefix else - prefix + versioned_prefix end end @@ -574,10 +575,7 @@ class Formula # Is formula's linked keg points to the prefix. def prefix_linked?(v = pkg_version) return false unless linked? - @versioned_prefix = true - result = linked_keg.resolved_path == prefix(v) - @versioned_prefix = false - result + linked_keg.resolved_path == versioned_prefix(v) end # {PkgVersion} of the linked keg for the formula. @@ -941,7 +939,7 @@ class Formula # formula, as the path is stable even when the software is updated. #
args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline"
def opt_prefix - FormulaPrefixPathname.new("#{HOMEBREW_PREFIX}/opt/#{name}") + Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}") end def opt_bin @@ -1005,7 +1003,7 @@ class Formula # @private def run_post_install - @versioned_prefix = true + @prefix_returns_versioned_prefix = true build = self.build self.build = Tab.for_formula(self) old_tmpdir = ENV["TMPDIR"] @@ -1020,7 +1018,7 @@ class Formula ENV["TMPDIR"] = old_tmpdir ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp - @versioned_prefix = false + @prefix_returns_versioned_prefix = false end # Tell the user about any caveats regarding this package. @@ -1123,7 +1121,7 @@ class Formula # where staging is a Mktemp staging context # @private def brew - @versioned_prefix = true + @prefix_returns_versioned_prefix = true stage do |staging| staging.retain! if ARGV.keep_tmp? prepare_patches @@ -1138,7 +1136,7 @@ class Formula end end ensure - @versioned_prefix = false + @prefix_returns_versioned_prefix = false end # @private @@ -1640,7 +1638,7 @@ class Formula # @private def run_test - @versioned_prefix = true + @prefix_returns_versioned_prefix = true old_home = ENV["HOME"] old_curl_home = ENV["CURL_HOME"] old_tmpdir = ENV["TMPDIR"] @@ -1672,7 +1670,7 @@ class Formula ENV["TEMP"] = old_temp ENV["TMP"] = old_tmp ENV["TERM"] = old_term - @versioned_prefix = false + @prefix_returns_versioned_prefix = false end # @private @@ -1857,6 +1855,12 @@ class Formula private + # Returns the prefix for a given formula version number. + # @private + def versioned_prefix(v) + rack/v + end + def exec_cmd(cmd, args, out, logfn) ENV["HOMEBREW_CC_LOG_PATH"] = logfn @@ -2426,10 +2430,4 @@ class Formula @link_overwrite_paths ||= Set.new end end - - class FormulaPrefixPathname < Pathname - def abv - Pathname.new(realpath).abv - end - end end From 44971905937ddf3e7815f069694eb7d87a217f63 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 6 Jan 2017 16:35:41 +0000 Subject: [PATCH 086/176] keg: use resolved_path not realpath. This guards against this being a non-symlink in which case it will fail. --- Library/Homebrew/keg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 59fed9ec34..4312c9454d 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -598,7 +598,7 @@ class Keg if src.symlink? || src.file? Find.prune if File.basename(src) == ".DS_Store" - Find.prune if src.realpath == dst + Find.prune if src.resolved_path == dst # Don't link pyc or pyo files because Python overwrites these # cached object files and next time brew wants to link, the # file is in the way. From 80b7d4c1aafc6eba51e6b167b1da13788714f4d4 Mon Sep 17 00:00:00 2001 From: Jan Viljanen Date: Fri, 6 Jan 2017 12:02:10 +0100 Subject: [PATCH 087/176] Whitelist PHP formulas in shadowed header audit check --- Library/Homebrew/extend/os/mac/formula_cellar_checks.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb index 8bc42ad35f..5b1c648bff 100644 --- a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb +++ b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb @@ -6,6 +6,8 @@ module FormulaCellarChecks formula.name.start_with?(formula_name) end + return if formula.name =~ /^php\d+$/ + return if MacOS.version < :mavericks && formula.name.start_with?("postgresql") return if MacOS.version < :yosemite && formula.name.start_with?("memcached") From f814ee87fbfd6434393bd3e606194eaad96d82e6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 7 Jan 2017 09:52:01 +0000 Subject: [PATCH 088/176] Revert "cc: always filter flags on deps." --- Library/Homebrew/shims/super/cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/Homebrew/shims/super/cc b/Library/Homebrew/shims/super/cc index 1400788ba3..b0ea705e8c 100755 --- a/Library/Homebrew/shims/super/cc +++ b/Library/Homebrew/shims/super/cc @@ -206,6 +206,10 @@ class Cmd end def keep?(path) + # The logic in this method will eventually become the default, + # but is currently opt-in. + return keep_orig?(path) unless ENV["HOMEBREW_EXPERIMENTAL_FILTER_FLAGS_ON_DEPS"] + # Allow references to self if formula_prefix && path.start_with?("#{formula_prefix}/") true @@ -222,6 +226,11 @@ class Cmd end end + # The original less-smart version of keep_orig; will eventually be removed + def keep_orig?(path) + path.start_with?(prefix, cellar, tmpdir) || !path.start_with?("/opt/local", "/opt/boxen/homebrew", "/opt/X11", "/sw", "/usr/X11") + end + def cflags args = [] From 2aac904eac522a4d746a852ecc244509f5cfdafa Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 7 Jan 2017 13:02:09 +0000 Subject: [PATCH 089/176] docs/README: link to Versions.md. --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 0e3e0f0fdd..ec75647330 100644 --- a/docs/README.md +++ b/docs/README.md @@ -27,6 +27,7 @@ - [How To Open A Pull Request (and get it merged)](How-To-Open-a-Homebrew-Pull-Request.md) - [Formula Cookbook](Formula-Cookbook.md) - [Acceptable Formulae](Acceptable-Formulae.md) +- [Formulae Versions](Versions.md) - [Node for Formula Authors](Node-for-Formula-Authors.md) - [Python for Formula Authors](Python-for-Formula-Authors.md) - [Migrating A Formula To A Tap](Migrating-A-Formula-To-A-Tap.md) From dc9819b86c60b5c6fd10373ff318d8ef60f97d52 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 7 Jan 2017 13:15:18 +0000 Subject: [PATCH 090/176] Revert "uses: properly handle untapped formulae in recursive dependency expansion" --- Library/Homebrew/cmd/uses.rb | 79 ++++++++++++------------ Library/Homebrew/dependency.rb | 2 +- Library/Homebrew/test/dependency_test.rb | 5 -- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index f9af367549..fb11a31a74 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,49 +47,48 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") + begin + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end end + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end + end + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } + end + end + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end + end - # If a tap isn't installed, we can't find the dependencies of one - # its formulae, and an exception will be thrown if we try. - if dep.is_a?(TapDependency) && !dep.tap.installed? - Dependency.keep_but_prune_recursive_deps - end + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") - end - end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } - end - end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name - end - end - - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + rescue FormulaUnavailableError + # Silently ignore this case as we don't care about things used in + # taps that aren't currently tapped. end end end diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 4a452440a7..253ba4bee7 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -175,7 +175,7 @@ class TapDependency < Dependency attr_reader :tap def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last]) - @tap = Tap.fetch(name.rpartition("/").first) + @tap = name.rpartition("/").first super(name, tags, env_proc, option_names) end diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 134e91d130..65255995ec 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -118,11 +118,6 @@ class DependencyTests < Homebrew::TestCase end class TapDependencyTests < Homebrew::TestCase - def test_tap - dep = TapDependency.new("foo/bar/dog") - assert_equal Tap.new("foo", "bar"), dep.tap - end - def test_option_names dep = TapDependency.new("foo/bar/dog") assert_equal %w[dog], dep.option_names From e7a81caaf4bc0468fdc302656efebd584e10a3f6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 7 Jan 2017 14:03:08 +0000 Subject: [PATCH 091/176] Allow `brew audit` to fake a Safari user-agent. This allows us to detect if homepages such as e.g. `aiccu` which blocks `curl` are up or not. --- Library/Homebrew/dev-cmd/audit.rb | 6 +++--- Library/Homebrew/global.rb | 1 + Library/Homebrew/utils/curl.rb | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 601031d6e0..6d43c51bfe 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -169,7 +169,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def url_status_code(url, range: false) + def url_status_code(url, range: false, user_agent: :default) # The system Curl is too old and unreliable with HTTPS homepages on # Yosemite and below. return "200" unless DevelopmentTools.curl_handles_most_https_homepages? @@ -185,7 +185,7 @@ class FormulaAuditor args = curl_args( extra_args: extra_args, show_output: true, - default_user_agent: true + user_agent: user_agent ) retries = 3 status_code = nil @@ -597,7 +597,7 @@ class FormulaAuditor return unless @online - status_code = url_status_code(homepage) + status_code = url_status_code(homepage, user_agent: :browser) return if status_code.start_with? "20" problem "The homepage #{homepage} is not reachable (HTTP status code #{status_code})" end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 9a2f0c794e..0311784212 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -26,6 +26,7 @@ RUBY_BIN = RUBY_PATH.dirname HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze +HOMEBREW_USER_AGENT_FAKE_SAFARI = "Mozilla/5.0 (#{ENV["HOMEBREW_SYSTEM"]}; #{ENV["HOMEBREW_PROCESSOR"]} #{ENV["HOMEBREW_OS_VERSION"]}) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12".freeze require "tap_constants" diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index eab623c404..5a40ae8469 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -12,7 +12,10 @@ def curl_args(options = {}) "--location", ] - unless options[:default_user_agent] + case options[:user_agent] + when :browser + args << "--user-agent" << HOMEBREW_USER_AGENT_FAKE_SAFARI + else args << "--user-agent" << HOMEBREW_USER_AGENT_CURL end From 6b63abb850a4478199e39327464dc014b632a9f1 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sat, 7 Jan 2017 15:06:46 -0500 Subject: [PATCH 092/176] keg_relocate: Check HOMEBREW_TEMP's realpath when excluding name changes. Since /tmp (the default HOMEBREW_TEMP) is a symlink to /private/tmp, some build systems (like Parrot's) will attempt to use the realpath instead of the literal /tmp we supply it with. This breaks the relocation code, which only tested the literal HOMEBREW_TEMP and not its realpath. --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 8f73daba59..f44a97b31d 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -6,7 +6,9 @@ class Keg each_install_name_for(file) do |bad_name| # Don't fix absolute paths unless they are rooted in the build directory - next if bad_name.start_with?("/") && !bad_name.start_with?(HOMEBREW_TEMP.to_s) + next if bad_name.start_with?("/") && + !bad_name.start_with?(HOMEBREW_TEMP.to_s) && + !bad_name.start_with?(HOMEBREW_TEMP.realpath.to_s) new_name = fixed_name(file, bad_name) change_install_name(bad_name, new_name, file) unless new_name == bad_name From 335be35acf805a2853a6fe92b06d9a643616f463 Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Sun, 8 Jan 2017 16:44:54 +0900 Subject: [PATCH 093/176] Generalize GitHubReleaseDownloadStrategy in order to support archive URL --- Library/Homebrew/download_strategy.rb | 83 +++++++++++++------ .../Homebrew/test/download_strategies_test.rb | 45 ++++++++-- 2 files changed, 94 insertions(+), 34 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 19af8820c5..3e028949b1 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -532,42 +532,78 @@ class S3DownloadStrategy < CurlDownloadStrategy end end -# GitHubReleaseDownloadStrategy downloads tarballs from GitHub Release assets. -# To use it, add ":using => GitHubReleaseDownloadStrategy" to the URL section -# of your formula. This download strategy uses GitHub access tokens (in the -# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. -# This strategy is suitable for corporate use just like S3DownloadStrategy, -# because it lets you use a private GttHub repository for internal distribution. -# It works with public one, but in that case simply use CurlDownloadStrategy. -class GitHubReleaseDownloadStrategy < CurlDownloadStrategy - require "utils/formatter" - require 'utils/github' - +# GitHubPrivateRepositoryDownloadStrategy downloads contents from GitHub +# Private Repository. To use it, add +# ":using => GitHubPrivateRepositoryDownloadStrategy" to the URL section of +# your formula. This download strategy uses GitHub access tokens (in the +# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. This +# strategy is suitable for corporate use just like S3DownloadStrategy, because +# it lets you use a private GttHub repository for internal distribution. It +# works with public one, but in that case simply use CurlDownloadStrategy. +class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy def initialize(name, resource) super + set_github_token + parse_url_pattern + end - @github_token = ENV["HOMEBREW_GITHUB_API_TOKEN"] - raise CurlDownloadStrategyError, "Environmental variable HOMEBREW_GITHUB_API_TOKEN is required." unless @github_token + def parse_url_pattern + url_pattern = %r|https://github.com/([^/]+)/([^/]+)/(\S+)| + unless @url =~ url_pattern + raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Repository." + end - url_pattern = %r|https://github.com/(\S+)/(\S+)/releases/download/(\S+)/(\S+)| - raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." unless @url =~ url_pattern + _, @owner, @repo, @filepath = *(@url.match(url_pattern)) + end - _, @owner, @repo, @tag, @filename = *(@url.match(url_pattern)) + def download_url + "https://#{@github_token}@github.com/#{@owner}/#{@repo}/#{@filepath}" end def _fetch - puts "Download asset_id: #{asset_id}" - # HTTP request header `Accept: application/octet-stream` is required. - # Without this, the GitHub API will respond with metadata, not binary. - curl asset_url, "-C", downloaded_size, "-o", temporary_path, "-H", 'Accept: application/octet-stream' + curl download_url, "-C", downloaded_size, "-o", temporary_path end private - def asset_url + def set_github_token + @github_token = ENV["HOMEBREW_GITHUB_API_TOKEN"] + unless @github_token + raise CurlDownloadStrategyError, "Environmental variable HOMEBREW_GITHUB_API_TOKEN is required." + end + end +end + +# GitHubPrivateRepositoryReleaseDownloadStrategy downloads tarballs from GitHub +# Release assets. To use it, add +# ":using => GitHubPrivateRepositoryReleaseDownloadStrategy" to the URL section +# of your formula. This download strategy uses GitHub access tokens (in the +# environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. +class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDownloadStrategy + require "utils/formatter" + require 'utils/github' + + def parse_url_pattern + url_pattern = %r|https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)| + unless @url =~ url_pattern + raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." + end + + _, @owner, @repo, @tag, @filename = *(@url.match(url_pattern)) + end + + def download_url "https://#{@github_token}@api.github.com/repos/#{@owner}/#{@repo}/releases/assets/#{asset_id}" end + def _fetch + # HTTP request header `Accept: application/octet-stream` is required. + # Without this, the GitHub API will respond with metadata, not binary. + curl download_url, "-C", downloaded_size, "-o", temporary_path, "-H", 'Accept: application/octet-stream' + end + + private + def asset_id @asset_id ||= resolve_asset_id end @@ -580,11 +616,8 @@ class GitHubReleaseDownloadStrategy < CurlDownloadStrategy return assets.first["id"] end - def release_url - "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}" - end - def fetch_release_metadata + release_url = "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}" GitHub.open(release_url) end end diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index e69bdfda23..21f7e6906f 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -61,25 +61,47 @@ class VCSDownloadStrategyTests < Homebrew::TestCase end end -class GitHubReleaseDownloadStrategyTests < Homebrew::TestCase +class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase + def setup + resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz") + ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" + @strategy = GitHubPrivateRepositoryDownloadStrategy.new("foo", resource) + end + + def test_set_github_token + assert_equal "token", @strategy.instance_variable_get(:@github_token) + end + + def test_parse_url_pattern + assert_equal "owner", @strategy.instance_variable_get(:@owner) + assert_equal "repo", @strategy.instance_variable_get(:@repo) + assert_equal "archive/1.1.5.tar.gz", @strategy.instance_variable_get(:@filepath) + end + + def test_download_url + expected = "https://token@github.com/owner/repo/archive/1.1.5.tar.gz" + assert_equal expected, @strategy.download_url + end +end + +class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase def setup resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" - @strategy = GitHubReleaseDownloadStrategy.new("foo", resource) + @strategy = GitHubPrivateRepositoryReleaseDownloadStrategy.new("foo", resource) end - def test_initialize - assert_equal "token", @strategy.instance_variable_get(:@github_token) + def test_parse_url_pattern assert_equal "owner", @strategy.instance_variable_get(:@owner) assert_equal "repo", @strategy.instance_variable_get(:@repo) assert_equal "tag", @strategy.instance_variable_get(:@tag) assert_equal "foo_v0.1.0_darwin_amd64.tar.gz", @strategy.instance_variable_get(:@filename) end - def test_asset_url + def test_download_url @strategy.stubs(:resolve_asset_id).returns(456) expected = "https://token@api.github.com/repos/owner/repo/releases/assets/456" - assert_equal expected, @strategy.send(:asset_url) + assert_equal expected, @strategy.download_url end def test_resolve_asset_id @@ -99,9 +121,14 @@ class GitHubReleaseDownloadStrategyTests < Homebrew::TestCase assert_equal 456, @strategy.send(:resolve_asset_id) end - def test_release_url - expected = "https://api.github.com/repos/owner/repo/releases/tags/tag" - assert_equal expected, @strategy.send(:release_url) + def test_fetch_release_metadata + expected_release_url = "https://api.github.com/repos/owner/repo/releases/tags/tag" + github_mock = MiniTest::Mock.new + github_mock.expect :call, {}, [expected_release_url] + GitHub.stub :open, github_mock do + @strategy.send(:fetch_release_metadata) + end + github_mock.verify end end From 560d5bdd7101d4e73f6501b5ac1601b0a434cece Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Sun, 8 Jan 2017 18:00:31 +0900 Subject: [PATCH 094/176] Validate a token when initializing GitHubPrivateRepositoryDownloadStrategy --- Library/Homebrew/download_strategy.rb | 24 +++++++++++++++---- .../Homebrew/test/download_strategies_test.rb | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 3e028949b1..d22ab9550f 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -541,10 +541,13 @@ end # it lets you use a private GttHub repository for internal distribution. It # works with public one, but in that case simply use CurlDownloadStrategy. class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy + require "utils/formatter" + require 'utils/github' + def initialize(name, resource) super - set_github_token parse_url_pattern + set_github_token end def parse_url_pattern @@ -571,6 +574,22 @@ class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy unless @github_token raise CurlDownloadStrategyError, "Environmental variable HOMEBREW_GITHUB_API_TOKEN is required." end + validate_github_repository_access! + end + + def validate_github_repository_access! + begin + # Test access to the repository + GitHub.repository(@owner, @repo) + rescue GitHub::HTTPNotFoundError + # We only handle HTTPNotFoundError here, + # becase AuthenticationFailedError is handled within util/github. + message = <<-EOS.undent + HOMEBREW_GITHUB_API_TOKEN can not access the repository: #{@owner}/#{@repo} + This token may not have permission to access the repository or the url of formula may be incorrect. + EOS + raise CurlDownloadStrategyError, message + end end end @@ -580,9 +599,6 @@ end # of your formula. This download strategy uses GitHub access tokens (in the # environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDownloadStrategy - require "utils/formatter" - require 'utils/github' - def parse_url_pattern url_pattern = %r|https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)| unless @url =~ url_pattern diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 21f7e6906f..ff4cbbf7aa 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -65,6 +65,7 @@ class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase def setup resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" + GitHub.stubs(:repository).returns {} @strategy = GitHubPrivateRepositoryDownloadStrategy.new("foo", resource) end @@ -88,6 +89,7 @@ class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase def setup resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" + GitHub.stubs(:repository).returns {} @strategy = GitHubPrivateRepositoryReleaseDownloadStrategy.new("foo", resource) end From 12b9cb7f4c5e0927cb1049db4f1aa53fbe371a6d Mon Sep 17 00:00:00 2001 From: Masayuki Morita Date: Sun, 8 Jan 2017 18:29:20 +0900 Subject: [PATCH 095/176] Fix rubocop style warning of download_strategy --- Library/Homebrew/download_strategy.rb | 34 +++++++++---------- .../Homebrew/test/download_strategies_test.rb | 2 +- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index d22ab9550f..bd036067df 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -542,7 +542,7 @@ end # works with public one, but in that case simply use CurlDownloadStrategy. class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy require "utils/formatter" - require 'utils/github' + require "utils/github" def initialize(name, resource) super @@ -551,12 +551,12 @@ class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy end def parse_url_pattern - url_pattern = %r|https://github.com/([^/]+)/([^/]+)/(\S+)| + url_pattern = %r{https://github.com/([^/]+)/([^/]+)/(\S+)} unless @url =~ url_pattern raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Repository." end - _, @owner, @repo, @filepath = *(@url.match(url_pattern)) + _, @owner, @repo, @filepath = *@url.match(url_pattern) end def download_url @@ -578,18 +578,16 @@ class GitHubPrivateRepositoryDownloadStrategy < CurlDownloadStrategy end def validate_github_repository_access! - begin - # Test access to the repository - GitHub.repository(@owner, @repo) - rescue GitHub::HTTPNotFoundError - # We only handle HTTPNotFoundError here, - # becase AuthenticationFailedError is handled within util/github. - message = <<-EOS.undent + # Test access to the repository + GitHub.repository(@owner, @repo) + rescue GitHub::HTTPNotFoundError + # We only handle HTTPNotFoundError here, + # becase AuthenticationFailedError is handled within util/github. + message = <<-EOS.undent HOMEBREW_GITHUB_API_TOKEN can not access the repository: #{@owner}/#{@repo} This token may not have permission to access the repository or the url of formula may be incorrect. - EOS - raise CurlDownloadStrategyError, message - end + EOS + raise CurlDownloadStrategyError, message end end @@ -600,12 +598,12 @@ end # environment variables HOMEBREW_GITHUB_API_TOKEN) to sign the request. class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDownloadStrategy def parse_url_pattern - url_pattern = %r|https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)| + url_pattern = %r{https://github.com/([^/]+)/([^/]+)/releases/download/([^/]+)/(\S+)} unless @url =~ url_pattern raise CurlDownloadStrategyError, "Invalid url pattern for GitHub Release." end - _, @owner, @repo, @tag, @filename = *(@url.match(url_pattern)) + _, @owner, @repo, @tag, @filename = *@url.match(url_pattern) end def download_url @@ -615,7 +613,7 @@ class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDo def _fetch # HTTP request header `Accept: application/octet-stream` is required. # Without this, the GitHub API will respond with metadata, not binary. - curl download_url, "-C", downloaded_size, "-o", temporary_path, "-H", 'Accept: application/octet-stream' + curl download_url, "-C", downloaded_size, "-o", temporary_path, "-H", "Accept: application/octet-stream" end private @@ -626,10 +624,10 @@ class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDo def resolve_asset_id release_metadata = fetch_release_metadata - assets = release_metadata["assets"].select{ |a| a["name"] == @filename } + assets = release_metadata["assets"].select { |a| a["name"] == @filename } raise CurlDownloadStrategyError, "Asset file not found." if assets.empty? - return assets.first["id"] + assets.first["id"] end def fetch_release_metadata diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index ff4cbbf7aa..2b64abbf95 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -117,7 +117,7 @@ class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase "id" => 456, "name" => "foo_v0.1.0_darwin_amd64.tar.gz", }, - ] + ], } @strategy.stubs(:fetch_release_metadata).returns(release_metadata) assert_equal 456, @strategy.send(:resolve_asset_id) From c276a44ebae578bdbd3048916f2a90ae20e72dd1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 12:16:55 +0000 Subject: [PATCH 096/176] bump-formula-pr: check for URL presence. If it's not there, produce a nicer error. Fixes #1805. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 8fdbd97b6f..68bf32d0bf 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -124,6 +124,8 @@ module Homebrew false elsif !hash_type odie "#{formula}: no tag/revision specified!" + elsif !new_url + odie "#{formula}: no url specified!" else rsrc_url = if requested_spec != :devel && new_url =~ /.*ftpmirror.gnu.*/ new_mirror = new_url.sub "ftpmirror.gnu.org", "ftp.gnu.org/gnu" From 346d68eb04013d2322796ed1a0edd7de007a156d Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 13:24:51 +0000 Subject: [PATCH 097/176] audit: check virtualenv and setuptools resource. `virtualenv_install_with_resources` will automatically define and install a `setuptools` resource so this is unnecessary. References https://github.com/Homebrew/homebrew-core/pull/8570 --- Library/Homebrew/dev-cmd/audit.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 6d43c51bfe..744aa6fbee 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -819,6 +819,11 @@ class FormulaAuditor problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)." end + if text =~ /virtualenv_(create|install_with_resources)/ && + text =~ /resource\s+['"]setuptools['"]\s+do/ + problem "Formulae using virtualenvs do not need a `setuptools` resource." + end + return unless text.include?('require "language/go"') && !text.include?("go_resource") problem "require \"language/go\" is unnecessary unless using `go_resource`s" end From f5b63f4a8dd3e22ffc405a1a6119a961f8332578 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 12:31:00 +0000 Subject: [PATCH 098/176] Deprecate brew (un)linkapps. Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" `.app` bundles that can be relocated. Instead, please consider using `brew cask` and migrate formulae using `.app`s to casks. --- Library/Homebrew/cmd/linkapps.rb | 16 +++++++++++++++- Library/Homebrew/cmd/unlinkapps.rb | 13 ++++++++++++- docs/brew.1.html | 14 ++++++++++++-- manpages/brew.1 | 10 ++++++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb index bd88409aaa..7dd1a6b939 100644 --- a/Library/Homebrew/cmd/linkapps.rb +++ b/Library/Homebrew/cmd/linkapps.rb @@ -1,6 +1,11 @@ #: * `linkapps` [`--local`] []: #: Find installed formulae that provide `.app`-style macOS apps and symlink them -#: into `/Applications`, allowing for easier access. +#: into `/Applications`, allowing for easier access (deprecated). +#: +#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using +#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app` +#: bundles that can be relocated. Instead, please consider using `brew cask` and +#: migrate formulae using `.app`s to casks. #: #: If no are provided, all of them will have their apps symlinked. #: @@ -14,6 +19,15 @@ module Homebrew module_function def linkapps + opoo <<-EOS.undent + `brew linkapps` has been deprecated and will eventually be removed! + + Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using + either aliases or symlinks and Homebrew formulae do not build "proper" `.app` + bundles that can be relocated. Instead, please consider using `brew cask` and + migrate formulae using `.app`s to casks. + EOS + target_dir = linkapps_target(local: ARGV.include?("--local")) unless target_dir.directory? diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb index d04ef9ee40..b2ba458bf6 100644 --- a/Library/Homebrew/cmd/unlinkapps.rb +++ b/Library/Homebrew/cmd/unlinkapps.rb @@ -1,5 +1,10 @@ #: * `unlinkapps` [`--local`] [`--dry-run`] []: -#: Remove symlinks created by `brew linkapps` from `/Applications`. +#: Remove symlinks created by `brew linkapps` from `/Applications` (deprecated). +#: +#: Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using +#: either aliases or symlinks and Homebrew formulae do not build "proper" `.app` +#: bundles that can be relocated. Instead, please consider using `brew cask` and +#: migrate formulae using `.app`s to casks. #: #: If no are provided, all linked apps will be removed. #: @@ -15,6 +20,12 @@ module Homebrew module_function def unlinkapps + opoo <<-EOS.undent + `brew unlinkapps` has been deprecated and will eventually be removed! + + Unfortunately `brew linkapps` cannot behave nicely with e.g. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" `.app` bundles that can be relocated. Instead, please consider using `brew cask` and migrate formulae using `.app`s to casks. + EOS + target_dir = linkapps_target(local: ARGV.include?("--local")) unlinkapps_from_dir(target_dir, dry_run: ARGV.dry_run?) diff --git a/docs/brew.1.html b/docs/brew.1.html index 8c81b1ddb0..ba65157cb9 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -223,7 +223,12 @@ actually link or delete any files.

If --force is passed, Homebrew will allow keg-only formulae to be linked.

linkapps [--local] [formulae]

Find installed formulae that provide .app-style macOS apps and symlink them -into /Applications, allowing for easier access.

+into /Applications, allowing for easier access (deprecated).

+ +

Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using +either aliases or symlinks and Homebrew formulae do not build "proper" .app +bundles that can be relocated. Instead, please consider using brew cask and +migrate formulae using .apps to casks.

If no formulae are provided, all of them will have their apps symlinked.

@@ -369,7 +374,12 @@ for temporarily disabling a formula:

If --dry-run or -n is passed, Homebrew will list all files which would be unlinked, but will not actually unlink or delete any files.

-
unlinkapps [--local] [--dry-run] [formulae]

Remove symlinks created by brew linkapps from /Applications.

+
unlinkapps [--local] [--dry-run] [formulae]

Remove symlinks created by brew linkapps from /Applications (deprecated).

+ +

Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using +either aliases or symlinks and Homebrew formulae do not build "proper" .app +bundles that can be relocated. Instead, please consider using brew cask and +migrate formulae using .apps to casks.

If no formulae are provided, all linked apps will be removed.

diff --git a/manpages/brew.1 b/manpages/brew.1 index c9269e7b39..aa1d1c1d00 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -294,7 +294,10 @@ If \fB\-\-force\fR is passed, Homebrew will allow keg\-only formulae to be linke . .TP \fBlinkapps\fR [\fB\-\-local\fR] [\fIformulae\fR] -Find installed formulae that provide \fB\.app\fR\-style macOS apps and symlink them into \fB/Applications\fR, allowing for easier access\. +Find installed formulae that provide \fB\.app\fR\-style macOS apps and symlink them into \fB/Applications\fR, allowing for easier access (deprecated)\. +. +.IP +Unfortunately \fBbrew linkapps\fR cannot behave nicely with e\.g\. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" \fB\.app\fR bundles that can be relocated\. Instead, please consider using \fBbrew cask\fR and migrate formulae using \fB\.app\fRs to casks\. . .IP If no \fIformulae\fR are provided, all of them will have their apps symlinked\. @@ -508,7 +511,10 @@ If \fB\-\-dry\-run\fR or \fB\-n\fR is passed, Homebrew will list all files which . .TP \fBunlinkapps\fR [\fB\-\-local\fR] [\fB\-\-dry\-run\fR] [\fIformulae\fR] -Remove symlinks created by \fBbrew linkapps\fR from \fB/Applications\fR\. +Remove symlinks created by \fBbrew linkapps\fR from \fB/Applications\fR (deprecated)\. +. +.IP +Unfortunately \fBbrew linkapps\fR cannot behave nicely with e\.g\. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" \fB\.app\fR bundles that can be relocated\. Instead, please consider using \fBbrew cask\fR and migrate formulae using \fB\.app\fRs to casks\. . .IP If no \fIformulae\fR are provided, all linked apps will be removed\. From c0a29d664420bb568036f8e92654cf5e0b73da3e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 13:33:56 +0000 Subject: [PATCH 099/176] caveats, keg: remove linkapps caveats code. --- Library/Homebrew/caveats.rb | 11 ----------- Library/Homebrew/keg.rb | 4 ---- 2 files changed, 15 deletions(-) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index 3dfdb1c872..d1dda9d4cb 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -23,7 +23,6 @@ class Caveats caveats << fish_function_caveats caveats << plist_caveats caveats << python_caveats - caveats << app_caveats caveats << elisp_caveats caveats.compact.join("\n") end @@ -169,16 +168,6 @@ class Caveats s end - def app_caveats - return unless keg - return unless keg.app_installed? - - <<-EOS.undent - .app bundles were installed. - Run `brew linkapps #{keg.name}` to symlink these to /Applications. - EOS - end - def elisp_caveats return if f.keg_only? return unless keg diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 4312c9454d..14eb0e3f33 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -367,10 +367,6 @@ class Keg Pathname.glob("#{app_prefix}/{,libexec/}*.app") end - def app_installed? - !apps.empty? - end - def elisp_installed? return false unless (path/"share/emacs/site-lisp"/name).exist? (path/"share/emacs/site-lisp"/name).children.any? { |f| %w[.el .elc].include? f.extname } From 28ad8a06cc24d2d71400e9c860a52ef046022cf1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:03:37 +0000 Subject: [PATCH 100/176] formula: return runtime_dependencies in to_hash. Which, in turn, provides it for `brew info --json=v1` so other tools such as e.g. `brew bundle` can make use of this information. --- Library/Homebrew/formula.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index e6312ccdb0..91a3e8150d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1618,6 +1618,7 @@ class Formula "used_options" => tab.used_options.as_flags, "built_as_bottle" => tab.built_as_bottle, "poured_from_bottle" => tab.poured_from_bottle, + "runtime_dependencies" => tab.runtime_dependencies, } end From d8adae0f92fcf6685d8fc8a1a44e6a11db30fac0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:42:09 +0000 Subject: [PATCH 101/176] formulary: read from formula in opt prefix. We want to prefer the newer/versioned formulae when possible but this is preferable to a random cached formula or, worse, no formula. This means `brew info foo` will never complain that `foo` is a missing formula. --- Library/Homebrew/formulary.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index fadd894570..25df57cdc2 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -380,6 +380,11 @@ class Formulary return TapLoader.new(possible_tap_newname_formulae.first, from: from) end + possible_keg_formula = Pathname.new("#{HOMEBREW_PREFIX}/opt/#{ref}/.brew/#{ref}.rb") + if possible_keg_formula.file? + return FormulaLoader.new(ref, possible_keg_formula) + end + possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb") if possible_cached_formula.file? return FormulaLoader.new(ref, possible_cached_formula) From 4a39070c268b6dba063b938d8663c70f60311230 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:41 +0000 Subject: [PATCH 102/176] xquartz: use default location when possible. Xcode can be installed anywhere but for most people it's in `/Applications/Xcode.app` so just look there by default before looking at Spotlight which can return weird results on e.g. backup disks. --- Library/Homebrew/os/mac/xquartz.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index 674e50c503..b82772faf7 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -5,6 +5,8 @@ module OS module XQuartz module_function + # TODO: confirm this path when you have internet + DEFAULT_BUNDLE_PATH = Pathname.new("Applications/Utilities/XQuartz.app").freeze FORGE_BUNDLE_ID = "org.macosforge.xquartz.X11".freeze APPLE_BUNDLE_ID = "org.x.X11".freeze FORGE_PKG_ID = "org.macosforge.xquartz.pkg".freeze @@ -56,6 +58,11 @@ module OS end def bundle_path + # Use the default location if it exists. + return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? + + # Ask Spotlight where XQuartz is. If the user didn't install XQuartz + # in the conventional place, this is our only option. MacOS.app_with_bundle_id(FORGE_BUNDLE_ID, APPLE_BUNDLE_ID) end From 2c6915a48fb1456b8075d95735dc2032e23ef210 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:20 +0000 Subject: [PATCH 103/176] xcode: general cleanup. --- Library/Homebrew/os/mac/xcode.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 8e51fc6b6d..d13c98b882 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -3,8 +3,8 @@ module OS module Xcode module_function - V4_BUNDLE_ID = "com.apple.dt.Xcode".freeze - V3_BUNDLE_ID = "com.apple.Xcode".freeze + BUNDLE_ID = "com.apple.dt.Xcode".freeze + OLD_BUNDLE_ID = "com.apple.Xcode".freeze def latest_version case MacOS.version @@ -51,9 +51,9 @@ module OS begin dir = MacOS.active_developer_dir - if dir.empty? || dir == CLT::MAVERICKS_PKG_PATH || !File.directory?(dir) + if dir.empty? || dir == CLT::PKG_PATH || !File.directory?(dir) path = bundle_path - path.join("Contents", "Developer") if path + path/"Contents/Developer" if path else # Use cleanpath to avoid pathological trailing slash Pathname.new(dir).cleanpath @@ -182,7 +182,7 @@ module OS FROM_XCODE_PKG_ID = "com.apple.pkg.DeveloperToolsCLI".freeze MAVERICKS_PKG_ID = "com.apple.pkg.CLTools_Executables".freeze MAVERICKS_NEW_PKG_ID = "com.apple.pkg.CLTools_Base".freeze # obsolete - MAVERICKS_PKG_PATH = "/Library/Developer/CommandLineTools".freeze + PKG_PATH = "/Library/Developer/CommandLineTools".freeze # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9 @@ -237,7 +237,7 @@ module OS return false if MacOS.version < :lion if MacOS.version >= :mavericks - version = Utils.popen_read("#{MAVERICKS_PKG_PATH}/usr/bin/clang --version") + version = Utils.popen_read("#{PKG_PATH}/usr/bin/clang --version") else version = Utils.popen_read("/usr/bin/clang --version") end @@ -261,7 +261,7 @@ module OS [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| if MacOS.version >= :mavericks - next unless File.exist?("#{MAVERICKS_PKG_PATH}/usr/bin/clang") + next unless File.exist?("#{PKG_PATH}/usr/bin/clang") end version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] return version if version From a17f38dd364af67d5965aaa58438cb768c6d057a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:30:32 +0000 Subject: [PATCH 104/176] xcode: use default location when possible. Xcode can be installed anywhere but for most people it's in `/Applications/Xcode.app` so just look there if `xcode-select` isn't helpful before looking at Spotlight which can return weird results on e.g. backup disks. Fixes #1587. --- Library/Homebrew/os/mac/xcode.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index d13c98b882..e85f21c631 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -3,6 +3,7 @@ module OS module Xcode module_function + DEFAULT_BUNDLE_PATH = Pathname.new("/Applications/Xcode.app").freeze BUNDLE_ID = "com.apple.dt.Xcode".freeze OLD_BUNDLE_ID = "com.apple.Xcode".freeze @@ -67,11 +68,14 @@ module OS Pathname.new("#{prefix}/Toolchains/XcodeDefault.xctoolchain") end - # Ask Spotlight where Xcode is. If the user didn't install the - # helper tools and installed Xcode in a non-conventional place, this - # is our only option. See: https://superuser.com/questions/390757 def bundle_path - MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID) + # Use the default location if it exists. + return DEFAULT_BUNDLE_PATH if DEFAULT_BUNDLE_PATH.exist? + + # Ask Spotlight where Xcode is. If the user didn't install the + # helper tools and installed Xcode in a non-conventional place, this + # is our only option. See: https://superuser.com/questions/390757 + MacOS.app_with_bundle_id(BUNDLE_ID, OLD_BUNDLE_ID) end def installed? From fe117bf79b244c42b7e4049d353c3c003eae4880 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:01 +0000 Subject: [PATCH 105/176] requirement: get formula from satisfy. If satisfy returns a `Pathname` from `which` then we can use that to infer a formula dependency from that `Requirement`. --- Library/Homebrew/requirement.rb | 36 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index fe1a3c020f..49108ca75a 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -15,6 +15,7 @@ class Requirement @default_formula = self.class.default_formula @cask ||= self.class.cask @download ||= self.class.download + @formula = nil tags.each do |tag| next unless tag.is_a? Hash @cask ||= tag[:cask] @@ -56,7 +57,14 @@ class Requirement def satisfied? result = self.class.satisfy.yielder { |p| instance_eval(&p) } @satisfied_result = result - result ? true : false + return false unless result + + if parent = satisfied_result_parent + parent.to_s =~ %r{(#{Regexp.escape(HOMEBREW_CELLAR)}|#{Regexp.escape(HOMEBREW_PREFIX)}/opt)/([\w+-.@]+)} + @formula = $2 + end + + true end # Overriding #fatal? is deprecated. @@ -69,6 +77,11 @@ class Requirement self.class.default_formula || false end + def satisfied_result_parent + return unless @satisfied_result.is_a?(Pathname) + @satisfied_result.resolved_path.parent + end + # Overriding #modify_build_environment is deprecated. # Pass a block to the env DSL method instead. # Note: #satisfied? should be called before invoking this method @@ -81,11 +94,8 @@ class Requirement # satisfy { which("executable") } # work, even under superenv where "executable" wouldn't normally be on the # PATH. - # This is undocumented magic and it should be removed, but we need to add - # a way to declare path-based requirements that work with superenv first. - return unless @satisfied_result.is_a?(Pathname) - parent = @satisfied_result.parent - + parent = satisfied_result_parent + return unless parent return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s) ENV.append_path("PATH", parent) end @@ -111,13 +121,15 @@ class Requirement "#<#{self.class.name}: #{name.inspect} #{tags.inspect}>" end + def formula + @formula || self.class.default_formula + end + def to_dependency - f = self.class.default_formula - raise "No default formula defined for #{inspect}" if f.nil? - if f =~ HOMEBREW_TAP_FORMULA_REGEX - TapDependency.new(f, tags, method(:modify_build_environment), name) - else - Dependency.new(f, tags, method(:modify_build_environment), name) + if formula =~ HOMEBREW_TAP_FORMULA_REGEX + TapDependency.new(formula, tags, method(:modify_build_environment), name) + elsif formula + Dependency.new(formula, tags, method(:modify_build_environment), name) end end From 0158cc2e23f228715182a946ddfd6268bd6fc2d8 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:33 +0000 Subject: [PATCH 106/176] build: don't assume requirement dependency is default formula. --- Library/Homebrew/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index c4e903642b..c0f15158d1 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -48,7 +48,7 @@ class Build Requirement.prune elsif req.build? && dependent != formula Requirement.prune - elsif req.satisfied? && req.default_formula? && (dep = req.to_dependency).installed? + elsif req.satisfied? && (dep = req.to_dependency) && dep.installed? deps << dep Requirement.prune end From 5821572b9b14b682feaec3f0c42afdba61a821b2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 22:44:47 +0000 Subject: [PATCH 107/176] formula_installer: don't assume requirement dependency is default formula. --- Library/Homebrew/formula_installer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 24c068460b..66bd60c374 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -370,8 +370,8 @@ class FormulaInstaller raise UnsatisfiedRequirements, fatals end - def install_requirement_default_formula?(req, dependent, build) - return false unless req.default_formula? + def install_requirement_formula?(req, dependent, build) + return false unless req.to_dependency return true unless req.satisfied? return false if req.run? install_bottle_for?(dependent, build) || build_bottle? @@ -390,7 +390,7 @@ class FormulaInstaller Requirement.prune elsif req.build? && install_bottle_for?(dependent, build) Requirement.prune - elsif install_requirement_default_formula?(req, dependent, build) + elsif install_requirement_formula?(req, dependent, build) dep = req.to_dependency deps.unshift(dep) formulae.unshift(dep.to_formula) From 3ccbfa72a2be56037375ee413b66c96d14384373 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 11 Jan 2017 14:19:56 -0800 Subject: [PATCH 108/176] brew.1: use uninstall instead of remove. Fixes #1817. --- Library/Homebrew/manpages/brew.1.md.erb | 2 +- docs/brew.1.html | 2 +- manpages/brew.1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/manpages/brew.1.md.erb b/Library/Homebrew/manpages/brew.1.md.erb index 2266f3e7ad..a7f099e9da 100644 --- a/Library/Homebrew/manpages/brew.1.md.erb +++ b/Library/Homebrew/manpages/brew.1.md.erb @@ -31,7 +31,7 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note * `install` : Install . - * `remove` : + * `uninstall` : Uninstall . * `update`: diff --git a/docs/brew.1.html b/docs/brew.1.html index ba65157cb9..8ec35ac618 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -22,7 +22,7 @@ didn't include with macOS.

install formula

Install formula.

-
remove formula

Uninstall formula.

+
uninstall formula

Uninstall formula.

update

Fetch the newest version of Homebrew from GitHub using git(1).

list

List all installed formulae.

search text|/text/

Perform a substring search of formula names for text. If text is diff --git a/manpages/brew.1 b/manpages/brew.1 index aa1d1c1d00..c3fb89d60f 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -26,7 +26,7 @@ With \fB\-\-verbose\fR or \fB\-v\fR, many commands print extra debugging informa Install \fIformula\fR\. . .TP -\fBremove\fR \fIformula\fR +\fBuninstall\fR \fIformula\fR Uninstall \fIformula\fR\. . .TP From ac7a59373087e9d49097ab7f0ddb691e64159959 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Thu, 12 Jan 2017 07:22:34 -0800 Subject: [PATCH 109/176] InreplaceError: fix undefined method crash When the first parameter to inreplace was an array, and the replacement failed, InreplaceError would end up crashing with an undefined method exception because the order of operations resulted in super not being passed the value of the entire inject block. --- Library/Homebrew/utils/inreplace.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index c7557ab41d..b4c219f064 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -1,9 +1,10 @@ module Utils class InreplaceError < RuntimeError def initialize(errors) - super errors.inject("inreplace failed\n") do |s, (path, errs)| + formatted_errors = errors.inject("inreplace failed\n") do |s, (path, errs)| s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join end + super formatted_errors end end From 62d48b4f9d5d0b11db514e5b5245b9f4fb1d2f66 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Tue, 20 Dec 2016 03:59:15 -0500 Subject: [PATCH 110/176] brew deps --tree: fix gap in line between reqs and deps --- Library/Homebrew/cmd/deps.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index b5240b2c96..205cbe172b 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -143,15 +143,23 @@ module Homebrew def recursive_deps_tree(f, prefix) reqs = f.requirements.select(&:default_formula?) + deps = f.deps.default max = reqs.length - 1 reqs.each_with_index do |req, i| - chr = i == max ? "└──" : "├──" + chr = if i == max && deps.empty? + "└──" + else + "├──" + end puts prefix + "#{chr} :#{dep_display_name(req.to_dependency)}" end - deps = f.deps.default max = deps.length - 1 deps.each_with_index do |dep, i| - chr = i == max ? "└──" : "├──" + chr = if i == max + "└──" + else + "├──" + end prefix_ext = i == max ? " " : "│ " puts prefix + "#{chr} #{dep_display_name(dep)}" recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext) From 7c7a878b1f1be672fd8b259e7089cb84afab6428 Mon Sep 17 00:00:00 2001 From: Andrew Hundt Date: Fri, 13 Jan 2017 16:20:30 -0500 Subject: [PATCH 111/176] clarify what should be in brew create url resolves https://github.com/Homebrew/brew/issues/1821 --- docs/Formula-Cookbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index df86be92fe..bb3ad33dcf 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -1,6 +1,6 @@ # Formula Cookbook -A formula is a package definition written in Ruby. It can be created with `brew create $URL`, installed with `brew install $FORMULA`, and debugged with `brew install --debug --verbose $FORMULA`. Formulae use the [Formula API](http://www.rubydoc.info/github/Homebrew/brew/master/Formula) which provides various Homebrew-specific helpers. +A formula is a package definition written in Ruby. It can be created with `brew create $URL` where `$URL` is a zip or tarball, installed with `brew install $FORMULA`, and debugged with `brew install --debug --verbose $FORMULA`. Formulae use the [Formula API](http://www.rubydoc.info/github/Homebrew/brew/master/Formula) which provides various Homebrew-specific helpers. ## Homebrew Terminology From 9dca10f9dc428e85afa399de4b76dbeac81a32b2 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Fri, 13 Jan 2017 16:26:59 -0800 Subject: [PATCH 112/176] audit: whitelist unstable versions already in core also allow higher stable versions with the same version prefix --- Library/Homebrew/dev-cmd/audit.rb | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 744aa6fbee..88d9a535c2 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -678,11 +678,47 @@ class FormulaAuditor end end + unstable_whitelist = %w[ + aalib 1.4rc5 + automysqlbackup 3.0-rc6 + aview 1.3.0rc1 + distcc 3.2rc1 + elm-format 0.5.2-alpha + ftgl 2.1.3-rc5 + hidapi 0.8.0-rc1 + libcaca 0.99b19 + premake 4.4-beta5 + pwnat 0.3-beta + pxz 4.999.9 + recode 3.7-beta2 + speexdsp 1.2rc3 + sqoop 1.4.6 + tcptraceroute 1.5beta7 + testssl 2.8rc3 + tiny-fugue 5.0b8 + vbindiff 3.0_beta4 + ].each_slice(2).to_a.map do |formula, version| + [formula, version.sub(/\d+$/, "")] + end + + gnome_devel_whitelist = %w[ + gtk-doc 1.25 + libart 2.3.21 + pygtkglext 1.1.0 + ].each_slice(2).to_a.map do |formula, version| + [formula, version.split(".")[0..1].join(".")] + end + stable = formula.stable case stable && stable.url when /[\d\._-](alpha|beta|rc\d)/ - problem "Stable version URLs should not contain #{$1}" + matched = $1 + version_prefix = stable.version.to_s.sub(/\d+$/, "") + return if unstable_whitelist.include?([formula.name, version_prefix]) + problem "Stable version URLs should not contain #{matched}" when %r{download\.gnome\.org/sources}, %r{ftp\.gnome\.org/pub/GNOME/sources}i + version_prefix = stable.version.to_s.split(".")[0..1].join(".") + return if gnome_devel_whitelist.include?([formula.name, version_prefix]) version = Version.parse(stable.url) if version >= Version.create("1.0") minor_version = version.to_s.split(".", 3)[1].to_i From 7c159449910d5c6fe2f4fea7416fed8a8ba2d4db Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 02:25:51 -0800 Subject: [PATCH 113/176] Fix documentation for HEAD upgrades. These can now be done with just `brew upgrade`, like other upgrades. Fixes #1818. --- Library/Homebrew/cmd/install.rb | 3 --- docs/brew.1.html | 5 +---- manpages/brew.1 | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 6f578caf63..fbfe46e71b 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -44,9 +44,6 @@ #: If `--keep-tmp` is passed, the temporary files created during installation #: are not deleted. #: -#: To install a newer version of HEAD use -#: `brew rm && brew install --HEAD `. -#: #: * `install` `--interactive` [`--git`] : #: Download and patch , then open a shell. This allows the user to #: run `./configure --help` and otherwise determine how to turn the software diff --git a/docs/brew.1.html b/docs/brew.1.html index ba65157cb9..9cc52a1310 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -196,10 +196,7 @@ for installation.

aka master, trunk, unstable.

If --keep-tmp is passed, the temporary files created during installation -are not deleted.

- -

To install a newer version of HEAD use -brew rm <foo> && brew install --HEAD <foo>.

+are not deleted.

install --interactive [--git] formula

Download and patch formula, then open a shell. This allows the user to run ./configure --help and otherwise determine how to turn the software package into a Homebrew formula.

diff --git a/manpages/brew.1 b/manpages/brew.1 index aa1d1c1d00..1dfb242444 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -258,9 +258,6 @@ If \fB\-\-HEAD\fR is passed, and \fIformula\fR defines it, install the HEAD vers .IP If \fB\-\-keep\-tmp\fR is passed, the temporary files created during installation are not deleted\. . -.IP -To install a newer version of HEAD use \fBbrew rm && brew install \-\-HEAD \fR\. -. .TP \fBinstall\fR \fB\-\-interactive\fR [\fB\-\-git\fR] \fIformula\fR Download and patch \fIformula\fR, then open a shell\. This allows the user to run \fB\./configure \-\-help\fR and otherwise determine how to turn the software package into a Homebrew formula\. From f4496e85e515180f96e0863af3047bf3f4a94e81 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 02:31:11 -0800 Subject: [PATCH 114/176] audit: don't allow universal for new formulae. We're frowning on these now so may as well turn that into code. --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 744aa6fbee..f2306debf0 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -481,6 +481,10 @@ class FormulaAuditor next unless @strict + if o.name == "universal" + problem "macOS has been 64-bit only since 10.6 so universal options are deprecated." + end + if o.name !~ /with(out)?-/ && o.name != "c++11" && o.name != "universal" problem "Options should begin with with/without. Migrate '--#{o.name}' with `deprecated_option`." end From feddacf829fe59ac8cf1f739db903423cf9111b0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 14:26:07 +0000 Subject: [PATCH 115/176] formula_installer: set specified_path on pour. This means that a `brew install $ALIAS` records the path accordingly so e.g. `Formula#full_installed_specified_name` returns the correct path. --- Library/Homebrew/formula_installer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 24c068460b..115d38c45f 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -808,6 +808,7 @@ class FormulaInstaller tab.poured_from_bottle = true tab.time = Time.now.to_i tab.head = HOMEBREW_REPOSITORY.git_head + tab.source["path"] = formula.specified_path.to_s tab.write end From 0d9020838fd19c5f4b677c4576159e561bfe7de1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 15 Jan 2017 19:50:07 +0000 Subject: [PATCH 116/176] tests: test Formula#recursive_requirements --- Library/Homebrew/test/formula_test.rb | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 81022d2202..e295875e7e 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -689,6 +689,44 @@ class FormulaTests < Homebrew::TestCase assert_equal %w[foo/bar/f1 baz/qux/f2], f3.runtime_dependencies.map(&:name) end + def test_requirements + f1 = formula("f1") do + url "f1-1" + + depends_on :python + depends_on :x11 => :recommended + depends_on :xcode => ['1.0', :optional] + end + stub_formula_loader f1 + + python = PythonRequirement.new + x11 = X11Requirement.new("x11", [:recommended]) + xcode = XcodeRequirement.new(["1.0", :optional]) + + # Default block should filter out deps that aren't being used + assert_equal Set[python, x11], Set.new(f1.recursive_requirements) + + f1.build = BuildOptions.new(["--with-xcode", "--without-x11"], f1.options) + assert_equal Set[python, xcode], Set.new(f1.recursive_requirements) + f1.build = f1.stable.build + + f2 = formula("f2") do + url "f2-1" + depends_on "f1" + end + + assert_equal Set[python, x11], Set.new(f2.recursive_requirements) + + # Empty block should allow all requirements + assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {}) + + # Requirements can be pruned + requirements = f2.recursive_requirements do |dependent, requirement| + Requirement.prune if requirement.is_a?(PythonRequirement) + end + assert_equal Set[x11, xcode], Set.new(requirements) + end + def test_to_hash f1 = formula("foo") do url "foo-1.0" From 02b7ffd89df401ffd142016d10ff6bb2f64c2149 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 15 Jan 2017 21:04:59 +0000 Subject: [PATCH 117/176] formula: runtime_dependencies contains requirement formulae. When a Requirement is converted to a Formula it should be listed under the runtime dependencies. --- Library/Homebrew/formula.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 91a3e8150d..1ced5030fc 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1519,10 +1519,15 @@ class Formula # Returns a list of Dependency objects that are required at runtime. # @private def runtime_dependencies - recursive_dependencies do |_dependent, dependency| + runtime_dependencies = recursive_dependencies do |_, dependency| Dependency.prune if dependency.build? Dependency.prune if !dependency.required? && build.without?(dependency) end + runtime_requirement_deps = recursive_requirements do |_, requirement| + Requirement.prune if requirement.build? + Requirement.prune if !requirement.required? && build.without?(requirement) + end.map(&:to_dependency).compact + runtime_dependencies + runtime_requirement_deps end # Returns a list of formulae depended on by this formula that aren't From feea90c0ddee280193182d8cce2ce56bc8e4aa6f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 16 Jan 2017 20:15:20 +0000 Subject: [PATCH 118/176] create: handle null versions. Fixes #1821 --- Library/Homebrew/dev-cmd/create.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/create.rb b/Library/Homebrew/dev-cmd/create.rb index 07dd1b3224..b4cda0fad5 100644 --- a/Library/Homebrew/dev-cmd/create.rb +++ b/Library/Homebrew/dev-cmd/create.rb @@ -142,12 +142,10 @@ class FormulaCreator def generate! raise "#{path} already exists" if path.exist? - if version.nil? + if version.nil? || version.null? opoo "Version cannot be determined from URL." puts "You'll need to add an explicit 'version' to the formula." - end - - if fetch? && version + elsif fetch? r = Resource.new r.url(url) r.version(version) From 6040456ea91add1d9f20820f6e23a47eb92bb4af Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 16 Jan 2017 20:35:56 +0000 Subject: [PATCH 119/176] Unset GREP_OPTIONS. Users may have this set, breaking grep's output. Fixes #1430. --- Library/Homebrew/brew.sh | 3 +++ Library/Homebrew/extend/ENV/shared.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 92953001d3..81a52f4744 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -82,6 +82,9 @@ unset GEM_PATH # bash processes inside builds unset BASH_ENV +# Users may have this set, breaking grep's output. +unset GREP_OPTIONS + HOMEBREW_SYSTEM="$(uname -s)" case "$HOMEBREW_SYSTEM" in Darwin) HOMEBREW_MACOS="1" ;; diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index a93c1ee1f6..7b468574ad 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -17,7 +17,7 @@ module SharedEnvExtension FC_FLAG_VARS = %w[FCFLAGS FFLAGS].freeze # @private SANITIZED_VARS = %w[ - CDPATH GREP_OPTIONS CLICOLOR_FORCE + CDPATH CLICOLOR_FORCE CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH CC CXX OBJC OBJCXX CPP MAKE LD LDSHARED CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS From 33b955a3f24d835f45d439f97ecabb7d6d51b7ad Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 21:58:57 +0000 Subject: [PATCH 120/176] tests: fix style of recursive_requirements tests --- Library/Homebrew/test/formula_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index e295875e7e..2d2136a05b 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -694,8 +694,8 @@ class FormulaTests < Homebrew::TestCase url "f1-1" depends_on :python - depends_on :x11 => :recommended - depends_on :xcode => ['1.0', :optional] + depends_on x11: :recommended + depends_on xcode: ["1.0", :optional] end stub_formula_loader f1 @@ -721,7 +721,7 @@ class FormulaTests < Homebrew::TestCase assert_equal Set[python, x11, xcode], Set.new(f2.recursive_requirements {}) # Requirements can be pruned - requirements = f2.recursive_requirements do |dependent, requirement| + requirements = f2.recursive_requirements do |_dependent, requirement| Requirement.prune if requirement.is_a?(PythonRequirement) end assert_equal Set[x11, xcode], Set.new(requirements) From 36c1c8e9b0e5919a5165ffb5eaeddb54db1238b0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 22:41:37 +0000 Subject: [PATCH 121/176] uses: fix recursive requirement resolution Fixes #1848 by sharing recursive dependency resolution between dependencies and requirements. Coincidentally, this also fixes the errors introduced by #1784 that necessitated it being reverted in #1797. --- Library/Homebrew/cmd/uses.rb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index fb11a31a74..e5e140d361 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -58,15 +58,29 @@ module Homebrew Dependency.prune unless includes.include?("build?") end end - reqs = f.recursive_requirements do |dependent, req| + + dep_formulae = deps.map do |dep| + begin + dep.to_formula + rescue + end + end.compact + + reqs_by_formula = ([f] + dep_formulae).flat_map do |formula| + formula.requirements.map { |req| [formula, req] } + end + + reqs_by_formula.reject! do |dependent, req| if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + ignores.include?("recommended?") || dependent.build.without?(req) elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + !includes.include?("optional?") && !dependent.build.with?(req) elsif req.build? - Requirement.prune unless includes.include?("build?") + !includes.include?("build?") end end + + reqs = reqs_by_formula.map(&:last) else deps = f.deps.reject do |dep| ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } From 0b216798bb33e63e7b9da795925f610f93cc1e33 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 15 Jan 2017 17:40:51 +0000 Subject: [PATCH 122/176] =?UTF-8?q?Revert=20"Revert=20"uses:=20properly=20?= =?UTF-8?q?handle=20untapped=20fo=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …rmulae in recursive dependency expansion"" This reverts commit dc9819b86c60b5c6fd10373ff318d8ef60f97d52. --- Library/Homebrew/cmd/uses.rb | 79 ++++++++++++------------ Library/Homebrew/dependency.rb | 2 +- Library/Homebrew/test/dependency_test.rb | 5 ++ 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index fb11a31a74..f9af367549 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,48 +47,49 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - begin - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") - end + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") - end - end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } - end - end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name - end - end - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + # If a tap isn't installed, we can't find the dependencies of one + # its formulae, and an exception will be thrown if we try. + if dep.is_a?(TapDependency) && !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps + end end - rescue FormulaUnavailableError - # Silently ignore this case as we don't care about things used in - # taps that aren't currently tapped. + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end + end + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } + end + end + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name + end + end + + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) end end end diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 253ba4bee7..4a452440a7 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -175,7 +175,7 @@ class TapDependency < Dependency attr_reader :tap def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last]) - @tap = name.rpartition("/").first + @tap = Tap.fetch(name.rpartition("/").first) super(name, tags, env_proc, option_names) end diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 65255995ec..134e91d130 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -118,6 +118,11 @@ class DependencyTests < Homebrew::TestCase end class TapDependencyTests < Homebrew::TestCase + def test_tap + dep = TapDependency.new("foo/bar/dog") + assert_equal Tap.new("foo", "bar"), dep.tap + end + def test_option_names dep = TapDependency.new("foo/bar/dog") assert_equal %w[dog], dep.option_names From 9475622c070d941b044f94eafef0d46aa29568bc Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 16 Jan 2017 23:23:09 +0000 Subject: [PATCH 123/176] uses: restore formula-level exception handler This is a temporary measure until: - #1862 is merged - I can a test on `brew uses` against every formula in the official taps to verify that exceptions are no longer raised. --- Library/Homebrew/cmd/uses.rb | 79 +++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb index f9af367549..20fc146bf0 100644 --- a/Library/Homebrew/cmd/uses.rb +++ b/Library/Homebrew/cmd/uses.rb @@ -47,49 +47,54 @@ module Homebrew uses = formulae.select do |f| used_formulae.all? do |ff| - if recursive - deps = f.recursive_dependencies do |dependent, dep| - if dep.recommended? - Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) - elsif dep.optional? - Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) - elsif dep.build? - Dependency.prune unless includes.include?("build?") - end + begin + if recursive + deps = f.recursive_dependencies do |dependent, dep| + if dep.recommended? + Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep) + elsif dep.optional? + Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep) + elsif dep.build? + Dependency.prune unless includes.include?("build?") + end - # If a tap isn't installed, we can't find the dependencies of one - # its formulae, and an exception will be thrown if we try. - if dep.is_a?(TapDependency) && !dep.tap.installed? - Dependency.keep_but_prune_recursive_deps + # If a tap isn't installed, we can't find the dependencies of one + # its formulae, and an exception will be thrown if we try. + if dep.is_a?(TapDependency) && !dep.tap.installed? + Dependency.keep_but_prune_recursive_deps + end + end + reqs = f.recursive_requirements do |dependent, req| + if req.recommended? + Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) + elsif req.optional? + Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) + elsif req.build? + Requirement.prune unless includes.include?("build?") + end + end + else + deps = f.deps.reject do |dep| + ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } + end + reqs = f.requirements.reject do |req| + ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } end end - reqs = f.recursive_requirements do |dependent, req| - if req.recommended? - Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req) - elsif req.optional? - Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req) - elsif req.build? - Requirement.prune unless includes.include?("build?") + next true if deps.any? do |dep| + begin + dep.to_formula.full_name == ff.full_name + rescue + dep.name == ff.name end end - else - deps = f.deps.reject do |dep| - ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } - end - reqs = f.requirements.reject do |req| - ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } - end - end - next true if deps.any? do |dep| - begin - dep.to_formula.full_name == ff.full_name - rescue - dep.name == ff.name - end - end - reqs.any? do |req| - req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + reqs.any? do |req| + req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula) + end + rescue FormulaUnavailableError + # Silently ignore this case as we don't care about things used in + # taps that aren't currently tapped. end end end From dac66c4ada178c09b3b9b77feb2eaa7442b7443e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 10:43:43 +0000 Subject: [PATCH 124/176] Add `keg_only :versioned_formula`. This is used to indicate a formula is a version of another formula. This will be used to provide a consistent interface for older formulae versions and replaces the use of `conflicts_with`. --- Library/Homebrew/dev-cmd/audit.rb | 10 +++++- Library/Homebrew/formula.rb | 5 +++ Library/Homebrew/formula_support.rb | 47 ++++++++++++++++------------- docs/Versions.md | 2 +- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 394e0e763d..2818396219 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -459,6 +459,14 @@ class FormulaAuditor end def audit_conflicts + if formula.versioned_formula? + problem <<-EOS + Versioned formulae should not use `conflicts_with`. + Use `keg_only :versioned_formula` instead. + EOS + return + end + formula.conflicts.each do |c| begin Formulary.factory(c.name) @@ -497,7 +505,7 @@ class FormulaAuditor return unless @new_formula return if formula.deprecated_options.empty? - return if formula.name.include?("@") + return if formula.versioned_formula? problem "New formulae should not use `deprecated_option`." end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1ced5030fc..77688840c2 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -382,6 +382,11 @@ class Formula PkgVersion.new(version, revision) end + # If this is a `@`-versioned formula. + def versioned_formula? + name.include?("@") + end + # A named Resource for the currently active {SoftwareSpec}. # Additional downloads can be defined as {#resource}s. # {Resource#stage} will create a temporary directory and yield to a block. diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index e4f8003644..dcb995a6be 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -29,27 +29,32 @@ class KegOnlyReason def to_s return @explanation unless @explanation.empty? case @reason - when :provided_by_macos, :provided_by_osx then <<-EOS -macOS already provides this software and installing another version in -parallel can cause all kinds of trouble. -EOS - when :shadowed_by_macos, :shadowed_by_osx then <<-EOS -macOS provides similar software and installing this software in -parallel can cause all kinds of trouble. -EOS - when :provided_pre_mountain_lion then <<-EOS -macOS already provides this software in versions before Mountain Lion. -EOS - when :provided_pre_mavericks then <<-EOS -macOS already provides this software in versions before Mavericks. -EOS - when :provided_pre_el_capitan then <<-EOS -macOS already provides this software in versions before El Capitan. -EOS - when :provided_until_xcode43 - "Xcode provides this software prior to version 4.3." - when :provided_until_xcode5 - "Xcode provides this software prior to version 5." + when :versioned_formula then <<-EOS.undent + This is an alternate version of another formula. + EOS + when :provided_by_macos, :provided_by_osx then <<-EOS.undent + macOS already provides this software and installing another version in + parallel can cause all kinds of trouble. + EOS + when :shadowed_by_macos, :shadowed_by_osx then <<-EOS.undent + macOS provides similar software and installing this software in + parallel can cause all kinds of trouble. + EOS + when :provided_pre_mountain_lion then <<-EOS.undent + macOS already provides this software in versions before Mountain Lion. + EOS + when :provided_pre_mavericks then <<-EOS.undent + macOS already provides this software in versions before Mavericks. + EOS + when :provided_pre_el_capitan then <<-EOS.undent + macOS already provides this software in versions before El Capitan. + EOS + when :provided_until_xcode43 then <<-EOS.undent + Xcode provides this software prior to version 4.3. + EOS + when :provided_until_xcode5 then <<-EOS.undent + Xcode provides this software prior to version 5. + EOS else @reason end.strip diff --git a/docs/Versions.md b/docs/Versions.md index 9e679db7dd..bd3ef8a5f8 100644 --- a/docs/Versions.md +++ b/docs/Versions.md @@ -11,6 +11,6 @@ Versioned formulae we include must meet the following standards: * 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. * 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 strive to be linked at the same time as their non-versioned counterpart (without patching). If this is not possible, favour either `conflicts_with` or `keg_only` depending on whether users expect to have multiple versions installed at once or not. +* Versioned formulae should only be linkable at the same time as their non-versioned counterpart if the upstream project provides support for e.g. suffixed binaries. If this is not possible, use `keg_only :versioned_formula` to allow users to have multiple versions installed at once. You should create your own [tap](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for formulae you or your organisation wishes to control the versioning of or those that do not meet the above standards. From fa3d459f5bb8a5de8c55febfdff6854b27743657 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 11:17:55 +0000 Subject: [PATCH 125/176] suite_test: skip flaky test. --- Library/Homebrew/cask/test/cask/artifact/suite_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb index b2949950ec..ed151e45cd 100644 --- a/Library/Homebrew/cask/test/cask/artifact/suite_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/suite_test.rb @@ -13,6 +13,8 @@ describe Hbc::Artifact::Suite do end it "moves the suite to the proper directory" do + skip("flaky test") + shutup do install_phase.call end From 42486c1181bdf4ed85f334ccb1edbb6632cfc4b2 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 17 Jan 2017 10:16:35 -0500 Subject: [PATCH 126/176] bottle: add: improve regexp to recognize comments This would have eliminated the need for Homebrew/homebrew-core#9000, for instance. --- Library/Homebrew/dev-cmd/bottle.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 9618cf4121..75078cffd0 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -435,6 +435,7 @@ module Homebrew else string = s.sub!( /( + (\ {2}\#[^\n]*\n)* # comments \ {2}( # two spaces at the beginning (url|head)\ ['"][\S\ ]+['"] # url or head with a string ( From 4f0505f759d355d6a514485733c0ea3349711655 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 17 Jan 2017 19:09:41 +0000 Subject: [PATCH 127/176] audit: only warn on versioned conflicts_with. Rather than all versioned formulae regardless. Oops. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2818396219..5945556951 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -459,7 +459,7 @@ class FormulaAuditor end def audit_conflicts - if formula.versioned_formula? + if formula.conflicts.any? && formula.versioned_formula? problem <<-EOS Versioned formulae should not use `conflicts_with`. Use `keg_only :versioned_formula` instead. From f0e5ebce06e8c2d7335fb3fbbc4314ee53c05e82 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 17 Jan 2017 14:55:00 -0500 Subject: [PATCH 128/176] rubocop_todo: bump max module length to 400 --- Library/Homebrew/.rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/.rubocop_todo.yml b/Library/Homebrew/.rubocop_todo.yml index c1b2ba6e7e..99080b5461 100644 --- a/Library/Homebrew/.rubocop_todo.yml +++ b/Library/Homebrew/.rubocop_todo.yml @@ -66,7 +66,7 @@ Metrics/BlockNesting: # Offense count: 19 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 363 + Max: 400 # Offense count: 1 # Configuration parameters: CountKeywordArgs. From 4d2201b8beabf99a1f4bf062a5aef12b19475caa Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 08:36:36 +0000 Subject: [PATCH 129/176] integration_command_test_case: improve fail output Instead of `puts`ing when the failure occurs save it until the error message and print a prose description of what the failure was and the output from the command. This makes the output from failing tests significantly easier to read. --- .../support/helper/integration_command_test_case.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index b79fdd6e0d..6879f2f812 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -106,16 +106,20 @@ class IntegrationCommandTestCase < Homebrew::TestCase def cmd(*args) output = cmd_output(*args) status = $?.exitstatus - puts "\n'brew #{args.join " "}' output: #{output}" if status.nonzero? - assert_equal 0, status + assert_equal 0, status, <<-EOS.undent + `brew #{args.join " "}` exited with non-zero status! + #{output} + EOS output end def cmd_fail(*args) output = cmd_output(*args) status = $?.exitstatus - $stderr.puts "\n'brew #{args.join " "}'" if status.zero? - refute_equal 0, status + refute_equal 0, status, <<-EOS.undent + `brew #{args.join " "}` exited with zero status! + #{output} + EOS output end From b99fb562753b45e7efec13366b32ddd2f58194f9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:05:27 +0000 Subject: [PATCH 130/176] tab: store installed_{as_dependency,on_request}. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are used to determine whether or not a formula’s install was specifically requested by a user and/or pulled in as a dependency. --- Library/Homebrew/tab.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 746c3dd928..fd59539dfd 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -25,6 +25,8 @@ class Tab < OpenStruct "unused_options" => build.unused_options.as_flags, "tabfile" => formula.prefix.join(FILENAME), "built_as_bottle" => build.bottle?, + "installed_as_dependency" => false, + "installed_on_request" => true, "poured_from_bottle" => false, "time" => Time.now.to_i, "source_modified_time" => formula.source_modified_time.to_i, @@ -172,6 +174,8 @@ class Tab < OpenStruct "used_options" => [], "unused_options" => [], "built_as_bottle" => false, + "installed_as_dependency" => false, + "installed_on_request" => true, "poured_from_bottle" => false, "time" => nil, "source_modified_time" => 0, @@ -313,6 +317,8 @@ class Tab < OpenStruct "unused_options" => unused_options.as_flags, "built_as_bottle" => built_as_bottle, "poured_from_bottle" => poured_from_bottle, + "installed_as_dependency" => installed_as_dependency, + "installed_on_request" => installed_on_request, "changed_files" => changed_files && changed_files.map(&:to_s), "time" => time, "source_modified_time" => source_modified_time.to_i, From 44f1c9752a1f55f09475cab79ab85fdaf39cef84 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:06:38 +0000 Subject: [PATCH 131/176] formula: installed_{as_dependency,on_request} hash Which, in turn, provides them for `brew info --json=v1` so other tools such as e.g. `brew bundle` can make use of this information. --- Library/Homebrew/formula.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 77688840c2..6df1eb4deb 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1629,6 +1629,8 @@ class Formula "built_as_bottle" => tab.built_as_bottle, "poured_from_bottle" => tab.poured_from_bottle, "runtime_dependencies" => tab.runtime_dependencies, + "installed_as_dependency" => tab.installed_as_dependency, + "installed_on_request" => tab.installed_on_request, } end From 16293c0a68622dee1497b36be8aef9d8a6dc064f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:07:55 +0000 Subject: [PATCH 132/176] formula_installer: use installed_* variables. Also, report formulae installed on request. This is useful in differentiating between those formulae that are popular because they are widely requested and those that are popular because they are widely depended on. --- Library/Homebrew/formula_installer.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 55e9832648..d9127f6541 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -36,6 +36,7 @@ class FormulaInstaller mode_attr_accessor :build_from_source, :force_bottle mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git mode_attr_accessor :verbose, :debug, :quieter + mode_attr_accessor :installed_as_dependency, :installed_on_request def initialize(formula) @formula = formula @@ -50,6 +51,8 @@ class FormulaInstaller @verbose = false @quieter = false @debug = false + @installed_as_dependency = false + @installed_on_request = true @options = Options.new @invalid_option_names = [] @requirement_messages = [] @@ -250,6 +253,12 @@ class FormulaInstaller category = "install" action = ([formula.full_name] + options).join(" ") Utils::Analytics.report_event(category, action) + + if installed_on_request + category = "install_on_request" + action = ([formula.full_name] + options).join(" ") + Utils::Analytics.report_event(category, action) + end end @@attempted << formula @@ -287,6 +296,12 @@ class FormulaInstaller brew_prefix = formula.prefix/".brew" brew_prefix.mkdir Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s) + + keg = Keg.new(formula.prefix) + tab = Tab.for_keg(keg) + tab.installed_as_dependency = installed_as_dependency + tab.installed_on_request = installed_on_request + tab.write end build_bottle_postinstall if build_bottle? @@ -483,6 +498,8 @@ class FormulaInstaller fi.build_from_source = ARGV.build_formula_from_source?(df) fi.verbose = verbose? && !quieter? fi.debug = debug? + fi.installed_as_dependency = true + fi.installed_on_request = false fi.prelude oh1 "Installing #{formula.full_name} dependency: #{Formatter.identifier(dep.name)}" fi.install @@ -809,6 +826,8 @@ class FormulaInstaller tab.time = Time.now.to_i tab.head = HOMEBREW_REPOSITORY.git_head tab.source["path"] = formula.specified_path.to_s + tab.installed_as_dependency = installed_as_dependency + tab.installed_on_request = installed_on_request tab.write end From ee43c09f7acfa57b6ea4b6238d7c3b0aa088031e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:09:31 +0000 Subject: [PATCH 133/176] install: set installed_{as_dependency,on_request}. --- Library/Homebrew/cmd/install.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index fbfe46e71b..5a3aeb7b32 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -184,6 +184,14 @@ module Homebrew # FormulaInstaller will handle this case. formulae << f end + + # Even if we don't install this formula mark it as no longer just + # installed as a dependency. + next unless f.opt_prefix.directory? + keg = Keg.new(f.opt_prefix.resolved_path) + tab = Tab.for_keg(keg) + tab.installed_on_request = true + tab.write end perform_preinstall_checks From 89d8864b6b26373f8e35be20ddb76644b186c705 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 9 Jan 2017 21:09:46 +0000 Subject: [PATCH 134/176] upgrade: tab installed_{as_dependency,on_request} --- Library/Homebrew/cmd/upgrade.rb | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 5b49a9f65b..ce892f85ce 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -94,14 +94,24 @@ module Homebrew .select(&:directory?) .map { |k| Keg.new(k.resolved_path) } + if f.opt_prefix.directory? + keg = Keg.new(f.opt_prefix.resolved_path) + tab = Tab.for_keg(keg) + end + fi = FormulaInstaller.new(f) - fi.options = f.build.used_options - fi.options &= f.options - fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) - fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? - fi.verbose = ARGV.verbose? - fi.quieter = ARGV.quieter? - fi.debug = ARGV.debug? + fi.options = f.build.used_options + fi.options &= f.options + fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && f.build.build_bottle?) + fi.build_from_source = ARGV.build_from_source? || ARGV.build_all_from_source? + fi.verbose = ARGV.verbose? + fi.quieter = ARGV.quieter? + fi.debug = ARGV.debug? + fi.installed_on_request = !ARGV.named.empty? + if tab + fi.installed_as_dependency = tab.installed_as_dependency + fi.installed_on_request ||= tab.installed_on_request + end fi.prelude oh1 "Upgrading #{f.full_specified_name} #{fi.options.to_a.join " "}" From 5424db12637917c159aca231d7e18ecfdcc8315b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 15:25:17 +0000 Subject: [PATCH 135/176] upgrade: temporarily comment out for fix. --- Library/Homebrew/cmd/upgrade.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index ce892f85ce..d3b9784b14 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -110,7 +110,7 @@ module Homebrew fi.installed_on_request = !ARGV.named.empty? if tab fi.installed_as_dependency = tab.installed_as_dependency - fi.installed_on_request ||= tab.installed_on_request + #fi.installed_on_request ||= tab.installed_on_request end fi.prelude From f0249643d47f1dee4a0d08c440eb3afd6da3558a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 18 Jan 2017 16:10:28 +0000 Subject: [PATCH 136/176] formula_installer: use attr_accessor for installed_* --- Library/Homebrew/cmd/upgrade.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index d3b9784b14..ce892f85ce 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -110,7 +110,7 @@ module Homebrew fi.installed_on_request = !ARGV.named.empty? if tab fi.installed_as_dependency = tab.installed_as_dependency - #fi.installed_on_request ||= tab.installed_on_request + fi.installed_on_request ||= tab.installed_on_request end fi.prelude diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index d9127f6541..e8f0e4bf81 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -32,11 +32,11 @@ class FormulaInstaller attr_reader :formula attr_accessor :options, :build_bottle, :invalid_option_names + attr_accessor :installed_as_dependency, :installed_on_request mode_attr_accessor :show_summary_heading, :show_header mode_attr_accessor :build_from_source, :force_bottle mode_attr_accessor :ignore_deps, :only_deps, :interactive, :git mode_attr_accessor :verbose, :debug, :quieter - mode_attr_accessor :installed_as_dependency, :installed_on_request def initialize(formula) @formula = formula From 6fc1747e0550545b4fe80f5a1854d16dd2b08afe Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Jan 2017 13:16:08 +0000 Subject: [PATCH 137/176] tests: add a missing Tab cache clear This was responsible for the sporadic failures I encountered in #1878. --- Library/Homebrew/test/formulary_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 3d88c84077..a306c43df9 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -110,6 +110,7 @@ class FormularyFactoryTest < Homebrew::TestCase keg.uninstall formula.clear_cache formula.bottle.clear_cache + Tab.clear_cache end def test_load_from_contents From 366ee0b267dbf54d6dfda7210036e388bd2fd1ff Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 19 Jan 2017 13:19:59 +0000 Subject: [PATCH 138/176] tests: revert modification to ARGV at end of test Similar to 6fc1747e0550545b4fe80f5a1854d16dd2b08afe. I hadn't seen any test failures caused by this, but I noticed it in the process of trackign that down and it's an accident waiting to happen. --- Library/Homebrew/test/formula_installer_test.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index 652548bd78..f86ae14883 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -61,6 +61,8 @@ class InstallTests < Homebrew::TestCase assert_equal 3, bin.children.length assert_predicate f.prefix/".brew/testball.rb", :readable? end + ensure + ARGV.reject! { |a| a == "--with-invalid_flag" } end def test_bottle_unneeded_formula_install From 34e13fc52750f1f13df96809034d59ce01af827f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 18 Jan 2017 22:20:44 +0000 Subject: [PATCH 139/176] keg: don't conditionally switch alias target This seems to be a remnant of Ruby 1.8. --- Library/Homebrew/keg.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 14eb0e3f33..4c869b0483 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -192,11 +192,7 @@ class Keg path.parent end - if Pathname.method_defined?(:to_path) - alias to_path to_s - else - alias to_str to_s - end + alias to_path to_s def inspect "#<#{self.class.name}:#{path}>" From 245944d359f366aaf511f133e11c98ec14cd50b1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 18 Jan 2017 22:21:22 +0000 Subject: [PATCH 140/176] keg: use Forwardable to methods delegated to #path --- Library/Homebrew/keg.rb | 50 +++++------------------------------------ 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 4c869b0483..8379686158 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -174,6 +174,12 @@ class Keg attr_reader :path, :name, :linked_keg_record, :opt_record protected :path + extend Forwardable + + def_delegators :path, + :to_s, :hash, :abv, :disk_usage, :file_count, :directory?, :exist?, :/, + :join, :rename, :find + def initialize(path) path = path.resolved_path if path.to_s.start_with?("#{HOMEBREW_PREFIX}/opt/") raise "#{path} is not a valid keg" unless path.parent.parent.realpath == HOMEBREW_CELLAR.realpath @@ -184,10 +190,6 @@ class Keg @opt_record = HOMEBREW_PREFIX/"opt/#{name}" end - def to_s - path.to_s - end - def rack path.parent end @@ -203,30 +205,6 @@ class Keg end alias eql? == - def hash - path.hash - end - - def abv - path.abv - end - - def disk_usage - path.disk_usage - end - - def file_count - path.file_count - end - - def directory? - path.directory? - end - - def exist? - path.exist? - end - def empty_installation? Pathname.glob("#{path}/**/*") do |file| next if file.directory? @@ -239,18 +217,6 @@ class Keg true end - def /(other) - path / other - end - - def join(*args) - path.join(*args) - end - - def rename(*args) - path.rename(*args) - end - def linked? linked_keg_record.symlink? && linked_keg_record.directory? && @@ -396,10 +362,6 @@ class Keg end end - def find(*args, &block) - path.find(*args, &block) - end - def oldname_opt_record @oldname_opt_record ||= if (opt_dir = HOMEBREW_PREFIX/"opt").directory? opt_dir.subdirs.detect do |dir| From cebe137499cc5e74dd0b34e54226a1ade7a4bf60 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 18 Jan 2017 11:03:36 -0800 Subject: [PATCH 141/176] audit: exempt wine's deps from the universal deprecation This can be reverted when wine's dependencies are all vendored. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5945556951..5b01021305 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -489,7 +489,7 @@ class FormulaAuditor next unless @strict - if o.name == "universal" + if o.name == "universal" && !Formula["wine"].recursive_dependencies.map(&:name).include?(formula.name) problem "macOS has been 64-bit only since 10.6 so universal options are deprecated." end From 70a381a00ff1e354e059aa07d55ebab90c5f874a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 11:21:30 +0000 Subject: [PATCH 142/176] tests: enforce `super` in lifecycle hooks This will allow us to have global setup and teardown for tests. For example, we can automatically clear caches after each test, to avoid annoying intermittent failures like #1879 and #1886. --- Library/Homebrew/test/ARGV_test.rb | 1 + Library/Homebrew/test/ENV_test.rb | 1 + Library/Homebrew/test/audit_test.rb | 4 ++++ .../Homebrew/test/bottle_collector_test.rb | 1 + Library/Homebrew/test/bottle_hooks_test.rb | 2 ++ .../Homebrew/test/build_environment_test.rb | 1 + Library/Homebrew/test/build_options_test.rb | 1 + Library/Homebrew/test/caveats_test.rb | 1 + .../test/checksum_verification_test.rb | 1 + Library/Homebrew/test/cleaner_test.rb | 2 ++ Library/Homebrew/test/cleanup_test.rb | 2 ++ Library/Homebrew/test/commands_test.rb | 2 ++ .../Homebrew/test/compiler_selector_test.rb | 1 + Library/Homebrew/test/dependencies_test.rb | 2 ++ .../test/dependency_collector_test.rb | 2 ++ .../test/dependency_expansion_test.rb | 1 + Library/Homebrew/test/dependency_test.rb | 1 + Library/Homebrew/test/descriptions_test.rb | 3 +++ Library/Homebrew/test/diagnostic_test.rb | 2 ++ .../Homebrew/test/download_strategies_test.rb | 6 +++++ Library/Homebrew/test/formula_lock_test.rb | 2 ++ Library/Homebrew/test/formula_pin_test.rb | 2 ++ Library/Homebrew/test/formula_test.rb | 5 +++++ Library/Homebrew/test/formulary_test.rb | 6 +++++ .../Homebrew/test/gpg2_requirement_test.rb | 2 ++ Library/Homebrew/test/gpg_test.rb | 1 + Library/Homebrew/test/keg_test.rb | 4 ++++ Library/Homebrew/test/language_python_test.rb | 2 ++ Library/Homebrew/test/migrator_test.rb | 5 +++++ Library/Homebrew/test/options_test.rb | 3 +++ .../test/os/mac/bottle_collector_test.rb | 1 + .../test/os/mac/dependency_collector_test.rb | 2 ++ .../Homebrew/test/os/mac/diagnostic_test.rb | 2 ++ Library/Homebrew/test/os/mac/keg_test.rb | 4 ++++ Library/Homebrew/test/os/mac/mach_test.rb | 3 +++ Library/Homebrew/test/os/mac/version_test.rb | 1 + Library/Homebrew/test/patch_test.rb | 1 + Library/Homebrew/test/patching_test.rb | 1 + Library/Homebrew/test/pathname_test.rb | 2 ++ Library/Homebrew/test/resource_test.rb | 1 + Library/Homebrew/test/sandbox_test.rb | 2 ++ Library/Homebrew/test/software_spec_test.rb | 3 +++ Library/Homebrew/test/stdlib_test.rb | 1 + .../helper/integration_command_test_case.rb | 2 ++ .../test/support/helper/lifecycle_enforcer.rb | 22 +++++++++++++++++++ .../Homebrew/test/support/helper/test_case.rb | 2 ++ Library/Homebrew/test/tab_test.rb | 4 ++++ Library/Homebrew/test/tap_test.rb | 3 +++ Library/Homebrew/test/uninstall_test.rb | 3 +++ Library/Homebrew/test/update_report_test.rb | 1 + Library/Homebrew/test/utils_test.rb | 2 ++ 51 files changed, 132 insertions(+) create mode 100644 Library/Homebrew/test/support/helper/lifecycle_enforcer.rb diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb index 6805e0c620..06660defc3 100644 --- a/Library/Homebrew/test/ARGV_test.rb +++ b/Library/Homebrew/test/ARGV_test.rb @@ -3,6 +3,7 @@ require "extend/ARGV" class ArgvExtensionTests < Homebrew::TestCase def setup + super @argv = [].extend(HomebrewArgvExtension) end diff --git a/Library/Homebrew/test/ENV_test.rb b/Library/Homebrew/test/ENV_test.rb index dd60250842..cbfd01e251 100644 --- a/Library/Homebrew/test/ENV_test.rb +++ b/Library/Homebrew/test/ENV_test.rb @@ -31,6 +31,7 @@ end module SharedEnvTests def setup + super @env = {}.extend(EnvActivation) end diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index dace4dc2ba..0b13d3c2b2 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -6,11 +6,13 @@ require "dev-cmd/audit" class FormulaTextTests < Homebrew::TestCase def setup + super @dir = mktmpdir end def teardown FileUtils.rm_rf @dir + super end def formula_text(name, body = nil, options = {}) @@ -58,11 +60,13 @@ end class FormulaAuditorTests < Homebrew::TestCase def setup + super @dir = mktmpdir end def teardown FileUtils.rm_rf @dir + super end def formula_auditor(name, text, options = {}) diff --git a/Library/Homebrew/test/bottle_collector_test.rb b/Library/Homebrew/test/bottle_collector_test.rb index d75e29ec86..5879da92c0 100644 --- a/Library/Homebrew/test/bottle_collector_test.rb +++ b/Library/Homebrew/test/bottle_collector_test.rb @@ -3,6 +3,7 @@ require "utils/bottles" class BottleCollectorTests < Homebrew::TestCase def setup + super @collector = Utils::Bottles::Collector.new end diff --git a/Library/Homebrew/test/bottle_hooks_test.rb b/Library/Homebrew/test/bottle_hooks_test.rb index 3535d80efd..fd890192fb 100644 --- a/Library/Homebrew/test/bottle_hooks_test.rb +++ b/Library/Homebrew/test/bottle_hooks_test.rb @@ -17,6 +17,7 @@ class BottleHookTests < Homebrew::TestCase end def setup + super @fi = FormulaInstaller.new FormulaDouble.new end @@ -43,5 +44,6 @@ class BottleHookTests < Homebrew::TestCase def teardown Homebrew::Hooks::Bottles.reset_hooks + super end end diff --git a/Library/Homebrew/test/build_environment_test.rb b/Library/Homebrew/test/build_environment_test.rb index 73a1c95f73..54b9cb2b17 100644 --- a/Library/Homebrew/test/build_environment_test.rb +++ b/Library/Homebrew/test/build_environment_test.rb @@ -3,6 +3,7 @@ require "build_environment" class BuildEnvironmentTests < Homebrew::TestCase def setup + super @env = BuildEnvironment.new end diff --git a/Library/Homebrew/test/build_options_test.rb b/Library/Homebrew/test/build_options_test.rb index e460d25ccb..05e7ccd947 100644 --- a/Library/Homebrew/test/build_options_test.rb +++ b/Library/Homebrew/test/build_options_test.rb @@ -4,6 +4,7 @@ require "options" class BuildOptionsTests < Homebrew::TestCase def setup + super args = Options.create(%w[--with-foo --with-bar --without-qux]) opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) @build = BuildOptions.new(args, opts) diff --git a/Library/Homebrew/test/caveats_test.rb b/Library/Homebrew/test/caveats_test.rb index 9eaac57927..3a582b907f 100644 --- a/Library/Homebrew/test/caveats_test.rb +++ b/Library/Homebrew/test/caveats_test.rb @@ -4,6 +4,7 @@ require "caveats" class CaveatsTests < Homebrew::TestCase def setup + super @f = formula { url "foo-1.0" } @c = Caveats.new @f end diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb index 9017b528d0..ad7dfb4628 100644 --- a/Library/Homebrew/test/checksum_verification_test.rb +++ b/Library/Homebrew/test/checksum_verification_test.rb @@ -19,6 +19,7 @@ class ChecksumVerificationTests < Homebrew::TestCase def teardown @_f.clear_cache + super end def test_good_sha256 diff --git a/Library/Homebrew/test/cleaner_test.rb b/Library/Homebrew/test/cleaner_test.rb index ac108421c8..413925dfa6 100644 --- a/Library/Homebrew/test/cleaner_test.rb +++ b/Library/Homebrew/test/cleaner_test.rb @@ -6,12 +6,14 @@ class CleanerTests < Homebrew::TestCase include FileUtils def setup + super @f = formula("cleaner_test") { url "foo-1.0" } @f.prefix.mkpath end def teardown @f.rack.rmtree if @f.rack.exist? + super end def test_clean_file diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index bb8e1cdc61..e27439e071 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -14,6 +14,7 @@ end class CleanupTests < Homebrew::TestCase def setup + super @ds_store = Pathname.new "#{HOMEBREW_PREFIX}/Library/.DS_Store" FileUtils.touch @ds_store end @@ -22,6 +23,7 @@ class CleanupTests < Homebrew::TestCase FileUtils.rm_f @ds_store ARGV.delete "--dry-run" ARGV.delete "--prune=all" + super end def test_cleanup diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb index d44d2da0e7..3d7c16e58f 100644 --- a/Library/Homebrew/test/commands_test.rb +++ b/Library/Homebrew/test/commands_test.rb @@ -13,6 +13,7 @@ end class CommandsTests < Homebrew::TestCase def setup + super @cmds = [ # internal commands HOMEBREW_LIBRARY_PATH/"cmd/rbcmd.rb", @@ -28,6 +29,7 @@ class CommandsTests < Homebrew::TestCase def teardown @cmds.each(&:unlink) + super end def test_internal_commands diff --git a/Library/Homebrew/test/compiler_selector_test.rb b/Library/Homebrew/test/compiler_selector_test.rb index b1591bdbec..aa1a6f97ec 100644 --- a/Library/Homebrew/test/compiler_selector_test.rb +++ b/Library/Homebrew/test/compiler_selector_test.rb @@ -31,6 +31,7 @@ class CompilerSelectorTests < Homebrew::TestCase end def setup + super @f = Double.new @cc = :clang @versions = CompilerVersions.new diff --git a/Library/Homebrew/test/dependencies_test.rb b/Library/Homebrew/test/dependencies_test.rb index db3b782265..c5444fcbcc 100644 --- a/Library/Homebrew/test/dependencies_test.rb +++ b/Library/Homebrew/test/dependencies_test.rb @@ -5,6 +5,7 @@ require "requirements" class DependenciesTests < Homebrew::TestCase def setup + super @deps = Dependencies.new end @@ -89,6 +90,7 @@ end class RequirementsTests < Homebrew::TestCase def setup + super @reqs = Requirements.new end diff --git a/Library/Homebrew/test/dependency_collector_test.rb b/Library/Homebrew/test/dependency_collector_test.rb index 1c7f70118b..c63d046370 100644 --- a/Library/Homebrew/test/dependency_collector_test.rb +++ b/Library/Homebrew/test/dependency_collector_test.rb @@ -11,11 +11,13 @@ class DependencyCollectorTests < Homebrew::TestCase end def setup + super @d = DependencyCollector.new end def teardown DependencyCollector.clear_cache + super end def test_dependency_creation diff --git a/Library/Homebrew/test/dependency_expansion_test.rb b/Library/Homebrew/test/dependency_expansion_test.rb index 9d6de35e2f..de743ce035 100644 --- a/Library/Homebrew/test/dependency_expansion_test.rb +++ b/Library/Homebrew/test/dependency_expansion_test.rb @@ -9,6 +9,7 @@ class DependencyExpansionTests < Homebrew::TestCase end def setup + super @foo = build_dep(:foo) @bar = build_dep(:bar) @baz = build_dep(:baz) diff --git a/Library/Homebrew/test/dependency_test.rb b/Library/Homebrew/test/dependency_test.rb index 134e91d130..404f26d79c 100644 --- a/Library/Homebrew/test/dependency_test.rb +++ b/Library/Homebrew/test/dependency_test.rb @@ -3,6 +3,7 @@ require "dependency" class DependableTests < Homebrew::TestCase def setup + super @tags = ["foo", "bar", :build] @dep = Struct.new(:tags).new(@tags).extend(Dependable) end diff --git a/Library/Homebrew/test/descriptions_test.rb b/Library/Homebrew/test/descriptions_test.rb index de38fdbd13..baeeb7b192 100644 --- a/Library/Homebrew/test/descriptions_test.rb +++ b/Library/Homebrew/test/descriptions_test.rb @@ -3,6 +3,8 @@ require "descriptions" class DescriptionsTest < Homebrew::TestCase def setup + super + @descriptions_hash = {} @descriptions = Descriptions.new(@descriptions_hash) @@ -12,6 +14,7 @@ class DescriptionsTest < Homebrew::TestCase def teardown $stdout = @old_stdout + super end def test_single_core_formula diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index c9bb524b0d..608dda0993 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -5,12 +5,14 @@ require "diagnostic" class DiagnosticChecksTest < Homebrew::TestCase def setup + super @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end def teardown ENV.replace(@env) + super end def test_inject_file_list diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 2b64abbf95..fa69ec64ec 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -15,6 +15,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase include FileUtils def setup + super @name = "foo" @resource = ResourceDouble.new @strategy = AbstractDownloadStrategy.new(@name, @resource) @@ -63,6 +64,7 @@ end class GitHubPrivateRepositoryDownloadStrategyTests < Homebrew::TestCase def setup + super resource = ResourceDouble.new("https://github.com/owner/repo/archive/1.1.5.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" GitHub.stubs(:repository).returns {} @@ -87,6 +89,7 @@ end class GitHubPrivateRepositoryReleaseDownloadStrategyTests < Homebrew::TestCase def setup + super resource = ResourceDouble.new("https://github.com/owner/repo/releases/download/tag/foo_v0.1.0_darwin_amd64.tar.gz") ENV["HOMEBREW_GITHUB_API_TOKEN"] = "token" GitHub.stubs(:repository).returns {} @@ -138,6 +141,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase include FileUtils def setup + super resource = ResourceDouble.new("https://github.com/homebrew/foo") @commit_id = 1 @strategy = GitDownloadStrategy.new("baz", resource) @@ -147,6 +151,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase def teardown rmtree @cached_location + super end def git_commit_all @@ -236,6 +241,7 @@ end class DownloadStrategyDetectorTests < Homebrew::TestCase def setup + super @d = DownloadStrategyDetector.new end diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb index 80ee9dd258..d5bd0d07c5 100644 --- a/Library/Homebrew/test/formula_lock_test.rb +++ b/Library/Homebrew/test/formula_lock_test.rb @@ -3,6 +3,7 @@ require "formula_lock" class FormulaLockTests < Homebrew::TestCase def setup + super @lock = FormulaLock.new("foo") @lock.lock end @@ -10,6 +11,7 @@ class FormulaLockTests < Homebrew::TestCase def teardown @lock.unlock HOMEBREW_LOCK_DIR.children.each(&:unlink) + super end def test_locking_file_with_existing_lock_raises_error diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb index 297d7703e3..5dd2bd29e0 100644 --- a/Library/Homebrew/test/formula_pin_test.rb +++ b/Library/Homebrew/test/formula_pin_test.rb @@ -21,6 +21,7 @@ class FormulaPinTests < Homebrew::TestCase end def setup + super @f = FormulaDouble.new @pin = FormulaPin.new(@f) @f.rack.mkpath @@ -50,5 +51,6 @@ class FormulaPinTests < Homebrew::TestCase def teardown @f.rack.rmtree + super end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 2d2136a05b..8293768fe0 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -874,6 +874,8 @@ class AliasChangeTests < Homebrew::TestCase end def setup + super + alias_name = "bar" @alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}" @@ -942,6 +944,8 @@ class OutdatedVersionsTests < Homebrew::TestCase attr_reader :f, :old_formula, :new_formula def setup + super + @f = formula do url "foo" version "1.20" @@ -960,6 +964,7 @@ class OutdatedVersionsTests < Homebrew::TestCase def teardown formulae = [@f, @old_formula, @new_formula] formulae.map(&:rack).select(&:exist?).each(&:rmtree) + super end def alias_path diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index a306c43df9..360c44a0dd 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -16,6 +16,7 @@ end class FormularyFactoryTest < Homebrew::TestCase def setup + super @name = "testball_bottle" @path = CoreTap.new.formula_dir/"#{@name}.rb" @bottle_dir = Pathname.new("#{TEST_FIXTURE_DIR}/bottles") @@ -41,6 +42,7 @@ class FormularyFactoryTest < Homebrew::TestCase def teardown @path.unlink + super end def test_factory @@ -129,6 +131,7 @@ end class FormularyTapFactoryTest < Homebrew::TestCase def setup + super @name = "foo" @tap = Tap.new "homebrew", "foo" @path = @tap.path/"#{@name}.rb" @@ -142,6 +145,7 @@ class FormularyTapFactoryTest < Homebrew::TestCase def teardown @tap.path.rmtree + super end def test_factory_tap_formula @@ -174,6 +178,7 @@ end class FormularyTapPriorityTest < Homebrew::TestCase def setup + super @name = "foo" @core_path = CoreTap.new.formula_dir/"#{@name}.rb" @tap = Tap.new "homebrew", "foo" @@ -190,6 +195,7 @@ class FormularyTapPriorityTest < Homebrew::TestCase def teardown @core_path.unlink @tap.path.rmtree + super end def test_find_with_priority_core_formula diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb index fa7fc9ea41..b45798b420 100644 --- a/Library/Homebrew/test/gpg2_requirement_test.rb +++ b/Library/Homebrew/test/gpg2_requirement_test.rb @@ -4,6 +4,7 @@ require "fileutils" class GPG2RequirementTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) (@dir/"bin/gpg").write <<-EOS.undent #!/bin/bash @@ -14,6 +15,7 @@ class GPG2RequirementTests < Homebrew::TestCase def teardown FileUtils.rm_rf @dir + super end def test_satisfied diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index 0374bdab4b..881468ad27 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -3,6 +3,7 @@ require "gpg" class GpgTest < Homebrew::TestCase def setup + super skip "GPG Unavailable" unless Gpg.available? @dir = Pathname.new(mktmpdir) end diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 40b47b5e9d..08bda4699a 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -20,6 +20,8 @@ class LinkTestCase < Homebrew::TestCase end def setup + super + @keg = setup_test_keg("foo", "1.0") @dst = HOMEBREW_PREFIX.join("bin", "helloworld") @nonexistent = Pathname.new("/some/nonexistent/path") @@ -43,6 +45,8 @@ class LinkTestCase < Homebrew::TestCase rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" + + super end end diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb index d1e3867f73..0a6d1eeaaf 100644 --- a/Library/Homebrew/test/language_python_test.rb +++ b/Library/Homebrew/test/language_python_test.rb @@ -4,6 +4,7 @@ require "resource" class LanguagePythonTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) resource = stub("resource", stage: true) formula_bin = @dir/"formula_bin" @@ -16,6 +17,7 @@ class LanguagePythonTests < Homebrew::TestCase def teardown FileUtils.rm_rf @dir + super end def test_virtualenv_creation diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 8a2b6ad63e..53151f3e32 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -10,6 +10,7 @@ end class MigratorErrorsTests < Homebrew::TestCase def setup + super @new_f = Testball.new("newname") @new_f.oldname = "oldname" @old_f = Testball.new("oldname") @@ -40,6 +41,8 @@ class MigratorTests < Homebrew::TestCase include FileUtils def setup + super + @new_f = Testball.new("newname") @new_f.oldname = "oldname" @@ -93,6 +96,8 @@ class MigratorTests < Homebrew::TestCase @new_f.unpin HOMEBREW_LOCK_DIR.children.each(&:unlink) + + super end def test_move_cellar diff --git a/Library/Homebrew/test/options_test.rb b/Library/Homebrew/test/options_test.rb index e7189a6042..f38ec44154 100644 --- a/Library/Homebrew/test/options_test.rb +++ b/Library/Homebrew/test/options_test.rb @@ -15,6 +15,7 @@ end class OptionTests < Homebrew::TestCase def setup + super @option = Option.new("foo") end @@ -43,6 +44,7 @@ end class DeprecatedOptionTests < Homebrew::TestCase def setup + super @deprecated_option = DeprecatedOption.new("foo", "bar") end @@ -68,6 +70,7 @@ end class OptionsTests < Homebrew::TestCase def setup + super @options = Options.new end diff --git a/Library/Homebrew/test/os/mac/bottle_collector_test.rb b/Library/Homebrew/test/os/mac/bottle_collector_test.rb index 2f88050aed..e9ae9b7537 100644 --- a/Library/Homebrew/test/os/mac/bottle_collector_test.rb +++ b/Library/Homebrew/test/os/mac/bottle_collector_test.rb @@ -3,6 +3,7 @@ require "utils/bottles" class OSMacBottleCollectorTests < Homebrew::TestCase def setup + super @collector = Utils::Bottles::Collector.new end diff --git a/Library/Homebrew/test/os/mac/dependency_collector_test.rb b/Library/Homebrew/test/os/mac/dependency_collector_test.rb index 4fdf3ebe42..1033df9ab5 100644 --- a/Library/Homebrew/test/os/mac/dependency_collector_test.rb +++ b/Library/Homebrew/test/os/mac/dependency_collector_test.rb @@ -7,11 +7,13 @@ class OSMacDependencyCollectorTests < Homebrew::TestCase end def setup + super @d = DependencyCollector.new end def teardown DependencyCollector.clear_cache + super end def test_tar_needs_xz_dependency diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 655aa1d46b..284d293ca9 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -5,12 +5,14 @@ require "diagnostic" class OSMacDiagnosticChecksTest < Homebrew::TestCase def setup + super @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end def teardown ENV.replace(@env) + super end def test_check_for_other_package_managers diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index e79cbc9217..5f215bd06f 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -6,6 +6,8 @@ class OSMacLinkTests < Homebrew::TestCase include FileUtils def setup + super + keg = HOMEBREW_CELLAR.join("foo", "1.0") keg.join("bin").mkpath @@ -34,6 +36,8 @@ class OSMacLinkTests < Homebrew::TestCase rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" + + super end def test_mach_o_files_skips_hardlinks diff --git a/Library/Homebrew/test/os/mac/mach_test.rb b/Library/Homebrew/test/os/mac/mach_test.rb index a42f7316b1..ed0424be65 100644 --- a/Library/Homebrew/test/os/mac/mach_test.rb +++ b/Library/Homebrew/test/os/mac/mach_test.rb @@ -109,6 +109,7 @@ end class ArchitectureListExtensionTests < MachOPathnameTests def setup + super @archs = [:i386, :x86_64, :ppc7400, :ppc64].extend(ArchitectureListExtension) end @@ -157,11 +158,13 @@ class TextExecutableTests < Homebrew::TestCase attr_reader :pn def setup + super @pn = HOMEBREW_PREFIX.join("an_executable") end def teardown HOMEBREW_PREFIX.join("an_executable").unlink + super end def test_simple_shebang diff --git a/Library/Homebrew/test/os/mac/version_test.rb b/Library/Homebrew/test/os/mac/version_test.rb index f702c7097a..ba42176917 100644 --- a/Library/Homebrew/test/os/mac/version_test.rb +++ b/Library/Homebrew/test/os/mac/version_test.rb @@ -4,6 +4,7 @@ require "os/mac/version" class OSMacVersionTests < Homebrew::TestCase def setup + super @v = MacOS::Version.new("10.7") end diff --git a/Library/Homebrew/test/patch_test.rb b/Library/Homebrew/test/patch_test.rb index 62624720e8..f5a61398aa 100644 --- a/Library/Homebrew/test/patch_test.rb +++ b/Library/Homebrew/test/patch_test.rb @@ -111,6 +111,7 @@ end class ExternalPatchTests < Homebrew::TestCase def setup + super @p = ExternalPatch.new(:p1) { url "file:///my.patch" } end diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb index ac14c8e1e7..eadab15dc1 100644 --- a/Library/Homebrew/test/patching_test.rb +++ b/Library/Homebrew/test/patching_test.rb @@ -23,6 +23,7 @@ class PatchingTests < Homebrew::TestCase def teardown @_f.clear_cache @_f.patchlist.each { |p| p.clear_cache if p.external? } + super end def assert_patched(formula) diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb index 2f6360719b..2f4002b005 100644 --- a/Library/Homebrew/test/pathname_test.rb +++ b/Library/Homebrew/test/pathname_test.rb @@ -7,6 +7,7 @@ module PathnameTestExtension include FileUtils def setup + super @src = Pathname.new(mktmpdir) @dst = Pathname.new(mktmpdir) @file = @src/"foo" @@ -16,6 +17,7 @@ module PathnameTestExtension def teardown rmtree(@src) rmtree(@dst) + super end end diff --git a/Library/Homebrew/test/resource_test.rb b/Library/Homebrew/test/resource_test.rb index c1b526cb2c..d982a7c337 100644 --- a/Library/Homebrew/test/resource_test.rb +++ b/Library/Homebrew/test/resource_test.rb @@ -3,6 +3,7 @@ require "resource" class ResourceTests < Homebrew::TestCase def setup + super @resource = Resource.new("test") end diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 2a062cb10f..96558afa4e 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -3,6 +3,7 @@ require "sandbox" class SandboxTest < Homebrew::TestCase def setup + super skip "sandbox not implemented" unless Sandbox.available? @sandbox = Sandbox.new @dir = Pathname.new(mktmpdir) @@ -11,6 +12,7 @@ class SandboxTest < Homebrew::TestCase def teardown @dir.rmtree + super end def test_formula? diff --git a/Library/Homebrew/test/software_spec_test.rb b/Library/Homebrew/test/software_spec_test.rb index d9226f8c34..026265a4a1 100644 --- a/Library/Homebrew/test/software_spec_test.rb +++ b/Library/Homebrew/test/software_spec_test.rb @@ -3,6 +3,7 @@ require "software_spec" class SoftwareSpecTests < Homebrew::TestCase def setup + super @spec = SoftwareSpec.new end @@ -136,6 +137,7 @@ end class HeadSoftwareSpecTests < Homebrew::TestCase def setup + super @spec = HeadSoftwareSpec.new end @@ -150,6 +152,7 @@ end class BottleSpecificationTests < Homebrew::TestCase def setup + super @spec = BottleSpecification.new end diff --git a/Library/Homebrew/test/stdlib_test.rb b/Library/Homebrew/test/stdlib_test.rb index 3babfd58af..f193ae71e9 100644 --- a/Library/Homebrew/test/stdlib_test.rb +++ b/Library/Homebrew/test/stdlib_test.rb @@ -4,6 +4,7 @@ require "cxxstdlib" class CxxStdlibTests < Homebrew::TestCase def setup + super @clang = CxxStdlib.create(:libstdcxx, :clang) @gcc = CxxStdlib.create(:libstdcxx, :gcc) @gcc40 = CxxStdlib.create(:libstdcxx, :gcc_4_0) diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 6879f2f812..86184ac51e 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -6,6 +6,7 @@ require "test/support/helper/test_case" class IntegrationCommandTestCase < Homebrew::TestCase def setup + super @cmd_id_index = 0 # Assign unique IDs to invocations of `cmd_output`. (HOMEBREW_PREFIX/"bin").mkpath FileUtils.touch HOMEBREW_PREFIX/"bin/brew" @@ -38,6 +39,7 @@ class IntegrationCommandTestCase < Homebrew::TestCase coretap.path/"formula_renames.json", ].flatten FileUtils.rm_rf paths_to_delete + super end def needs_test_cmd_taps diff --git a/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb new file mode 100644 index 0000000000..413f8b11e7 --- /dev/null +++ b/Library/Homebrew/test/support/helper/lifecycle_enforcer.rb @@ -0,0 +1,22 @@ +module Test + module Helper + module LifecycleEnforcer + def setup + @__setup_called = true + super + end + + def teardown + @__teardown_called = true + super + end + + def after_teardown + assert @__setup_called, "Expected setup to call `super` but didn't" + assert @__teardown_called, "Expected teardown to call `super` but didn't" + + super + end + end + end +end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 60c91e7bb3..5becfeef19 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -2,10 +2,12 @@ module Homebrew class TestCase < ::Minitest::Test require "test/support/helper/env" require "test/support/helper/fs_leak_logger" + require "test/support/helper/lifecycle_enforcer" require "test/support/helper/shutup" require "test/support/helper/version_assertions" include Test::Helper::Env include Test::Helper::FSLeakLogger + include Test::Helper::LifecycleEnforcer include Test::Helper::Shutup include Test::Helper::VersionAssertions diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index f9824ba2a8..5a354a908b 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -4,6 +4,8 @@ require "formula" class TabTests < Homebrew::TestCase def setup + super + @used = Options.create(%w[--with-foo --without-bar]) @unused = Options.create(%w[--with-baz --without-qux]) @@ -260,6 +262,7 @@ end class TabLoadingTests < Homebrew::TestCase def setup + super @f = formula { url "foo-1.0" } @f.prefix.mkpath @path = @f.prefix.join(Tab::FILENAME) @@ -268,6 +271,7 @@ class TabLoadingTests < Homebrew::TestCase def teardown @f.rack.rmtree + super end def test_for_keg diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 7114cdf228..4990bc6df3 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -34,6 +34,7 @@ class TapTest < Homebrew::TestCase include FileUtils def setup + super @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" @path.mkpath @tap = Tap.new("Homebrew", "foo") @@ -86,6 +87,7 @@ class TapTest < Homebrew::TestCase def teardown @path.rmtree + super end def test_fetch @@ -285,6 +287,7 @@ class CoreTapTest < Homebrew::TestCase include FileUtils def setup + super @repo = CoreTap.new end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 597e77e40d..4ab2f985ed 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -3,6 +3,8 @@ require "cmd/uninstall" class UninstallTests < Homebrew::TestCase def setup + super + @dependency = formula("dependency") { url "f-1" } @dependent = formula("dependent") do url "f-1" @@ -32,6 +34,7 @@ class UninstallTests < Homebrew::TestCase f.installed_kegs.each(&:remove_opt_record) f.rack.rmtree end + super end def handle_unsatisfied_dependents diff --git a/Library/Homebrew/test/update_report_test.rb b/Library/Homebrew/test/update_report_test.rb index 6b6cec6ce0..32c3e36d0a 100644 --- a/Library/Homebrew/test/update_report_test.rb +++ b/Library/Homebrew/test/update_report_test.rb @@ -24,6 +24,7 @@ class ReportTests < Homebrew::TestCase end def setup + super @tap = CoreTap.new @reporter = ReporterMock.new(@tap) @hub = ReporterHub.new diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index d7c25683d7..310bfb1351 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -5,6 +5,7 @@ require "utils/shell" class UtilTests < Homebrew::TestCase def setup + super @dir = Pathname.new(mktmpdir) @env = ENV.to_hash end @@ -12,6 +13,7 @@ class UtilTests < Homebrew::TestCase def teardown @dir.rmtree ENV.replace @env + super end def test_ofail From 2d550b50081bfa0d641875f8657fd376afe0c10f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:24:19 +0000 Subject: [PATCH 143/176] tests: clear tab cache in global teardown --- Library/Homebrew/test/formulary_test.rb | 1 - Library/Homebrew/test/support/helper/test_case.rb | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 360c44a0dd..2ed5cd3f0e 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -112,7 +112,6 @@ class FormularyFactoryTest < Homebrew::TestCase keg.uninstall formula.clear_cache formula.bottle.clear_cache - Tab.clear_cache end def test_load_from_contents diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 5becfeef19..170dd4cff9 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -14,6 +14,11 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + def teardown + Tab.clear_cache + super + end + def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block) @_f = Class.new(Formula, &block).new(name, path, spec, alias_path: alias_path) end From d86342a2519b6bdc5393302e3e81e5b72aa26e7f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:08:20 +0000 Subject: [PATCH 144/176] tests: reset ARGV in teardown --- Library/Homebrew/test/cleanup_test.rb | 2 -- Library/Homebrew/test/formula_installer_test.rb | 13 ++++--------- Library/Homebrew/test/support/helper/test_case.rb | 6 ++++++ Library/Homebrew/test/uninstall_test.rb | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index e27439e071..03ad6871e9 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -21,8 +21,6 @@ class CleanupTests < Homebrew::TestCase def teardown FileUtils.rm_f @ds_store - ARGV.delete "--dry-run" - ARGV.delete "--prune=all" super end diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index f86ae14883..5467be98a6 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -61,8 +61,6 @@ class InstallTests < Homebrew::TestCase assert_equal 3, bin.children.length assert_predicate f.prefix/".brew/testball.rb", :readable? end - ensure - ARGV.reject! { |a| a == "--with-invalid_flag" } end def test_bottle_unneeded_formula_install @@ -86,13 +84,10 @@ class InstallTests < Homebrew::TestCase cc_arg = "--cc=clang" ARGV << cc_arg - begin - temporary_install(TestballBottle.new) do |f| - tab = Tab.for_formula(f) - assert_equal "clang", tab.compiler - end - ensure - ARGV.delete_if { |x| x == cc_arg } + + temporary_install(TestballBottle.new) do |f| + tab = Tab.for_formula(f) + assert_equal "clang", tab.compiler end end end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 170dd4cff9..ebe5d3d224 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -14,8 +14,14 @@ module Homebrew TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze + def setup + super + @__argv = ARGV.dup + end + def teardown Tab.clear_cache + ARGV.replace(@__argv) super end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 4ab2f985ed..b517836e85 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -62,8 +62,6 @@ class UninstallTests < Homebrew::TestCase assert_empty handle_unsatisfied_dependents refute_predicate Homebrew, :failed? end - ensure - ARGV.delete("--ignore-dependencies") end end From d7b8420aaadf93b455a5c268777c3013f8ac2296 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:39:17 +0000 Subject: [PATCH 145/176] tests: clean up file system for all tests (No longer just integration tests.) --- .../test/checksum_verification_test.rb | 5 --- Library/Homebrew/test/cleaner_test.rb | 5 --- .../Homebrew/test/download_strategies_test.rb | 5 --- Library/Homebrew/test/formula_lock_test.rb | 1 - Library/Homebrew/test/formula_pin_test.rb | 5 --- Library/Homebrew/test/formula_test.rb | 6 ---- Library/Homebrew/test/formulary_test.rb | 16 ---------- Library/Homebrew/test/keg_test.rb | 9 +----- Library/Homebrew/test/migrator_test.rb | 18 +---------- Library/Homebrew/test/os/mac/keg_test.rb | 2 -- Library/Homebrew/test/patching_test.rb | 6 ---- .../helper/integration_command_test_case.rb | 30 ------------------ .../Homebrew/test/support/helper/test_case.rb | 31 ++++++++++++++++++- Library/Homebrew/test/tab_test.rb | 5 --- Library/Homebrew/test/tap_test.rb | 5 --- Library/Homebrew/test/uninstall_test.rb | 4 --- 16 files changed, 32 insertions(+), 121 deletions(-) diff --git a/Library/Homebrew/test/checksum_verification_test.rb b/Library/Homebrew/test/checksum_verification_test.rb index ad7dfb4628..4c674edd29 100644 --- a/Library/Homebrew/test/checksum_verification_test.rb +++ b/Library/Homebrew/test/checksum_verification_test.rb @@ -17,11 +17,6 @@ class ChecksumVerificationTests < Homebrew::TestCase end end - def teardown - @_f.clear_cache - super - end - def test_good_sha256 formula do sha256 TESTBALL_SHA256 diff --git a/Library/Homebrew/test/cleaner_test.rb b/Library/Homebrew/test/cleaner_test.rb index 413925dfa6..05a91b90b4 100644 --- a/Library/Homebrew/test/cleaner_test.rb +++ b/Library/Homebrew/test/cleaner_test.rb @@ -11,11 +11,6 @@ class CleanerTests < Homebrew::TestCase @f.prefix.mkpath end - def teardown - @f.rack.rmtree if @f.rack.exist? - super - end - def test_clean_file @f.bin.mkpath @f.lib.mkpath diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index fa69ec64ec..604671b1e7 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -149,11 +149,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase mkpath @cached_location end - def teardown - rmtree @cached_location - super - end - def git_commit_all shutup do system "git", "add", "--all" diff --git a/Library/Homebrew/test/formula_lock_test.rb b/Library/Homebrew/test/formula_lock_test.rb index d5bd0d07c5..13244555d0 100644 --- a/Library/Homebrew/test/formula_lock_test.rb +++ b/Library/Homebrew/test/formula_lock_test.rb @@ -10,7 +10,6 @@ class FormulaLockTests < Homebrew::TestCase def teardown @lock.unlock - HOMEBREW_LOCK_DIR.children.each(&:unlink) super end diff --git a/Library/Homebrew/test/formula_pin_test.rb b/Library/Homebrew/test/formula_pin_test.rb index 5dd2bd29e0..7e3c7efa04 100644 --- a/Library/Homebrew/test/formula_pin_test.rb +++ b/Library/Homebrew/test/formula_pin_test.rb @@ -48,9 +48,4 @@ class FormulaPinTests < Homebrew::TestCase refute_predicate @pin, :pinned? refute_predicate HOMEBREW_PINNED_KEGS, :directory? end - - def teardown - @f.rack.rmtree - super - end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 8293768fe0..1a1fe562ec 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -961,12 +961,6 @@ class OutdatedVersionsTests < Homebrew::TestCase @old_alias_target_prefix = HOMEBREW_CELLAR/"#{old_formula.name}/1.0" end - def teardown - formulae = [@f, @old_formula, @new_formula] - formulae.map(&:rack).select(&:exist?).each(&:rmtree) - super - end - def alias_path "#{@f.tap.alias_dir}/bar" end diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index 2ed5cd3f0e..f1fad404c9 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -40,11 +40,6 @@ class FormularyFactoryTest < Homebrew::TestCase EOS end - def teardown - @path.unlink - super - end - def test_factory assert_kind_of Formula, Formulary.factory(@name) end @@ -142,11 +137,6 @@ class FormularyTapFactoryTest < Homebrew::TestCase @path.write @code end - def teardown - @tap.path.rmtree - super - end - def test_factory_tap_formula assert_kind_of Formula, Formulary.factory(@name) end @@ -191,12 +181,6 @@ class FormularyTapPriorityTest < Homebrew::TestCase @tap_path.write code end - def teardown - @core_path.unlink - @tap.path.rmtree - super - end - def test_find_with_priority_core_formula formula = Formulary.find_with_priority(@name) assert_kind_of Formula, formula diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 08bda4699a..8f4cc44d90 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -36,16 +36,9 @@ class LinkTestCase < Homebrew::TestCase end def teardown - @kegs.each do |keg| - keg.unlink - keg.uninstall - end - + @kegs.each(&:unlink) $stdout = @old_stdout - - rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" - super end end diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 53151f3e32..84708a502e 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -72,31 +72,15 @@ class MigratorTests < Homebrew::TestCase end def teardown - @old_pin.unlink if @old_pin.symlink? - - if @old_keg_record.parent.symlink? - @old_keg_record.parent.unlink - elsif @old_keg_record.directory? + if !@old_keg_record.parent.symlink? && @old_keg_record.directory? @keg.unlink - @keg.uninstall end if @new_keg_record.directory? new_keg = Keg.new(@new_keg_record) new_keg.unlink - new_keg.uninstall end - @old_keg_record.parent.rmtree if @old_keg_record.parent.directory? - @new_keg_record.parent.rmtree if @new_keg_record.parent.directory? - - rmtree HOMEBREW_PREFIX/"bin" - rmtree HOMEBREW_PREFIX/"opt" if (HOMEBREW_PREFIX/"opt").directory? - # What to do with pin? - @new_f.unpin - - HOMEBREW_LOCK_DIR.children.each(&:unlink) - super end diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index 5f215bd06f..a2b6b2d506 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -30,11 +30,9 @@ class OSMacLinkTests < Homebrew::TestCase def teardown @keg.unlink - @keg.uninstall $stdout = @old_stdout - rmtree HOMEBREW_PREFIX/"bin" rmtree HOMEBREW_PREFIX/"lib" super diff --git a/Library/Homebrew/test/patching_test.rb b/Library/Homebrew/test/patching_test.rb index eadab15dc1..3dacc0818b 100644 --- a/Library/Homebrew/test/patching_test.rb +++ b/Library/Homebrew/test/patching_test.rb @@ -20,12 +20,6 @@ class PatchingTests < Homebrew::TestCase end end - def teardown - @_f.clear_cache - @_f.patchlist.each { |p| p.clear_cache if p.external? } - super - end - def assert_patched(formula) shutup do formula.brew do diff --git a/Library/Homebrew/test/support/helper/integration_command_test_case.rb b/Library/Homebrew/test/support/helper/integration_command_test_case.rb index 86184ac51e..a36b566916 100644 --- a/Library/Homebrew/test/support/helper/integration_command_test_case.rb +++ b/Library/Homebrew/test/support/helper/integration_command_test_case.rb @@ -12,36 +12,6 @@ class IntegrationCommandTestCase < Homebrew::TestCase FileUtils.touch HOMEBREW_PREFIX/"bin/brew" end - def teardown - coretap = CoreTap.new - paths_to_delete = [ - HOMEBREW_LINKED_KEGS, - HOMEBREW_PINNED_KEGS, - HOMEBREW_CELLAR.children, - HOMEBREW_CACHE.children, - HOMEBREW_LOCK_DIR.children, - HOMEBREW_LOGS.children, - HOMEBREW_TEMP.children, - HOMEBREW_PREFIX/".git", - HOMEBREW_PREFIX/"bin", - HOMEBREW_PREFIX/"share", - HOMEBREW_PREFIX/"opt", - HOMEBREW_PREFIX/"Caskroom", - HOMEBREW_LIBRARY/"Taps/caskroom", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", - HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", - HOMEBREW_REPOSITORY/".git", - coretap.path/".git", - coretap.alias_dir, - coretap.formula_dir.children, - coretap.path/"formula_renames.json", - ].flatten - FileUtils.rm_rf paths_to_delete - super - end - def needs_test_cmd_taps return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set" diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index ebe5d3d224..53d4e70317 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -20,8 +20,37 @@ module Homebrew end def teardown - Tab.clear_cache ARGV.replace(@__argv) + + Tab.clear_cache + + coretap = CoreTap.new + paths_to_delete = [ + HOMEBREW_LINKED_KEGS, + HOMEBREW_PINNED_KEGS, + HOMEBREW_CELLAR.children, + HOMEBREW_CACHE.children, + HOMEBREW_LOCK_DIR.children, + HOMEBREW_LOGS.children, + HOMEBREW_TEMP.children, + HOMEBREW_PREFIX/".git", + HOMEBREW_PREFIX/"bin", + HOMEBREW_PREFIX/"share", + HOMEBREW_PREFIX/"opt", + HOMEBREW_PREFIX/"Caskroom", + HOMEBREW_LIBRARY/"Taps/caskroom", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", + HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", + HOMEBREW_REPOSITORY/".git", + coretap.path/".git", + coretap.alias_dir, + coretap.formula_dir.children, + coretap.path/"formula_renames.json", + ].flatten + FileUtils.rm_rf paths_to_delete + super end diff --git a/Library/Homebrew/test/tab_test.rb b/Library/Homebrew/test/tab_test.rb index 5a354a908b..f6f55348d1 100644 --- a/Library/Homebrew/test/tab_test.rb +++ b/Library/Homebrew/test/tab_test.rb @@ -269,11 +269,6 @@ class TabLoadingTests < Homebrew::TestCase @path.write TEST_FIXTURE_DIR.join("receipt.json").read end - def teardown - @f.rack.rmtree - super - end - def test_for_keg tab = Tab.for_keg(@f.prefix) assert_equal @path, tab.tabfile diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 4990bc6df3..0e07927fcb 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -85,11 +85,6 @@ class TapTest < Homebrew::TestCase ENV.replace(env) end - def teardown - @path.rmtree - super - end - def test_fetch assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew") tap = Tap.fetch("Homebrew", "foo") diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index b517836e85..2f8bf4fffc 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -30,10 +30,6 @@ class UninstallTests < Homebrew::TestCase def teardown Homebrew.failed = false - [@dependency, @dependent].each do |f| - f.installed_kegs.each(&:remove_opt_record) - f.rack.rmtree - end super end From 1aee7c6945c3cbbbbfa2830bb1cf6bf39d4702be Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:55:42 +0000 Subject: [PATCH 146/176] tests: remove explicit tmpdir deletions These are no longer necessary. --- Library/Homebrew/test/audit_test.rb | 10 ---------- Library/Homebrew/test/language_python_test.rb | 5 ----- Library/Homebrew/test/pathname_test.rb | 6 ------ Library/Homebrew/test/sandbox_test.rb | 5 ----- Library/Homebrew/test/utils_test.rb | 1 - 5 files changed, 27 deletions(-) diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 0b13d3c2b2..f8d1374822 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -10,11 +10,6 @@ class FormulaTextTests < Homebrew::TestCase @dir = mktmpdir end - def teardown - FileUtils.rm_rf @dir - super - end - def formula_text(name, body = nil, options = {}) path = Pathname.new "#{@dir}/#{name}.rb" path.open("w") do |f| @@ -64,11 +59,6 @@ class FormulaAuditorTests < Homebrew::TestCase @dir = mktmpdir end - def teardown - FileUtils.rm_rf @dir - super - end - def formula_auditor(name, text, options = {}) path = Pathname.new "#{@dir}/#{name}.rb" path.open("w") do |f| diff --git a/Library/Homebrew/test/language_python_test.rb b/Library/Homebrew/test/language_python_test.rb index 0a6d1eeaaf..aa0a7d51dc 100644 --- a/Library/Homebrew/test/language_python_test.rb +++ b/Library/Homebrew/test/language_python_test.rb @@ -15,11 +15,6 @@ class LanguagePythonTests < Homebrew::TestCase @venv = Language::Python::Virtualenv::Virtualenv.new(@formula, @dir, "python") end - def teardown - FileUtils.rm_rf @dir - super - end - def test_virtualenv_creation @formula.expects(:resource).with("homebrew-virtualenv").returns( mock("resource", stage: true) diff --git a/Library/Homebrew/test/pathname_test.rb b/Library/Homebrew/test/pathname_test.rb index 2f4002b005..b48a26fbd3 100644 --- a/Library/Homebrew/test/pathname_test.rb +++ b/Library/Homebrew/test/pathname_test.rb @@ -13,12 +13,6 @@ module PathnameTestExtension @file = @src/"foo" @dir = @src/"bar" end - - def teardown - rmtree(@src) - rmtree(@dst) - super - end end class PathnameTests < Homebrew::TestCase diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 96558afa4e..2e97b5d6a2 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -10,11 +10,6 @@ class SandboxTest < Homebrew::TestCase @file = @dir/"foo" end - def teardown - @dir.rmtree - super - end - def test_formula? f = formula { url "foo-1.0" } f2 = formula { url "bar-1.0" } diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 310bfb1351..7099e332c2 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -11,7 +11,6 @@ class UtilTests < Homebrew::TestCase end def teardown - @dir.rmtree ENV.replace @env super end From 6861451f87316ce339af55eaa8e63e5ef8c5021b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 16:15:48 +0000 Subject: [PATCH 147/176] tests: remove more per-test file system cleanup These locations are now all automatically cleaned up after every test. --- Library/Homebrew/test/ARGV_test.rb | 2 - Library/Homebrew/test/cleanup_test.rb | 3 -- Library/Homebrew/test/diagnostic_test.rb | 2 - .../Homebrew/test/formula_installer_test.rb | 4 -- Library/Homebrew/test/formula_test.rb | 38 ------------------- Library/Homebrew/test/formulary_test.rb | 9 ----- Library/Homebrew/test/gpg_test.rb | 2 - Library/Homebrew/test/install_test.rb | 1 - Library/Homebrew/test/keg_test.rb | 6 --- Library/Homebrew/test/migrator_test.rb | 2 - Library/Homebrew/test/os/mac/keg_test.rb | 2 - Library/Homebrew/test/tap_test.rb | 7 ---- Library/Homebrew/test/versions_test.rb | 2 - 13 files changed, 80 deletions(-) diff --git a/Library/Homebrew/test/ARGV_test.rb b/Library/Homebrew/test/ARGV_test.rb index 06660defc3..e93d09c394 100644 --- a/Library/Homebrew/test/ARGV_test.rb +++ b/Library/Homebrew/test/ARGV_test.rb @@ -22,8 +22,6 @@ class ArgvExtensionTests < Homebrew::TestCase keg.mkpath @argv << "mxcl" assert_equal 1, @argv.kegs.length - ensure - keg.parent.rmtree end def test_argv_named diff --git a/Library/Homebrew/test/cleanup_test.rb b/Library/Homebrew/test/cleanup_test.rb index 03ad6871e9..8a292933aa 100644 --- a/Library/Homebrew/test/cleanup_test.rb +++ b/Library/Homebrew/test/cleanup_test.rb @@ -55,9 +55,6 @@ class CleanupTests < Homebrew::TestCase refute_predicate f1, :installed? refute_predicate f2, :installed? assert_predicate f3, :installed? - ensure - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_cleanup_logs diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index 608dda0993..2d12868273 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -105,8 +105,6 @@ class DiagnosticChecksTest < Homebrew::TestCase assert_match "/usr/bin occurs before #{HOMEBREW_PREFIX}/bin", @checks.check_user_path_1 - ensure - bin.rmtree end def test_check_user_path_bin diff --git a/Library/Homebrew/test/formula_installer_test.rb b/Library/Homebrew/test/formula_installer_test.rb index 5467be98a6..c99b2de74c 100644 --- a/Library/Homebrew/test/formula_installer_test.rb +++ b/Library/Homebrew/test/formula_installer_test.rb @@ -125,11 +125,7 @@ class FormulaInstallerTests < Homebrew::TestCase fi = FormulaInstaller.new(dependent) assert_raises(CannotInstallFormulaError) { fi.check_install_sanity } ensure - dependency.unpin dependency_keg.unlink - dependency_keg.uninstall - dependency.clear_cache - dep_path.unlink Formulary::FORMULAE.delete(dep_path) end end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 1a1fe562ec..a043423114 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -176,8 +176,6 @@ class FormulaTests < Homebrew::TestCase prefix.mkpath FileUtils.touch prefix+Tab::FILENAME assert_predicate f, :any_version_installed? - ensure - f.rack.rmtree end def test_migration_needed @@ -203,9 +201,6 @@ class FormulaTests < Homebrew::TestCase newname_prefix.mkpath refute_predicate f, :migration_needed? - ensure - oldname_prefix.parent.rmtree - newname_prefix.parent.rmtree end def test_installed? @@ -240,8 +235,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.head.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_devel_installed @@ -255,8 +248,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.devel.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_stable_installed @@ -270,8 +261,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR+f.name+f.version prefix.mkpath assert_equal prefix, f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_outdated_stable_head_installed @@ -289,8 +278,6 @@ class FormulaTests < Homebrew::TestCase tab.write assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_outdated_devel_head_installed @@ -311,8 +298,6 @@ class FormulaTests < Homebrew::TestCase tab.write assert_equal HOMEBREW_CELLAR/"#{f.name}/#{f.version}", f.installed_prefix - ensure - f.rack.rmtree end def test_installed_prefix_head @@ -358,8 +343,6 @@ class FormulaTests < Homebrew::TestCase prefix = HOMEBREW_CELLAR/"#{f.name}/HEAD-222222_2" assert_equal prefix, f.latest_head_prefix - ensure - f.rack.rmtree end def test_equality @@ -571,7 +554,6 @@ class FormulaTests < Homebrew::TestCase assert_equal Version.create("HEAD-5658946"), f.head.version ensure ENV.replace(initial_env) - cached_location.rmtree end def test_legacy_options @@ -771,9 +753,6 @@ class FormulaTests < Homebrew::TestCase assert_equal f3.installed_kegs.sort_by(&:version)[0..1], f3.eligible_kegs_for_cleanup.sort_by(&:version) - ensure - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_eligible_kegs_for_cleanup_keg_pinned @@ -795,10 +774,6 @@ class FormulaTests < Homebrew::TestCase assert_predicate f3, :installed? assert_equal [Keg.new(f2.prefix)], shutup { f3.eligible_kegs_for_cleanup } - ensure - f1.unpin - [f1, f2, f3].each(&:clear_cache) - f3.rack.rmtree end def test_eligible_kegs_for_cleanup_head_installed @@ -821,8 +796,6 @@ class FormulaTests < Homebrew::TestCase eligible_kegs = f.installed_kegs - [Keg.new(f.prefix("HEAD-111111_1"))] assert_equal eligible_kegs, f.eligible_kegs_for_cleanup - ensure - f.rack.rmtree end def test_pour_bottle @@ -1173,11 +1146,6 @@ class OutdatedVersionsTests < Homebrew::TestCase ensure ENV.replace(initial_env) testball_repo.rmtree if testball_repo.exist? - outdated_stable_prefix.rmtree if outdated_stable_prefix.exist? - head_prefix_b.rmtree if head_prefix.exist? - head_prefix_c.rmtree if head_prefix_c.exist? - FileUtils.rm_rf HOMEBREW_CACHE/"testball--git" - FileUtils.rm_rf HOMEBREW_CELLAR/"testball" end def test_outdated_kegs_version_scheme_changed @@ -1191,8 +1159,6 @@ class OutdatedVersionsTests < Homebrew::TestCase setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" }) refute_predicate f.outdated_kegs, :empty? - ensure - prefix.rmtree end def test_outdated_kegs_mixed_version_schemes @@ -1220,8 +1186,6 @@ class OutdatedVersionsTests < Homebrew::TestCase prefix_d = HOMEBREW_CELLAR.join("testball/20141011") setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 }) assert_predicate f.outdated_kegs, :empty? - ensure - f.rack.rmtree end def test_outdated_kegs_head_with_version_scheme @@ -1241,7 +1205,5 @@ class OutdatedVersionsTests < Homebrew::TestCase setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 }) assert_predicate f.outdated_kegs, :empty? - ensure - head_prefix.rmtree end end diff --git a/Library/Homebrew/test/formulary_test.rb b/Library/Homebrew/test/formulary_test.rb index f1fad404c9..ea7ecf8d05 100644 --- a/Library/Homebrew/test/formulary_test.rb +++ b/Library/Homebrew/test/formulary_test.rb @@ -58,8 +58,6 @@ class FormularyFactoryTest < Homebrew::TestCase path.write "class Wrong#{Formulary.class_s(name)} < Formula\nend\n" assert_raises(FormulaClassUnavailableError) { Formulary.factory(name) } - ensure - path.unlink end def test_factory_from_path @@ -87,8 +85,6 @@ class FormularyFactoryTest < Homebrew::TestCase result = Formulary.factory("foo") assert_kind_of Formula, result assert_equal alias_path.to_s, result.alias_path - ensure - alias_dir.rmtree end def test_factory_from_rack_and_from_keg @@ -104,9 +100,6 @@ class FormularyFactoryTest < Homebrew::TestCase assert_kind_of Tab, f.build ensure keg.unlink - keg.uninstall - formula.clear_cache - formula.bottle.clear_cache end def test_load_from_contents @@ -118,8 +111,6 @@ class FormularyFactoryTest < Homebrew::TestCase (HOMEBREW_CELLAR/@name).mkpath assert_equal HOMEBREW_CELLAR/@name, Formulary.to_rack(@name) assert_raises(TapFormulaUnavailableError) { Formulary.to_rack("a/b/#{@name}") } - ensure - FileUtils.rm_rf HOMEBREW_CELLAR/@name end end diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index 881468ad27..d3a6372971 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -15,7 +15,5 @@ class GpgTest < Homebrew::TestCase assert_predicate @dir/".gnupg/secring.gpg", :exist? end end - ensure - @dir.rmtree end end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index e047c00303..fa0ef5ffee 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -113,7 +113,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase ensure ENV.replace(initial_env) - repo_path.rmtree end def test_install_with_invalid_option diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index 8f4cc44d90..bd42320383 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -298,8 +298,6 @@ class LinkTests < LinkTestCase assert_equal 2, lib.children.length ensure a.unlink - a.uninstall - b.uninstall end def test_removes_broken_symlinks_that_conflict_with_directories @@ -315,7 +313,6 @@ class LinkTests < LinkTestCase keg.link ensure keg.unlink - keg.uninstall end end @@ -427,9 +424,6 @@ class InstalledDependantsTests < LinkTestCase result = Keg.find_some_installed_dependents([renamed_keg]) assert_equal [[renamed_keg], ["bar"]], result - ensure - # Move it back to where it was so it'll be cleaned up. - (HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo") end def test_empty_dependencies_in_tab diff --git a/Library/Homebrew/test/migrator_test.rb b/Library/Homebrew/test/migrator_test.rb index 84708a502e..012ea12bb0 100644 --- a/Library/Homebrew/test/migrator_test.rb +++ b/Library/Homebrew/test/migrator_test.rb @@ -32,8 +32,6 @@ class MigratorErrorsTests < Homebrew::TestCase tab.source["tap"] = "homebrew/core" tab.write assert_raises(Migrator::MigratorDifferentTapsError) { Migrator.new(@new_f) } - ensure - keg.parent.rmtree end end diff --git a/Library/Homebrew/test/os/mac/keg_test.rb b/Library/Homebrew/test/os/mac/keg_test.rb index a2b6b2d506..d1103415de 100644 --- a/Library/Homebrew/test/os/mac/keg_test.rb +++ b/Library/Homebrew/test/os/mac/keg_test.rb @@ -50,7 +50,6 @@ class OSMacLinkTests < Homebrew::TestCase assert_equal 1, keg.mach_o_files.size ensure keg.unlink - keg.uninstall end def test_mach_o_files_isnt_confused_by_symlinks @@ -66,6 +65,5 @@ class OSMacLinkTests < Homebrew::TestCase assert_equal 1, keg.mach_o_files.size ensure keg.unlink - keg.uninstall end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 0e07927fcb..2ab003fd27 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -168,8 +168,6 @@ class TapTest < Homebrew::TestCase end end refute_predicate services_tap, :private? - ensure - services_tap.path.rmtree if services_tap end def test_remote_not_git_repo @@ -253,8 +251,6 @@ class TapTest < Homebrew::TestCase refute_predicate tap, :installed? refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist? refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist? - ensure - (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? end def test_pin_and_unpin @@ -320,8 +316,5 @@ class CoreTapTest < Homebrew::TestCase assert_equal ["bar"], @repo.aliases assert_equal @repo.alias_table, "bar" => "foo" assert_equal @repo.alias_reverse_table, "foo" => ["bar"] - ensure - @formula_file.unlink - @repo.alias_dir.rmtree end end diff --git a/Library/Homebrew/test/versions_test.rb b/Library/Homebrew/test/versions_test.rb index a6e922178f..b6814b1d19 100644 --- a/Library/Homebrew/test/versions_test.rb +++ b/Library/Homebrew/test/versions_test.rb @@ -185,8 +185,6 @@ class VersionParsingTests < Homebrew::TestCase d = HOMEBREW_CELLAR/"foo-0.1.9" d.mkpath assert_equal version("0.1.9"), d.version - ensure - d.unlink end def test_no_version From 22f294af90ed08e2da9d0652fdc9c560c7797bed Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sun, 22 Jan 2017 19:50:14 +0800 Subject: [PATCH 148/176] bottle: fix regex Noted that this is intended for the revision of this formula instead of rebuild of a bottle. --- Library/Homebrew/dev-cmd/bottle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 75078cffd0..7367e5c372 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -443,7 +443,7 @@ module Homebrew (\n^\ {3}[\S\ ]+$)* # options can be in multiple lines )?| (homepage|desc|sha1|sha256|version|mirror)\ ['"][\S\ ]+['"]| # specs with a string - rebuild\ \d+ # rebuild with a number + revision\ \d+ # revision with a number )\n+ # multiple empty lines )+ /mx, '\0' + output + "\n" From 6e0f1366b014b285799c9bb9c311c6345bcd666b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:56:58 +0000 Subject: [PATCH 149/176] tests: extract a common using_git_env method --- .../Homebrew/test/download_strategies_test.rb | 12 ----- Library/Homebrew/test/formula_test.rb | 46 +++++++------------ Library/Homebrew/test/install_test.rb | 28 ++++------- Library/Homebrew/test/support/helper/env.rb | 28 +++++++++-- Library/Homebrew/test/tap_test.rb | 23 ++++------ 5 files changed, 57 insertions(+), 80 deletions(-) diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 604671b1e7..0a2068bd98 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -157,18 +157,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase end end - def using_git_env - initial_env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - yield - ensure - ENV.replace(initial_env) - end - def setup_git_repo using_git_env do @cached_location.cd do diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index a043423114..74db4ad6c2 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -526,8 +526,6 @@ class FormulaTests < Homebrew::TestCase end def test_update_head_version - initial_env = ENV.to_hash - f = formula do head "foo", using: :git end @@ -535,25 +533,19 @@ class FormulaTests < Homebrew::TestCase cached_location = f.head.downloader.cached_location cached_location.mkpath - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - cached_location.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" + using_git_env do + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end end end f.update_head_version assert_equal Version.create("HEAD-5658946"), f.head.version - ensure - ENV.replace(initial_env) end def test_legacy_options @@ -1104,7 +1096,6 @@ class OutdatedVersionsTests < Homebrew::TestCase tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" }) setup_tab_for_prefix(head_prefix_b) - initial_env = ENV.to_hash testball_repo = HOMEBREW_PREFIX.join("testball_repo") testball_repo.mkdir @@ -1114,18 +1105,14 @@ class OutdatedVersionsTests < Homebrew::TestCase head "file://#{testball_repo}", using: :git end - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - testball_repo.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" + using_git_env do + testball_repo.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" + end end end @@ -1144,7 +1131,6 @@ class OutdatedVersionsTests < Homebrew::TestCase reset_outdated_kegs assert_predicate f.outdated_kegs(fetch_head: true), :empty? ensure - ENV.replace(initial_env) testball_repo.rmtree if testball_repo.exist? end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index fa0ef5ffee..2ca5bf4ca1 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -73,24 +73,19 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase end def test_install_head_installed - initial_env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - repo_path = HOMEBREW_CACHE.join("repo") repo_path.join("bin").mkpath - repo_path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "bin/something.bin" - FileUtils.touch "README" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial repo commit" + using_git_env do + repo_path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "bin/something.bin" + FileUtils.touch "README" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial repo commit" + end end end @@ -110,9 +105,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase cmd("install", "testball1", "--HEAD", "--ignore-dependencies") assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1") assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1") - - ensure - ENV.replace(initial_env) end def test_install_with_invalid_option diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 904a1d4c71..6c69b335d5 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -1,14 +1,32 @@ module Test module Helper module Env + def copy_env + ENV.to_hash + end + + def restore_env(env) + ENV.replace(env) + end + def with_environment(partial_env) - old = ENV.to_hash + old = copy_env ENV.update partial_env - begin - yield - ensure - ENV.replace old + yield + ensure + restore_env old + end + + def using_git_env + initial_env = copy_env + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" end + yield + ensure + restore_env initial_env end end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 2ab003fd27..6656017f3b 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -66,23 +66,16 @@ class TapTest < Homebrew::TestCase end def setup_git_repo - env = ENV.to_hash - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" - end - - @path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - system "git", "add", "--all" - system "git", "commit", "-m", "init" + using_git_env do + @path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + system "git", "add", "--all" + system "git", "commit", "-m", "init" + end end end - ensure - ENV.replace(env) end def test_fetch From 116ed3ec80b6d1b9d6178f25793cfcaaaa161308 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 14:57:44 +0000 Subject: [PATCH 150/176] tests: automatically restore ENV in teardown --- Library/Homebrew/test/audit_test.rb | 3 --- Library/Homebrew/test/commands_test.rb | 4 ---- Library/Homebrew/test/diagnostic_test.rb | 6 ------ Library/Homebrew/test/os/mac/diagnostic_test.rb | 6 ------ Library/Homebrew/test/shell_test.rb | 3 --- Library/Homebrew/test/support/helper/test_case.rb | 3 +++ Library/Homebrew/test/utils_test.rb | 6 ------ 7 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index f8d1374822..75a882d693 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -361,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase end EOS - original_value = ENV["HOMEBREW_NO_GITHUB_API"] ENV["HOMEBREW_NO_GITHUB_API"] = "1" fa.audit_github_repository assert_equal [], fa.problems - ensure - ENV["HOMEBREW_NO_GITHUB_API"] = original_value end def test_audit_caveats diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb index 3d7c16e58f..5f5dc95865 100644 --- a/Library/Homebrew/test/commands_test.rb +++ b/Library/Homebrew/test/commands_test.rb @@ -47,8 +47,6 @@ class CommandsTests < Homebrew::TestCase end def test_external_commands - env = ENV.to_hash - mktmpdir do |dir| %w[brew-t1 brew-t2.rb brew-t3.py].each do |file| path = "#{dir}/#{file}" @@ -67,8 +65,6 @@ class CommandsTests < Homebrew::TestCase "Executable files with a non Ruby extension shoudn't be included" refute cmds.include?("t4"), "Non-executable files shouldn't be included" end - ensure - ENV.replace(env) end def test_internal_command_path diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb index 2d12868273..7a1fb25f79 100644 --- a/Library/Homebrew/test/diagnostic_test.rb +++ b/Library/Homebrew/test/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class DiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_inject_file_list assert_equal "foo:\n", @checks.inject_file_list([], "foo:\n") diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 284d293ca9..5f467e87be 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -6,15 +6,9 @@ require "diagnostic" class OSMacDiagnosticChecksTest < Homebrew::TestCase def setup super - @env = ENV.to_hash @checks = Homebrew::Diagnostic::Checks.new end - def teardown - ENV.replace(@env) - super - end - def test_check_for_other_package_managers MacOS.stubs(:macports_or_fink).returns ["fink"] assert_match "You have MacPorts or Fink installed:", diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb index 877acb5c8b..a32d098638 100644 --- a/Library/Homebrew/test/shell_test.rb +++ b/Library/Homebrew/test/shell_test.rb @@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase end def prepend_path_shell(shell, path, fragment) - original_shell = ENV["SHELL"] ENV["SHELL"] = shell prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) @@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase prepend_message.start_with?(fragment), "#{shell}: expected #{prepend_message} to match #{fragment}" ) - - ENV["SHELL"] = original_shell end def test_prepend_path_in_shell_profile diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 53d4e70317..c4c7f87275 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -16,11 +16,14 @@ module Homebrew def setup super + @__argv = ARGV.dup + @__env = copy_env # Call #to_hash to duplicate ENV end def teardown ARGV.replace(@__argv) + restore_env @__env Tab.clear_cache diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7099e332c2..7ff4e192ac 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -7,12 +7,6 @@ class UtilTests < Homebrew::TestCase def setup super @dir = Pathname.new(mktmpdir) - @env = ENV.to_hash - end - - def teardown - ENV.replace @env - super end def test_ofail From 0c1d665568875ffccb660a65ff248b7ab98ec77c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:11:49 +0000 Subject: [PATCH 151/176] tests: set developer in ENV rather than stubbing --- Library/Homebrew/test/audit_test.rb | 6 +++--- Library/Homebrew/test/os/mac/diagnostic_test.rb | 2 +- Library/Homebrew/test/utils_test.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index 75a882d693..60cf276106 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -243,7 +243,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = shutup do formula_auditor "foo", <<-EOS.undent class Foo < GithubGistFormula @@ -260,7 +260,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = formula_auditor "foo", <<-EOS.undent class Foo < ScriptFileFormula url "http://example.com/foo-1.0.tgz" @@ -275,7 +275,7 @@ class FormulaAuditorTests < Homebrew::TestCase needs_compat require "compat/formula_specialties" - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") fa = formula_auditor "foo", <<-EOS.undent class Foo < AmazonWebServicesFormula url "http://example.com/foo-1.0.tgz" diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb index 5f467e87be..704235b01c 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_test.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb @@ -16,7 +16,7 @@ class OSMacDiagnosticChecksTest < Homebrew::TestCase end def test_check_for_unsupported_macos - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") OS::Mac.stubs(:prerelease?).returns true assert_match "We do not provide support for this pre-release version.", @checks.check_for_unsupported_macos diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7ff4e192ac..520cd4fcdd 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -207,7 +207,7 @@ class UtilTests < Homebrew::TestCase end def test_odeprecated - ARGV.stubs(:homebrew_developer?).returns false + ENV.delete("HOMEBREW_DEVELOPER") e = assert_raises(MethodDeprecatedError) do odeprecated("method", "replacement", caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], From a736c7e3173fd7a9727026b5b968ac5f067a906d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:16:32 +0000 Subject: [PATCH 152/176] tests: set verbose in ENV instead of stubbing ARGV --- Library/Homebrew/test/sandbox_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 2e97b5d6a2..21a3ca8c40 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -47,7 +47,7 @@ class SandboxTest < Homebrew::TestCase def test_complains_on_failure Utils.expects(popen_read: "foo") - ARGV.stubs(verbose?: true) + ENV["HOMEBREW_VERBOSE"] = "1" out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end @@ -61,7 +61,7 @@ class SandboxTest < Homebrew::TestCase bar EOS Utils.expects(popen_read: with_bogus_error) - ARGV.stubs(verbose?: true) + ENV["HOMEBREW_VERBOSE"] = "1" out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end From 1e1de8c111b5c3a36e4bdf886d6f2e736890ba56 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 21 Jan 2017 15:46:28 +0000 Subject: [PATCH 153/176] tests: remove remainder of ARGV stubs I was waiting for confirmation that there wasn't a good reason for these to be stubbed before I removed them. --- Library/Homebrew/test/sandbox_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/sandbox_test.rb b/Library/Homebrew/test/sandbox_test.rb index 21a3ca8c40..a633defce2 100644 --- a/Library/Homebrew/test/sandbox_test.rb +++ b/Library/Homebrew/test/sandbox_test.rb @@ -15,11 +15,11 @@ class SandboxTest < Homebrew::TestCase f2 = formula { url "bar-1.0" } f2.stubs(:tap).returns(Tap.fetch("test/tap")) - ARGV.stubs(:sandbox?).returns true + ENV["HOMEBREW_SANDBOX"] = "1" assert Sandbox.formula?(f), "Formulae should be sandboxed if --sandbox was passed." - ARGV.stubs(:sandbox?).returns false + ENV.delete("HOMEBREW_SANDBOX") assert Sandbox.formula?(f), "Formulae should be sandboxed if in a sandboxed tap." refute Sandbox.formula?(f2), @@ -27,7 +27,7 @@ class SandboxTest < Homebrew::TestCase end def test_test? - ARGV.stubs(:no_sandbox?).returns false + ENV.delete("HOMEBREW_NO_SANDBOX") assert Sandbox.test?, "Tests should be sandboxed unless --no-sandbox was passed." end From cbc9e5dd3b0b47a98e3976ae1683641dbe94b57d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 11:10:06 +0000 Subject: [PATCH 154/176] tests: re-use with_environment in using_git_env Proposed by @reitermarkus in https://github.com/Homebrew/brew/pull/1890#discussion_r97210285. I made one slight adjustment of preserving the previous date string in case anything was relying on it. --- Library/Homebrew/test/support/helper/env.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 6c69b335d5..7e6429e743 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -18,15 +18,15 @@ module Test end def using_git_env - initial_env = copy_env - %w[AUTHOR COMMITTER].each do |role| - ENV["GIT_#{role}_NAME"] = "brew tests" - ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| + env["GIT_#{role}_NAME"] = "brew tests" + env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + env["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + + with_environment(git_env) do + yield end - yield - ensure - restore_env initial_env end end end From 9c3d01c682056367f59d557720c7a08ca67f48c4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 19:59:13 +0000 Subject: [PATCH 155/176] tests: remove unnecessary comment See https://github.com/Homebrew/brew/pull/1890#discussion_r97229473. --- Library/Homebrew/test/support/helper/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index c4c7f87275..801fa08c77 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -18,7 +18,7 @@ module Homebrew super @__argv = ARGV.dup - @__env = copy_env # Call #to_hash to duplicate ENV + @__env = copy_env end def teardown From b53ce62ffb193748266c63d7b13fd023c0764ff0 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 20:45:15 +0000 Subject: [PATCH 156/176] tests: use more recent git committer date This will allow the `brew bundle` test to use the default git environment. --- Library/Homebrew/test/download_strategies_test.rb | 6 +++--- Library/Homebrew/test/formula_test.rb | 2 +- Library/Homebrew/test/install_test.rb | 6 +++--- Library/Homebrew/test/support/helper/env.rb | 2 +- Library/Homebrew/test/tap_test.rb | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 0a2068bd98..3c4272c749 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -180,7 +180,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase def test_source_modified_time setup_git_repo - assert_equal 1_242_860_651, @strategy.source_modified_time.to_i + assert_equal 1_485_115_153, @strategy.source_modified_time.to_i end def test_last_commit @@ -191,7 +191,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase git_commit_all end end - assert_equal "c50c79b", @strategy.last_commit + assert_equal "f68266e", @strategy.last_commit end def test_fetch_last_commit @@ -216,7 +216,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase end @strategy.shutup! - assert_equal "c50c79b", @strategy.fetch_last_commit + assert_equal "f68266e", @strategy.fetch_last_commit ensure remote_repo.rmtree if remote_repo.directory? end diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 74db4ad6c2..b061113708 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -1090,7 +1090,7 @@ class OutdatedVersionsTests < Homebrew::TestCase outdated_stable_prefix = HOMEBREW_CELLAR.join("testball/1.0") head_prefix_a = HOMEBREW_CELLAR.join("testball/HEAD") head_prefix_b = HOMEBREW_CELLAR.join("testball/HEAD-aaaaaaa_1") - head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-5658946") + head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-18a7103") setup_tab_for_prefix(outdated_stable_prefix) tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" }) diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index 2ca5bf4ca1..3f3df6099b 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -100,10 +100,10 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase # Ignore dependencies, because we'll try to resolve requirements in build.rb # and there will be the git requirement, but we cannot instantiate git # formula since we only have testball1 formula. - assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") - assert_match "testball1-HEAD-2ccdf4f already installed", + assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") + assert_match "testball1-HEAD-d5eb689 already installed", cmd("install", "testball1", "--HEAD", "--ignore-dependencies") - assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1") + assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-d5eb689", cmd("unlink", "testball1") assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1") end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 7e6429e743..7958a041ef 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -21,7 +21,7 @@ module Test git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| env["GIT_#{role}_NAME"] = "brew tests" env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - env["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + env["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" end with_environment(git_env) do diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 6656017f3b..a268ab0ae9 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -177,10 +177,10 @@ class TapTest < Homebrew::TestCase touch @path/"README" setup_git_repo - assert_equal "e1893a6bd191ba895c71b652ff8376a6114c7fa7", @tap.git_head - assert_equal "e189", @tap.git_short_head - assert_match "years ago", @tap.git_last_commit - assert_equal "2009-05-21", @tap.git_last_commit_date + assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head + assert_equal "0453", @tap.git_short_head + assert_match "ago", @tap.git_last_commit + assert_equal "2017-01-22", @tap.git_last_commit_date end def test_private_remote From 19e61355b38b8ba96db0ca71849bb536af0490bf Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sun, 22 Jan 2017 20:54:37 +0000 Subject: [PATCH 157/176] tests: remove with_git_env method A common git environment is now used in all tests, so this is no longer required. --- Library/Homebrew/dev-cmd/tests.rb | 1 + .../Homebrew/test/download_strategies_test.rb | 40 ++++++++----------- Library/Homebrew/test/formula_test.rb | 28 ++++++------- Library/Homebrew/test/install_test.rb | 18 ++++----- Library/Homebrew/test/support/helper/env.rb | 12 ------ Library/Homebrew/test/tap_test.rb | 14 +++---- 6 files changed, 44 insertions(+), 69 deletions(-) diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index b4f3c2d40d..05bdda8d2e 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -34,6 +34,7 @@ module Homebrew %w[AUTHOR COMMITTER].each do |role| ENV["GIT_#{role}_NAME"] = "brew tests" ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" end Homebrew.install_gem_setup_path! "bundler" diff --git a/Library/Homebrew/test/download_strategies_test.rb b/Library/Homebrew/test/download_strategies_test.rb index 3c4272c749..40236b420a 100644 --- a/Library/Homebrew/test/download_strategies_test.rb +++ b/Library/Homebrew/test/download_strategies_test.rb @@ -158,15 +158,13 @@ class GitDownloadStrategyTests < Homebrew::TestCase end def setup_git_repo - using_git_env do - @cached_location.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all + @cached_location.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" end + touch "README" + git_commit_all end end @@ -185,11 +183,9 @@ class GitDownloadStrategyTests < Homebrew::TestCase def test_last_commit setup_git_repo - using_git_env do - @cached_location.cd do - touch "LICENSE" - git_commit_all - end + @cached_location.cd do + touch "LICENSE" + git_commit_all end assert_equal "f68266e", @strategy.last_commit end @@ -202,17 +198,15 @@ class GitDownloadStrategyTests < Homebrew::TestCase resource.instance_variable_set(:@version, Version.create("HEAD")) @strategy = GitDownloadStrategy.new("baz", resource) - using_git_env do - remote_repo.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - end - touch "README" - git_commit_all - touch "LICENSE" - git_commit_all + remote_repo.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" end + touch "README" + git_commit_all + touch "LICENSE" + git_commit_all end @strategy.shutup! diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index b061113708..ecdd1847b9 100644 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -533,14 +533,12 @@ class FormulaTests < Homebrew::TestCase cached_location = f.head.downloader.cached_location cached_location.mkpath - using_git_env do - cached_location.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" - end + cached_location.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" end end @@ -1105,14 +1103,12 @@ class OutdatedVersionsTests < Homebrew::TestCase head "file://#{testball_repo}", using: :git end - using_git_env do - testball_repo.cd do - FileUtils.touch "LICENSE" - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial commit" - end + testball_repo.cd do + FileUtils.touch "LICENSE" + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial commit" end end diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb index 3f3df6099b..da6c1863f5 100644 --- a/Library/Homebrew/test/install_test.rb +++ b/Library/Homebrew/test/install_test.rb @@ -76,16 +76,14 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase repo_path = HOMEBREW_CACHE.join("repo") repo_path.join("bin").mkpath - using_git_env do - repo_path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - FileUtils.touch "bin/something.bin" - FileUtils.touch "README" - system "git", "add", "--all" - system "git", "commit", "-m", "Initial repo commit" - end + repo_path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + FileUtils.touch "bin/something.bin" + FileUtils.touch "README" + system "git", "add", "--all" + system "git", "commit", "-m", "Initial repo commit" end end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb index 7958a041ef..88b25e237e 100644 --- a/Library/Homebrew/test/support/helper/env.rb +++ b/Library/Homebrew/test/support/helper/env.rb @@ -16,18 +16,6 @@ module Test ensure restore_env old end - - def using_git_env - git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env| - env["GIT_#{role}_NAME"] = "brew tests" - env["GIT_#{role}_EMAIL"] = "brew-tests@localhost" - env["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" - end - - with_environment(git_env) do - yield - end - end end end end diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index a268ab0ae9..9979be43d4 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -66,14 +66,12 @@ class TapTest < Homebrew::TestCase end def setup_git_repo - using_git_env do - @path.cd do - shutup do - system "git", "init" - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" - system "git", "add", "--all" - system "git", "commit", "-m", "init" - end + @path.cd do + shutup do + system "git", "init" + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" + system "git", "add", "--all" + system "git", "commit", "-m", "init" end end end From 70a5ebafc43d4ffab162956301ef4bf972f52b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Mon, 23 Jan 2017 01:13:58 +0000 Subject: [PATCH 158/176] cask - internal_stanza: arguments to args --- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index e5c04ee514..41d72e42d4 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -50,12 +50,12 @@ module Hbc :uninstall_postflight, ] - def self.run(*arguments) - table = arguments.include? "--table" - quiet = arguments.include? "--quiet" - format = :to_yaml if arguments.include? "--yaml" - format = :inspect if arguments.include? "--inspect" - cask_tokens = arguments.reject { |arg| arg.chars.first == "-" } + def self.run(*args) + table = args.include? "--table" + quiet = args.include? "--quiet" + format = :to_yaml if args.include? "--yaml" + format = :inspect if args.include? "--inspect" + cask_tokens = args.reject { |arg| arg.chars.first == "-" } stanza = cask_tokens.shift.to_sym cask_tokens = Hbc.all_tokens if cask_tokens.empty? From 16f4130dd81b45df697699f5bac7fa54489e8291 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 04:28:33 +0100 Subject: [PATCH 159/176] Add internal command to calculate appcast checkpoint. --- Library/Homebrew/cask/lib/hbc/audit.rb | 19 ++++---- Library/Homebrew/cask/lib/hbc/cli.rb | 1 + .../hbc/cli/internal_appcast_checkpoint.rb | 45 +++++++++++++++++++ Library/Homebrew/cask/lib/hbc/dsl/appcast.rb | 20 +++++++++ Library/Homebrew/cask/spec/cask/audit_spec.rb | 2 +- 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 955ecdbb00..12cefb9395 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -133,20 +133,19 @@ module Hbc def check_appcast_checkpoint_accuracy odebug "Verifying appcast checkpoint is accurate" - result = @command.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, cask.appcast], print_stderr: false) - if result.success? - processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") - # This step is necessary to replicate running `sed` from the command line - processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") + result = cask.appcast.calculate_checkpoint + + actual_checkpoint = result[:checkpoint] + + if actual_checkpoint.nil? + add_warning "error retrieving appcast: #{result[:command_result].stderr}" + else expected = cask.appcast.checkpoint - actual = Digest::SHA2.hexdigest(processed_appcast_text) - add_warning <<-EOS.undent unless expected == actual + add_warning <<-EOS.undent unless expected == actual_checkpoint appcast checkpoint mismatch Expected: #{expected} - Actual: #{actual} + Actual: #{actual_checkpoint} EOS - else - add_warning "error retrieving appcast: #{result.stderr}" end end diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 42c3982ba8..36fae30349 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -23,6 +23,7 @@ require "hbc/cli/zap" require "hbc/cli/internal_use_base" require "hbc/cli/internal_audit_modified_casks" +require "hbc/cli/internal_appcast_checkpoint" require "hbc/cli/internal_checkurl" require "hbc/cli/internal_dump" require "hbc/cli/internal_help" diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb new file mode 100644 index 0000000000..6de76cbc77 --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -0,0 +1,45 @@ +module Hbc + class CLI + class InternalAppcastCheckpoint < InternalUseBase + def self.run(*args) + cask_tokens = cask_tokens_from(args) + raise CaskUnspecifiedError if cask_tokens.empty? + + appcask_checkpoint(cask_tokens) + end + + def self.appcask_checkpoint(cask_tokens) + count = 0 + + cask_tokens.each do |cask_token| + cask = Hbc.load(cask_token) + + if cask.appcast.nil? + opoo "Cask '#{cask}' is missing an `appcast` stanza." + else + result = cask.appcast.calculate_checkpoint + + checkpoint = result[:checkpoint] + + if checkpoint.nil? + onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" + else + puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint + count += 1 + end + end + end + + count == cask_tokens.count + end + + def self.help + "calculates a given Cask's appcast checkpoint" + end + + def self.needs_init? + true + end + end + end +end diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb index 2f1245d3d9..94660e9366 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb @@ -1,3 +1,5 @@ +require "hbc/system_command" + module Hbc class DSL class Appcast @@ -9,6 +11,24 @@ module Hbc @checkpoint = @parameters[:checkpoint] end + def calculate_checkpoint + result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false) + + checkpoint = if result.success? + processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") + + # This step is necessary to replicate running `sed` from the command line + processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") + + Digest::SHA2.hexdigest(processed_appcast_text) + end + + { + checkpoint: checkpoint, + command_result: result, + } + end + def to_yaml [@uri, @parameters].to_yaml end diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index c12063a1d6..193b58fd60 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -162,7 +162,7 @@ describe Hbc::Audit do before do allow(audit).to receive(:check_appcast_http_code) - allow(fake_system_command).to receive(:run).and_return(fake_curl_result) + allow(Hbc::SystemCommand).to receive(:run).and_return(fake_curl_result) allow(fake_curl_result).to receive(:success?).and_return(success) end From 2de6d96a10f00f6dc828711166a53b768f97bbab Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 21:56:54 +0100 Subject: [PATCH 160/176] Change regex to catch multi-line `pubDate` tags. --- Library/Homebrew/cask/lib/hbc/dsl/appcast.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb index 94660e9366..e27870622c 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/appcast.rb @@ -15,11 +15,7 @@ module Hbc result = SystemCommand.run("/usr/bin/curl", args: ["--compressed", "--location", "--user-agent", URL::FAKE_USER_AGENT, @uri], print_stderr: false) checkpoint = if result.success? - processed_appcast_text = result.stdout.gsub(%r{[^<]*}, "") - - # This step is necessary to replicate running `sed` from the command line - processed_appcast_text << "\n" unless processed_appcast_text.end_with?("\n") - + processed_appcast_text = result.stdout.gsub(%r{[^<]*}m, "") Digest::SHA2.hexdigest(processed_appcast_text) end From 7d131de57dac25dbb7cf9a8f986c291de87f7e65 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 12:01:47 +0000 Subject: [PATCH 161/176] tests: slightly stricter match in tab test Suggested by @reitermarkus in https://github.com/Homebrew/brew/pull/1890#discussion_r97234536, and then I added the \A and \Z. --- Library/Homebrew/test/tap_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/tap_test.rb b/Library/Homebrew/test/tap_test.rb index 9979be43d4..578326cea8 100644 --- a/Library/Homebrew/test/tap_test.rb +++ b/Library/Homebrew/test/tap_test.rb @@ -177,7 +177,7 @@ class TapTest < Homebrew::TestCase assert_equal "0453e16c8e3fac73104da50927a86221ca0740c2", @tap.git_head assert_equal "0453", @tap.git_short_head - assert_match "ago", @tap.git_last_commit + assert_match(/\A\d+ .+ ago\Z/, @tap.git_last_commit) assert_equal "2017-01-22", @tap.git_last_commit_date end From b7dc56a8aa08e5783072ac728ed08ca597262835 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 22 Jan 2017 23:17:09 +0100 Subject: [PATCH 162/176] Delete with_environment from cask tests. --- Library/Homebrew/cask/spec/cask/cli_spec.rb | 16 ++++++++-------- Library/Homebrew/cask/test/cask/dsl_test.rb | 6 +++++- Library/Homebrew/cask/test/test_helper.rb | 2 -- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cask/spec/cask/cli_spec.rb b/Library/Homebrew/cask/spec/cask/cli_spec.rb index 9964275f10..6b2313a41c 100644 --- a/Library/Homebrew/cask/spec/cask/cli_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli_spec.rb @@ -39,17 +39,17 @@ describe Hbc::CLI do end it "respects the env variable when choosing what appdir to create" do - with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do - expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir")) - described_class.process("noop") - end + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir") + expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir")) + described_class.process("noop") end it "respects the env variable when choosing a non-default Caskroom location" do - with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do - expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir")) - described_class.process("noop") - end + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir") + expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir")) + described_class.process("noop") end it "exits with a status of 1 when something goes wrong" do diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb index 96d24a1a14..0ea928f40e 100644 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl_test.rb @@ -69,7 +69,11 @@ describe Hbc::DSL do end it "may use deprecated DSL version hash syntax" do - with_environment "HOMEBREW_DEVELOPER" => nil do + stub = proc do |arg| + arg == "HOMEBREW_DEVELOPER" ? nil : ENV[arg] + end + + ENV.stub :[], stub do shutup do test_cask = Hbc.load("with-dsl-version") test_cask.token.must_equal "with-dsl-version" diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb index 275ede3048..7315839f58 100644 --- a/Library/Homebrew/cask/test/test_helper.rb +++ b/Library/Homebrew/cask/test/test_helper.rb @@ -13,9 +13,7 @@ require "global" # add Homebrew-Cask to load path $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) -require "test/support/helper/env" require "test/support/helper/shutup" -include Test::Helper::Env include Test::Helper::Shutup def sudo(*args) From f7c6fc058f5eff55281fd7559b4217184162edcf Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 09:49:25 +0100 Subject: [PATCH 163/176] Remove legacy cask cache instead of migrating. --- Library/Homebrew/cask/lib/hbc.rb | 2 +- Library/Homebrew/cask/lib/hbc/cache.rb | 21 ++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index 69b6e8f21c..775b9229f0 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -46,7 +46,7 @@ module Hbc def self.init Cache.ensure_cache_exists - Cache.migrate_legacy_cache + Cache.delete_legacy_cache Caskroom.migrate_caskroom_from_repo_to_prefix Caskroom.ensure_caskroom_exists diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb index e343da3faf..7b586528ed 100644 --- a/Library/Homebrew/cask/lib/hbc/cache.rb +++ b/Library/Homebrew/cask/lib/hbc/cache.rb @@ -9,27 +9,10 @@ module Hbc Hbc.cache.mkpath end - def migrate_legacy_cache + def delete_legacy_cache return unless Hbc.legacy_cache.exist? - ohai "Migrating cached files to #{Hbc.cache}..." - Hbc.legacy_cache.children.select(&:symlink?).each do |symlink| - file = symlink.readlink - - new_name = file.basename - .sub(/\-((?:(\d|#{DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$/x, - '--\1') - - renamed_file = Hbc.cache.join(new_name) - - if file.exist? - puts "#{file} -> #{renamed_file}" - FileUtils.mv(file, renamed_file) - end - - FileUtils.rm(symlink) - end - + ohai "Deleting legacy cache at #{Hbc.legacy_cache}..." FileUtils.remove_entry_secure(Hbc.legacy_cache) end end From f23c127cde7b3e678555efc8c0d405247a6975b7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 14:19:14 +0100 Subject: [PATCH 164/176] Fix installer deleting artifacts if they already exist. --- Library/Homebrew/cask/lib/hbc/installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 3875e1c8fe..465011735e 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -141,8 +141,8 @@ module Hbc artifacts.each do |artifact| odebug "Installing artifact of class #{artifact}" - already_installed_artifacts.unshift(artifact) artifact.new(@cask, options).install_phase + already_installed_artifacts.unshift(artifact) end rescue StandardError => e begin From 62a0c3a6f5cd6577cf9e628524b88b91b9419df7 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2017 12:26:34 +0000 Subject: [PATCH 165/176] tests: remove env helper --- Library/Homebrew/cask/spec/spec_helper.rb | 2 -- .../Homebrew/test/gpg2_requirement_test.rb | 5 ++--- Library/Homebrew/test/gpg_test.rb | 7 +++---- Library/Homebrew/test/support/helper/env.rb | 21 ------------------- .../Homebrew/test/support/helper/test_case.rb | 6 ++---- 5 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 Library/Homebrew/test/support/helper/env.rb diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb index 458fe00f4f..162cb3b8f3 100644 --- a/Library/Homebrew/cask/spec/spec_helper.rb +++ b/Library/Homebrew/cask/spec/spec_helper.rb @@ -15,7 +15,6 @@ require "global" # add Homebrew-Cask to load path $LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s) -require "test/support/helper/env" require "test/support/helper/shutup" Pathname.glob(HOMEBREW_LIBRARY_PATH.join("cask", "spec", "support", "*.rb")).each(&method(:require)) @@ -38,6 +37,5 @@ end RSpec.configure do |config| config.order = :random - config.include(Test::Helper::Env) config.include(Test::Helper::Shutup) end diff --git a/Library/Homebrew/test/gpg2_requirement_test.rb b/Library/Homebrew/test/gpg2_requirement_test.rb index b45798b420..3297c28512 100644 --- a/Library/Homebrew/test/gpg2_requirement_test.rb +++ b/Library/Homebrew/test/gpg2_requirement_test.rb @@ -19,8 +19,7 @@ class GPG2RequirementTests < Homebrew::TestCase end def test_satisfied - with_environment("PATH" => @dir/"bin") do - assert_predicate GPG2Requirement.new, :satisfied? - end + ENV["PATH"] = @dir/"bin" + assert_predicate GPG2Requirement.new, :satisfied? end end diff --git a/Library/Homebrew/test/gpg_test.rb b/Library/Homebrew/test/gpg_test.rb index d3a6372971..ea43725491 100644 --- a/Library/Homebrew/test/gpg_test.rb +++ b/Library/Homebrew/test/gpg_test.rb @@ -10,10 +10,9 @@ class GpgTest < Homebrew::TestCase def test_create_test_key Dir.chdir(@dir) do - with_environment("HOME" => @dir) do - shutup { Gpg.create_test_key(@dir) } - assert_predicate @dir/".gnupg/secring.gpg", :exist? - end + ENV["HOME"] = @dir + shutup { Gpg.create_test_key(@dir) } + assert_predicate @dir/".gnupg/secring.gpg", :exist? end end end diff --git a/Library/Homebrew/test/support/helper/env.rb b/Library/Homebrew/test/support/helper/env.rb deleted file mode 100644 index 88b25e237e..0000000000 --- a/Library/Homebrew/test/support/helper/env.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Test - module Helper - module Env - def copy_env - ENV.to_hash - end - - def restore_env(env) - ENV.replace(env) - end - - def with_environment(partial_env) - old = copy_env - ENV.update partial_env - yield - ensure - restore_env old - end - end - end -end diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb index 801fa08c77..ab97ef7589 100644 --- a/Library/Homebrew/test/support/helper/test_case.rb +++ b/Library/Homebrew/test/support/helper/test_case.rb @@ -1,11 +1,9 @@ module Homebrew class TestCase < ::Minitest::Test - require "test/support/helper/env" require "test/support/helper/fs_leak_logger" require "test/support/helper/lifecycle_enforcer" require "test/support/helper/shutup" require "test/support/helper/version_assertions" - include Test::Helper::Env include Test::Helper::FSLeakLogger include Test::Helper::LifecycleEnforcer include Test::Helper::Shutup @@ -18,12 +16,12 @@ module Homebrew super @__argv = ARGV.dup - @__env = copy_env + @__env = ENV.to_hash # dup doesn't work on ENV end def teardown ARGV.replace(@__argv) - restore_env @__env + ENV.replace(@__env) Tab.clear_cache From e8f67eb13dd9015172f62937e4be210506fa2cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Mon, 23 Jan 2017 01:16:07 +0000 Subject: [PATCH 166/176] cask - internal stanzas: lowercase help --- Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/internal_help.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb index af1494e5f9..ac1b204939 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb @@ -27,7 +27,7 @@ module Hbc end def self.help - "Dump the given Cask in YAML format" + "dump the given Cask in YAML format" end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb index 6c646cfd7f..0908ee05ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb @@ -16,7 +16,7 @@ module Hbc end def self.help - "Print help strings for unstable internal-use commands" + "print help strings for unstable internal-use commands" end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 41d72e42d4..f0c49c0df9 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -125,7 +125,7 @@ module Hbc end def self.help - "Extract and render a specific stanza for the given Casks" + "extract and render a specific stanza for the given Casks" end end end From a64e2835adcd133b2db3eecde5808a74147dc565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Mon, 23 Jan 2017 01:54:36 +0000 Subject: [PATCH 167/176] cask - internal_stanza: use cask_tokens_from(args) --- Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index f0c49c0df9..105e946d75 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -55,7 +55,7 @@ module Hbc quiet = args.include? "--quiet" format = :to_yaml if args.include? "--yaml" format = :inspect if args.include? "--inspect" - cask_tokens = args.reject { |arg| arg.chars.first == "-" } + cask_tokens = cask_tokens_from(args) stanza = cask_tokens.shift.to_sym cask_tokens = Hbc.all_tokens if cask_tokens.empty? From 53e232fc7e2f5f9372ba9b544e01abf99f96c99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Galv=C3=A3o?= Date: Mon, 23 Jan 2017 01:03:19 +0000 Subject: [PATCH 168/176] Add --calculate (print current checkpoint without it) --- .../lib/hbc/cli/internal_appcast_checkpoint.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index 6de76cbc77..fc2d1049fc 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -2,13 +2,14 @@ module Hbc class CLI class InternalAppcastCheckpoint < InternalUseBase def self.run(*args) + calculate = args.include? "--calculate" cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? - appcask_checkpoint(cask_tokens) + appcask_checkpoint(cask_tokens, calculate) end - def self.appcask_checkpoint(cask_tokens) + def self.appcask_checkpoint(cask_tokens, calculate) count = 0 cask_tokens.each do |cask_token| @@ -17,9 +18,13 @@ module Hbc if cask.appcast.nil? opoo "Cask '#{cask}' is missing an `appcast` stanza." else - result = cask.appcast.calculate_checkpoint + if calculate + result = cask.appcast.calculate_checkpoint - checkpoint = result[:checkpoint] + checkpoint = result[:checkpoint] + else + checkpoint = cask.appcast.checkpoint + end if checkpoint.nil? onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" @@ -34,7 +39,7 @@ module Hbc end def self.help - "calculates a given Cask's appcast checkpoint" + "prints (no flag) or calculates ('--calculate') a given Cask's appcast checkpoint" end def self.needs_init? From 2d5b659b0e4ba396f133156d368afc4fa1b8373c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 09:22:51 +0100 Subject: [PATCH 169/176] Add support for calculating appcast checkpoint from URLs. --- .../lib/hbc/cli/internal_appcast_checkpoint.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index fc2d1049fc..915ec314bb 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -6,7 +6,18 @@ module Hbc cask_tokens = cask_tokens_from(args) raise CaskUnspecifiedError if cask_tokens.empty? - appcask_checkpoint(cask_tokens, calculate) + if cask_tokens.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ } + appcask_checkpoint_for_url(cask_tokens) + else + appcask_checkpoint(cask_tokens, calculate) + end + end + + def self.appcask_checkpoint_for_url(urls) + urls.each do |url| + appcast = DSL::Appcast.new(url) + puts appcast.calculate_checkpoint[:checkpoint] + end end def self.appcask_checkpoint(cask_tokens, calculate) @@ -39,7 +50,7 @@ module Hbc end def self.help - "prints (no flag) or calculates ('--calculate') a given Cask's appcast checkpoint" + "prints (no flag) or calculates ('--calculate') a given Cask's (or URL's) appcast checkpoint" end def self.needs_init? From e12c1db231cd619408574d63ecf38f883745e1ee Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 23 Jan 2017 15:03:03 +0000 Subject: [PATCH 170/176] official_taps: remove homebrew/gui. This was deprecated and had all formulae removed in: https://github.com/Homebrew/homebrew-gui/pull/52 --- Library/Homebrew/official_taps.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/official_taps.rb b/Library/Homebrew/official_taps.rb index c1ef431b68..f2afea6140 100644 --- a/Library/Homebrew/official_taps.rb +++ b/Library/Homebrew/official_taps.rb @@ -5,7 +5,6 @@ OFFICIAL_TAPS = %w[ emacs fuse games - gui nginx php python From 2076b494a6233630025acd45d9a5766bd6bb785d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 23 Jan 2017 16:23:01 +0100 Subject: [PATCH 171/176] Add manpage entry for _appcast_checkpoint. --- .../cask/lib/hbc/cli/internal_appcast_checkpoint.rb | 2 +- Library/Homebrew/manpages/brew-cask.1.md | 7 +++++++ manpages/brew-cask.1 | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb index 915ec314bb..790e917b22 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb @@ -50,7 +50,7 @@ module Hbc end def self.help - "prints (no flag) or calculates ('--calculate') a given Cask's (or URL's) appcast checkpoint" + "prints or calculates a given Cask's or URL's appcast checkpoint" end def self.needs_init? diff --git a/Library/Homebrew/manpages/brew-cask.1.md b/Library/Homebrew/manpages/brew-cask.1.md index f0a70d4a76..a2c9c8c165 100644 --- a/Library/Homebrew/manpages/brew-cask.1.md +++ b/Library/Homebrew/manpages/brew-cask.1.md @@ -120,6 +120,13 @@ names, and other aspects of this manual are still subject to change. **`zap` may remove files which are shared between applications.** +## INTERNAL COMMANDS + + * `_appcast_checkpoint` [--calculate] [ ... | ... ]: + Given a `token`, returns the current appcast checkpoint, or calculates + the appcast checkpoint if the `--calculate` flag is specified. + Given a `URL`, calculates the appcast checkpoint for it. + ## OPTIONS To make these options persistent, see the ENVIRONMENT section, below. diff --git a/manpages/brew-cask.1 b/manpages/brew-cask.1 index 63aad2c56c..9b217fed54 100644 --- a/manpages/brew-cask.1 +++ b/manpages/brew-cask.1 @@ -105,6 +105,15 @@ If the Cask definition contains a \fBzap\fR stanza, performs additional \fBzap\f . .IP "" 0 . +.SH "INTERNAL COMMANDS" +. +.TP +\fB_appcast_checkpoint\fR [\-\-calculate] [ \fItoken\fR \.\.\. | \fIURL\fR \.\.\. ] +Given a \fBtoken\fR, returns the current appcast checkpoint, or calculates the appcast checkpoint if the \fB\-\-calculate\fR flag is specified\. +. +.br +Given a \fBURL\fR, calculates the appcast checkpoint for it\. +. .SH "OPTIONS" To make these options persistent, see the ENVIRONMENT section, below\. . From 13488183bd3fe9d0f8e84d66075c9c7d4cdc931d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 12:27:49 +0000 Subject: [PATCH 172/176] emoji: remove hack required for Ruby 1.8.7 Since this hack is no longer required, and `Emoji.tick` and `.cross` are only called in one place, I think it's better to just inline them there rather than having methods on `Emoji` that just return a one-character String. --- Library/Homebrew/emoji.rb | 12 +----------- Library/Homebrew/utils.rb | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb index 8c58ca8952..43fa781e6b 100644 --- a/Library/Homebrew/emoji.rb +++ b/Library/Homebrew/emoji.rb @@ -1,17 +1,7 @@ module Emoji class << self - def tick - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @tick ||= ["2714".hex].pack("U*") - end - - def cross - # necessary for 1.8.7 unicode handling since many installs are on 1.8.7 - @cross ||= ["2718".hex].pack("U*") - end - def install_badge - ENV["HOMEBREW_INSTALL_BADGE"] || "\xf0\x9f\x8d\xba" + ENV["HOMEBREW_INSTALL_BADGE"] || "🍺" end def enabled? diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 614d50eeae..70d2787d97 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -106,7 +106,7 @@ def pretty_installed(f) if !$stdout.tty? f.to_s elsif Emoji.enabled? - "#{Tty.bold}#{f} #{Formatter.success(Emoji.tick)}#{Tty.reset}" + "#{Tty.bold}#{f} #{Formatter.success("✔")}#{Tty.reset}" else Formatter.success("#{Tty.bold}#{f} (installed)#{Tty.reset}") end @@ -116,7 +116,7 @@ def pretty_uninstalled(f) if !$stdout.tty? f.to_s elsif Emoji.enabled? - "#{Tty.bold}#{f} #{Formatter.error(Emoji.cross)}#{Tty.reset}" + "#{Tty.bold}#{f} #{Formatter.error("✘")}#{Tty.reset}" else Formatter.error("#{Tty.bold}#{f} (uninstalled)#{Tty.reset}") end From b0fea9eb6c7dfc39bbd8083180a7156b9b859571 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 12:30:47 +0000 Subject: [PATCH 173/176] fileutils: update Ruby documentation URL --- Library/Homebrew/extend/fileutils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 4f20d36a3b..287a1408f4 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -3,7 +3,7 @@ require "tmpdir" require "etc" # Homebrew extends Ruby's `FileUtils` to make our code more readable. -# @see http://ruby-doc.org/stdlib-1.8.7/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API +# @see http://ruby-doc.org/stdlib-2.0.0/libdoc/fileutils/rdoc/FileUtils.html Ruby's FileUtils API module FileUtils # Create a temporary directory then yield. When the block returns, # recursively delete the temporary directory. Passing opts[:retain] From 50c1fea4ea9ca8067e194db5918fbf5a7f5c3ca1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 23 Jan 2017 21:22:54 +0000 Subject: [PATCH 174/176] xcode: reduce minimum CLT version. This should be 1.0.0 to be nicer to 10.7 users. Fixes #1893. --- Library/Homebrew/os/mac/xcode.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index e85f21c631..aa4504a179 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -226,7 +226,7 @@ module OS def minimum_version case MacOS.version when "10.12" then "8.0.0" - else "4.0.0" + else "1.0.0" end end From 65dde58057029d473be9175444b333525fe82850 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 20 Jan 2017 17:27:08 +0000 Subject: [PATCH 175/176] =?UTF-8?q?tests:=20add=20some=20emoji=20tests=20?= =?UTF-8?q?=F0=9F=92=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Homebrew/test/emoji_test.rb | 11 +++++++++++ Library/Homebrew/test/utils_test.rb | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Library/Homebrew/test/emoji_test.rb diff --git a/Library/Homebrew/test/emoji_test.rb b/Library/Homebrew/test/emoji_test.rb new file mode 100644 index 0000000000..ea68db8f6e --- /dev/null +++ b/Library/Homebrew/test/emoji_test.rb @@ -0,0 +1,11 @@ +require "testing_env" +require "emoji" + +class EmojiTest < Homebrew::TestCase + def test_install_badge + assert_equal "🍺", Emoji.install_badge + + ENV["HOMEBREW_INSTALL_BADGE"] = "foo" + assert_equal "foo", Emoji.install_badge + end +end diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 520cd4fcdd..7ae5793e2b 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -9,6 +9,14 @@ class UtilTests < Homebrew::TestCase @dir = Pathname.new(mktmpdir) end + # Helper for matching escape sequences. + def e(code) + /(\e\[\d+m)*\e\[#{code}m/ + end + + # Helper for matching that style is reset at the end of a string. + Z = /(\e\[\d+m)*\e\[0m\Z/ + def test_ofail shutup { ofail "foo" } assert Homebrew.failed? @@ -22,11 +30,25 @@ class UtilTests < Homebrew::TestCase end def test_pretty_installed + $stdout.stubs(:tty?).returns true + ENV.delete("HOMEBREW_NO_EMOJI") + assert_match(/\A#{e 1}foo #{e 32}✔#{Z}/, pretty_installed("foo")) + + ENV["HOMEBREW_NO_EMOJI"] = "1" + assert_match(/\A#{e 1}foo \(installed\)#{Z}/, pretty_installed("foo")) + $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_installed("foo") end def test_pretty_uninstalled + $stdout.stubs(:tty?).returns true + ENV.delete("HOMEBREW_NO_EMOJI") + assert_match(/\A#{e 1}foo #{e 31}✘#{Z}/, pretty_uninstalled("foo")) + + ENV["HOMEBREW_NO_EMOJI"] = "1" + assert_match(/\A#{e 1}foo \(uninstalled\)#{Z}/, pretty_uninstalled("foo")) + $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_uninstalled("foo") end From 5480a84114243fcd0aedda3a650b23b59ae91b2c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 Jan 2017 18:24:31 +0000 Subject: [PATCH 176/176] tests: give `e` helper in UtilTests a better name --- Library/Homebrew/test/utils_test.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb index 7ae5793e2b..1f2fb7b55f 100644 --- a/Library/Homebrew/test/utils_test.rb +++ b/Library/Homebrew/test/utils_test.rb @@ -9,14 +9,10 @@ class UtilTests < Homebrew::TestCase @dir = Pathname.new(mktmpdir) end - # Helper for matching escape sequences. - def e(code) + def esc(code) /(\e\[\d+m)*\e\[#{code}m/ end - # Helper for matching that style is reset at the end of a string. - Z = /(\e\[\d+m)*\e\[0m\Z/ - def test_ofail shutup { ofail "foo" } assert Homebrew.failed? @@ -32,10 +28,12 @@ class UtilTests < Homebrew::TestCase def test_pretty_installed $stdout.stubs(:tty?).returns true ENV.delete("HOMEBREW_NO_EMOJI") - assert_match(/\A#{e 1}foo #{e 32}✔#{Z}/, pretty_installed("foo")) + tty_with_emoji_output = /\A#{esc 1}foo #{esc 32}✔#{esc 0}\Z/ + assert_match tty_with_emoji_output, pretty_installed("foo") ENV["HOMEBREW_NO_EMOJI"] = "1" - assert_match(/\A#{e 1}foo \(installed\)#{Z}/, pretty_installed("foo")) + tty_no_emoji_output = /\A#{esc 1}foo \(installed\)#{esc 0}\Z/ + assert_match tty_no_emoji_output, pretty_installed("foo") $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_installed("foo") @@ -44,10 +42,12 @@ class UtilTests < Homebrew::TestCase def test_pretty_uninstalled $stdout.stubs(:tty?).returns true ENV.delete("HOMEBREW_NO_EMOJI") - assert_match(/\A#{e 1}foo #{e 31}✘#{Z}/, pretty_uninstalled("foo")) + tty_with_emoji_output = /\A#{esc 1}foo #{esc 31}✘#{esc 0}\Z/ + assert_match tty_with_emoji_output, pretty_uninstalled("foo") ENV["HOMEBREW_NO_EMOJI"] = "1" - assert_match(/\A#{e 1}foo \(uninstalled\)#{Z}/, pretty_uninstalled("foo")) + tty_no_emoji_output = /\A#{esc 1}foo \(uninstalled\)#{esc 0}\Z/ + assert_match tty_no_emoji_output, pretty_uninstalled("foo") $stdout.stubs(:tty?).returns false assert_equal "foo", pretty_uninstalled("foo")