diff options
| -rw-r--r-- | Library/.rubocop.yml | 3 | ||||
| -rw-r--r-- | Library/Homebrew/brew.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/brew.sh | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/update.sh | 2 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/tests.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/language/python_virtualenv_constants.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/pkgconfig/10.13/sqlite3.pc | 2 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/conflicts_cop.rb | 27 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/extend/formula_cop.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/sandbox.rb | 1 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/conflicts_cop_spec.rb | 47 | ||||
| -rw-r--r-- | Library/Homebrew/test/spec_helper.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb | 47 | ||||
| -rw-r--r-- | docs/Acceptable-Formulae.md | 56 | ||||
| -rw-r--r-- | docs/Python-for-Formula-Authors.md | 8 | ||||
| -rw-r--r-- | docs/README.md | 2 |
19 files changed, 157 insertions, 77 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index dbff189ef..6bfb669fd 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -18,6 +18,9 @@ FormulaAudit/Checksum: FormulaAudit/ChecksumCase: Enabled: true +FormulaAudit/Conflicts: + Enabled: true + FormulaAuditStrict/BottleBlock: Enabled: true diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 11ea8df67..ec86bd794 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -11,7 +11,9 @@ raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO require "pathname" HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent require "English" -$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) +unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s) + $LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s) +end require "global" require "tap" diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 97c3b7f86..638e9dc19 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -1,4 +1,4 @@ -HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty 2>/dev/null)" +HOMEBREW_VERSION="$(git -C "$HOMEBREW_REPOSITORY" describe --tags --dirty --abbrev=7 2>/dev/null)" HOMEBREW_USER_AGENT_VERSION="$HOMEBREW_VERSION" if [[ -z "$HOMEBREW_VERSION" ]] then diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 77a5c1cd2..fb6a3459c 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -336,7 +336,7 @@ homebrew-update() { *) odie <<EOS This command updates brew itself, and does not take formula names. -Use 'brew upgrade <formula>'. +Use 'brew upgrade $@' instead. EOS ;; esac diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ff6b17b45..3bbfa461a 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -519,15 +519,6 @@ class FormulaAuditor problem "Ambiguous conflicting formula #{c.name.inspect}." end end - - versioned_conflicts_whitelist = %w[node@ bash-completion@].freeze - - return unless formula.conflicts.any? && formula.versioned_formula? - return if formula.name.start_with?(*versioned_conflicts_whitelist) - problem <<-EOS - Versioned formulae should not use `conflicts_with`. - Use `keg_only :versioned_formula` instead. - EOS end def audit_keg_only_style diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 658f2e2f3..af9dcc575 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -53,10 +53,7 @@ module Homebrew ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000" end - # TODO: unpin this version when this error no longer shows: - # bundler-1.15.0/lib/bundler/shared_helpers.rb:25: - # stack level too deep (SystemStackError) - Homebrew.install_gem_setup_path! "bundler", "1.14.6" + Homebrew.install_gem_setup_path! "bundler" system "bundle", "install" unless quiet_system("bundle", "check") parallel = true diff --git a/Library/Homebrew/language/python_virtualenv_constants.rb b/Library/Homebrew/language/python_virtualenv_constants.rb index c8b71aa85..4efd2ce1d 100644 --- a/Library/Homebrew/language/python_virtualenv_constants.rb +++ b/Library/Homebrew/language/python_virtualenv_constants.rb @@ -1,2 +1,2 @@ -PYTHON_VIRTUALENV_URL = "https://files.pythonhosted.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz".freeze -PYTHON_VIRTUALENV_SHA256 = "fab40f32d9ad298fba04a260f3073505a16d52539a84843cf8c8369d4fd17167".freeze +PYTHON_VIRTUALENV_URL = "https://files.pythonhosted.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz".freeze +PYTHON_VIRTUALENV_SHA256 = "02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a".freeze diff --git a/Library/Homebrew/os/mac/pkgconfig/10.13/sqlite3.pc b/Library/Homebrew/os/mac/pkgconfig/10.13/sqlite3.pc index aa78d2c1d..86ac8b0ce 100644 --- a/Library/Homebrew/os/mac/pkgconfig/10.13/sqlite3.pc +++ b/Library/Homebrew/os/mac/pkgconfig/10.13/sqlite3.pc @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: SQLite Description: SQL database engine -Version: 3.18.0 +Version: 3.19.3 Libs: -L${libdir} -lsqlite3 Libs.private: Cflags: -I${includedir} diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 1d70c3981..ec38512e8 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -216,7 +216,7 @@ module OS # on the older supported platform for that Xcode release, i.e there's no # CLT package for 10.11 that contains the Clang version from Xcode 8. case MacOS.version - when "10.13" then "900.0.26" + when "10.13" then "900.0.28.1" when "10.12" then "802.0.42" when "10.11" then "800.0.42.1" when "10.10" then "700.1.81" diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb index e27f91867..81ea2fcf2 100644 --- a/Library/Homebrew/rubocops.rb +++ b/Library/Homebrew/rubocops.rb @@ -7,3 +7,4 @@ require_relative "./rubocops/text_cop" require_relative "./rubocops/caveats_cop" require_relative "./rubocops/checksum_cop" require_relative "./rubocops/legacy_patches_cop" +require_relative "./rubocops/conflicts_cop" diff --git a/Library/Homebrew/rubocops/conflicts_cop.rb b/Library/Homebrew/rubocops/conflicts_cop.rb new file mode 100644 index 000000000..c1b801559 --- /dev/null +++ b/Library/Homebrew/rubocops/conflicts_cop.rb @@ -0,0 +1,27 @@ +require_relative "./extend/formula_cop" +require_relative "../extend/string" + +module RuboCop + module Cop + module FormulaAudit + # This cop audits versioned Formulae for `conflicts_with` + class Conflicts < FormulaCop + MSG = <<-EOS.undent + Versioned formulae should not use `conflicts_with`. + Use `keg_only :versioned_formula` instead. + EOS + + WHITELIST = %w[ + node@ + bash-completion@ + ].freeze + + def audit_formula(_node, _class_node, _parent_class_node, body) + return unless versioned_formula? + problem MSG if !formula_file_name.start_with?(*WHITELIST) && + method_called_ever?(body, :conflicts_with) + end + end + end + end +end diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 439fde6a5..ddfb507d2 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -344,6 +344,16 @@ module RuboCop end end + # Returns true if the formula is versioned + def versioned_formula? + formula_file_name.include?("@") || @formula_name.match(/AT\d+/) + end + + # Returns filename of the formula without the extension + def formula_file_name + File.basename(processed_source.buffer.name, ".rb") + end + # Returns printable component name def format_component(component_node) return component_node.method_name if component_node.send_type? || component_node.block_type? diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index e2ff84ac5..e72ecb950 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -156,6 +156,7 @@ class Sandbox (literal "/dev/ptmx") (literal "/dev/dtracehelper") (literal "/dev/null") + (literal "/dev/random") (literal "/dev/zero") (regex #"^/dev/fd/[0-9]+$") (regex #"^/dev/ttys?[0-9]*$") diff --git a/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb b/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb new file mode 100644 index 000000000..c3175509a --- /dev/null +++ b/Library/Homebrew/test/rubocops/conflicts_cop_spec.rb @@ -0,0 +1,47 @@ +require "rubocop" +require "rubocop/rspec/support" +require_relative "../../extend/string" +require_relative "../../rubocops/conflicts_cop" + +describe RuboCop::Cop::FormulaAudit::Conflicts do + subject(:cop) { described_class.new } + + context "When auditing formula for conflicts with" do + it "multiple conflicts_with" do + source = <<-EOS.undent + class FooAT20 < Formula + url 'http://example.com/foo-2.0.tgz' + conflicts_with "mysql", "mariadb", "percona-server", + :because => "both install plugins" + end + EOS + + msg = <<-EOS.undent + Versioned formulae should not use `conflicts_with`. + Use `keg_only :versioned_formula` instead. + EOS + expected_offenses = [{ message: msg, + severity: :convention, + line: 3, + column: 2, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + + it "no conflicts_with" do + source = <<-EOS.undent + class FooAT20 < Formula + url 'http://example.com/foo-2.0.tgz' + desc 'Bar' + end + EOS + inspect_source(cop, source) + expect(cop.offenses).to eq([]) + end + end +end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 75540caad..b1a028d9d 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -41,6 +41,8 @@ TEST_DIRECTORIES = [ RSpec.configure do |config| config.order = :random + config.filter_run_when_matching :focus + config.include(Test::Helper::Shutup) config.include(Test::Helper::Fixtures) config.include(Test::Helper::Formula) diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index ae1854f58..cf9c13fb8 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -77,20 +77,43 @@ RSpec.shared_context "integration test" do "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args), "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, "HOMEBREW_DEVELOPER" => ENV["HOMEBREW_DEVELOPER"], + "GEM_HOME" => nil, ) - ruby_args = [ - "-W0", - "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", - "-I", HOMEBREW_LIBRARY_PATH.to_s, - "-rconfig" - ] - ruby_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] - ruby_args << "-rtest/support/helper/integration_mocks" - ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s - - Bundler.with_original_env do - stdout, stderr, status = Open3.capture3(env, RUBY_PATH, *ruby_args, *args) + @ruby_args ||= begin + ruby_args = [ + "-W0", + "-I", "#{HOMEBREW_LIBRARY_PATH}/test/support/lib", + "-I", HOMEBREW_LIBRARY_PATH.to_s, + "-rconfig" + ] + if ENV["HOMEBREW_TESTS_COVERAGE"] + simplecov_spec = Gem.loaded_specs["simplecov"] + specs = [simplecov_spec] + simplecov_spec.runtime_dependencies.each do |dep| + begin + specs += dep.to_specs + rescue Gem::LoadError => e + onoe e + end + end + libs = specs.flat_map do |spec| + full_gem_path = spec.full_gem_path + # full_require_paths isn't available in RubyGems < 2.2. + spec.require_paths.map do |lib| + next lib if lib.include?(full_gem_path) + "#{full_gem_path}/#{lib}" + end + end + libs.each { |lib| ruby_args << "-I" << lib } + ruby_args << "-rsimplecov" + end + ruby_args << "-rtest/support/helper/integration_mocks" + ruby_args << (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path.to_s + end + + Bundler.with_clean_env do + stdout, stderr, status = Open3.capture3(env, RUBY_PATH, *@ruby_args, *args) $stdout.print stdout $stderr.print stderr status diff --git a/docs/Acceptable-Formulae.md b/docs/Acceptable-Formulae.md index 0773d12d9..df799bb1a 100644 --- a/docs/Acceptable-Formulae.md +++ b/docs/Acceptable-Formulae.md @@ -2,43 +2,14 @@ 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 +additional [Interesting Taps and Forks](Interesting-Taps-and-Forks.md) and anyone can start their own! -### We try hard to avoid dupes in `homebrew/core` -Stuff that comes with macOS or libraries that are provided by -[RubyGems, CPAN or PyPi](Gems,-Eggs-and-Perl-Modules.md) -should not be duplicated. There are good reasons for this: - -* Duplicate libraries regularly break builds -* Subtle bugs emerge with duplicate libraries, and to a lesser extent, - duplicate tools -* We want our formulae to work with what comes with macOS - -There are exceptions: - -* OpenSSL - Apple has formally deprecated OpenSSL on macOS in favour of their own Security Framework - & consequently the macOS OpenSSL is rarely updated and frequently falls behind important security updates. - Homebrew endeavours to use our shipped OpenSSL as much as possible. -* Programs that a user will regularly interact with directly, like editors and - language runtimes -* Libraries that provide functionality or contain security updates not found in - the system version -* Things that are **designed to be installed in parallel to earlier versions of - themselves** - -#### 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 | +### Dupes in `homebrew/core` +We now accept stuff that comes with macOS as long as it uses `keg_only :provided_by_macos` to be keg-only by default. + +### Versioned formulae in `homebrew/core` +We now accept versioned formulae as long as they [meet the requirements](Versions.md). ### We don’t like tools that upgrade themselves Software that can upgrade itself does not integrate well with Homebrew's own @@ -74,7 +45,7 @@ etc. If not, then put bindings in the formula they bind to. This is more useful to people. Just install the stuff! Having to faff around with -foo-ruby, foo-perl etc. sucks. +foo-ruby, foo-perl etc. is a bad user experience. ### Niche (or self-submitted) stuff The software in question must: @@ -100,9 +71,16 @@ running a package manager. ### Stuff that builds an `.app` Don’t make your formula build an `.app` (native macOS Application); we -don’t want those things in Homebrew (but -[Homebrew Cask](https://github.com/caskroom/homebrew-cask) does). -Make it build a command-line tool or a library. +don’t want those things in Homebrew. Encourage upstream projects to build and support a `.app` that can be distributed by [Homebrew Cask](https://github.com/caskroom/homebrew-cask) (and used without it, too). + +### Stuff that builds a GUI by default (but doesn't have to) +Make it build a command-line tool or a library by default and, if the GUI is useful and would be widely used, add an option to build the GUI. Don't offer an option for multiple GUI backends e.g. X11 is a bad user experience for GUIs on macOS. + +### Stuff that doesn't build with the latest, stable Xcode's Clang +Clang is the default C/C++ compiler on macOS (and has been for a long time). Software that doesn't build with it hasn't been adequately ported to macOS. + +### Stuff that requires heavy manual pre/post-install intervention +We're a package manager so we want to do things like resolve dependencies and setup applications for our users. If things require too much manual intervention then they aren't useful in a package manager. ### Sometimes there are exceptions Even if all criteria are met we may not accept the formula. diff --git a/docs/Python-for-Formula-Authors.md b/docs/Python-for-Formula-Authors.md index 8b4bc2cb4..5b9d6ced6 100644 --- a/docs/Python-for-Formula-Authors.md +++ b/docs/Python-for-Formula-Authors.md @@ -2,13 +2,13 @@ This document explains how to successfully use Python in a Homebrew formula. -Homebrew draws a distinction between Python **applications** and Python **libraries**. The difference is that users generally do not care that applications are written in Python; it is unusual that a user would expect to be able to `import foo` after installing an application. Examples of applications are `ansible` and `jrnl`. +Homebrew draws a distinction between Python **applications** and Python **libraries**. The difference is that users generally do not care that applications are written in Python; it is unusual that a user would expect to be able to `import foo` after installing an application. Examples of applications are [`ansible`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/ansible.rb) and [`jrnl`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/jrnl.rb). -Python libraries exist to be imported by other Python modules; they are often dependencies of Python applications. They are usually no more than incidentally useful from a Terminal.app command line. Examples of libraries are `py2cairo` and the bindings that are installed by `protobuf --with-python`. +Python libraries exist to be imported by other Python modules; they are often dependencies of Python applications. They are usually no more than incidentally useful from a Terminal.app command line. Examples of libraries are [`py2cairo`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/py2cairo.rb) and the bindings that are installed by [`protobuf --with-python`](https://github.com/Homebrew/homebrew-core/blob/master/Formula/protobuf.rb). Bindings are a special case of libraries that allow Python code to interact with a library or application implemented in another language. -Homebrew is happy to accept applications that are built in Python, whether the apps are available from PyPI or not. Homebrew generally won't accept libraries that can be installed correctly with `pip install foo`. Libraries that can be `pip`-installed but have several Homebrew dependencies may be appropriate for the [homebrew/python](https://github.com/Homebrew/homebrew-python) tap. Bindings may be installed for packages that provide them, especially if equivalent functionality isn't available through pip. +Homebrew is happy to accept applications that are built in Python, whether the apps are available from PyPI or not. Homebrew generally won't accept libraries that can be installed correctly with `pip install foo`. Bindings may be installed for packages that provide them, especially if equivalent functionality isn't available through pip. ## Running `setup.py` @@ -40,8 +40,6 @@ If you submit a formula with this syntax to core, you may be asked to rewrite it ## Applications -`ansible.rb` and `jrnl.rb` are good examples of applications that follow this advice. - ### 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: diff --git a/docs/README.md b/docs/README.md index 420038ca6..07ff9074c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,7 +10,7 @@ - [Tips and Tricks](Tips-N'-Tricks.md) - [Bottles (binary packages)](Bottles.md) - [Taps (third-party repositories)](brew-tap.md) -- [Interesting Taps and Forks](Interesting-Taps-&-Forks.md) +- [Interesting Taps and Forks](Interesting-Taps-and-Forks.md) - [Anonymous Aggregate User Behaviour Analytics](Analytics.md) - [Querying `brew`](Querying-Brew.md) |
