From fa26b5a06d0075e2e9e9aae09c95946c535d582a Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sat, 6 Aug 2022 13:21:18 +0800 Subject: [PATCH 1/8] linux/super: add unversioned GCC lib directory to RPATH This adds GCC's runtime lib directory to the RPATH of every build on Linux (unconditionally!). This is useful for three things: 1. It fixes versioned GCC linkage for formulae that users build from source instead of pouring from a bottle. We currently only handle bottle installs. See #13633. 2. It helps minimise the GCC dependency explosion. When a formula has a Linux-only GCC dependency, then all its dependents that link with some GCC runtime library (typically `libstdc++`) must, before this change, also adopt a GCC dependency. This is a consequence of our injecting GCC's runtime library directory into RPATH only when a formula is built with GCC (this is done through the specs file). We can avoid the need to do this by always injecting this path instead. 3. This enables us to automatically install Homebrew GCC whenever the user's GCC is too old and the formula may need it. Without this change, auto-installing GCC is not that useful because formulae that need it may not know to look for our GCC, unless the formula already happened to be built with our GCC. With this change, these formulae will always be able to find our GCC when it is installed. This is particularly useful for when we start building with a version of GCC that is much closer to the latest than we currently do. This approach comes with at least two drawbacks: 1. We will see spurious linkage warnings in CI about an undeclared dependency with linkage as soon as Homebrew GCC is installed, because formulae will link with our GCC instead of the host's. Users will also see a similar complaint if they do `brew linkage`. 2. This leans _very_ heavily on GCC delivering backward compatibility of their runtime libraries. If they do not, we could see different behaviour across different CI runs for the same formula depending on whether Homebrew GCC is installed. It's worth noting that item 3 in the "useful" list above may rely on features not yet implement in `brew`. --- Library/Homebrew/extend/os/linux/extend/ENV/super.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb index 8dd6f95c8d..eb2460a5ba 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb @@ -51,6 +51,7 @@ module Superenv def determine_rpath_paths(formula) PATH.new( *formula&.lib, + "#{HOMEBREW_PREFIX}/opt/gcc/lib/gcc/current", PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing, "#{HOMEBREW_PREFIX}/lib", ) From ca0ab6eceb61993f32c1598a000ec7edc426e96f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:05:25 +0000 Subject: [PATCH 2/8] build(deps): bump rubocop from 1.33.0 to 1.34.1 in /Library/Homebrew Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.33.0 to 1.34.1. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.33.0...v1.34.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Library/Homebrew/Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 9fc0ad2ea6..61febf66ff 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -74,7 +74,7 @@ GEM parser rainbow (~> 3.0) sorbet-runtime (>= 0.5) - parser (3.1.2.0) + parser (3.1.2.1) ast (~> 2.4.1) patchelf (1.3.0) elftools (>= 1.1.3) @@ -124,14 +124,14 @@ GEM rspec (>= 3, < 4) rspec_junit_formatter (0.5.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.33.0) + rubocop (1.34.1) json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.19.1, < 2.0) + rubocop-ast (>= 1.20.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.21.0) From d39ba743f98603adc9e922e671d607ed06b74798 Mon Sep 17 00:00:00 2001 From: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:08:02 +0000 Subject: [PATCH 3/8] brew vendor-gems: commit updates. --- Library/Homebrew/vendor/bundle/bundler/setup.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index f902e1aa4d..69885e22a4 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -58,7 +58,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/method_source-1.0.0/l $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.22.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-3.11.1/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-3.1.2.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-3.1.2.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rainbow-3.1.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/sorbet-runtime-0.5.10175/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parlour-8.0.0/lib" @@ -86,7 +86,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec_junit_formatter $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-ast-1.21.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.11.0/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-2.2.0/lib" -$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.33.0/lib" +$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.34.1/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.14.3/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.15.2/lib" $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.12.1/lib" From 478e42d536679ecc8673fbbb991347779e4d8112 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Wed, 10 Aug 2022 19:00:59 +0800 Subject: [PATCH 4/8] linux/linkage_checker: remove `gcc` from `undeclared_deps` --- Library/Homebrew/extend/os/linux/linkage_checker.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/linux/linkage_checker.rb b/Library/Homebrew/extend/os/linux/linkage_checker.rb index 4e2bbf557b..e94995e966 100644 --- a/Library/Homebrew/extend/os/linux/linkage_checker.rb +++ b/Library/Homebrew/extend/os/linux/linkage_checker.rb @@ -72,6 +72,9 @@ class LinkageChecker @unwanted_system_dylibs = @system_dylibs.reject do |s| SYSTEM_LIBRARY_ALLOWLIST.include? File.basename(s) end - @undeclared_deps -= [CompilerSelector.preferred_gcc, "glibc"] + # FIXME: Remove this when these dependencies are injected correctly (e.g. through `DependencyCollector`) + # See discussion at + # https://github.com/Homebrew/brew/pull/13577 + @undeclared_deps -= [CompilerSelector.preferred_gcc, "glibc", "gcc"] end end From 6b697470fd7f844e3be709cd2b3da5d0c1294147 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 10 Aug 2022 14:19:33 +0100 Subject: [PATCH 5/8] brew style --fix For https://github.com/Homebrew/brew/pull/13671 --- Library/Homebrew/dev-cmd/bump-cask-pr.rb | 4 ++-- Library/Homebrew/rubocops/lines.rb | 6 +++--- Library/Homebrew/service.rb | 6 +++--- Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/style.rb | 4 ++-- Library/Homebrew/tap.rb | 2 +- .../fixtures/cask/Casks/with-depends-on-macos-failure.rb | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index d6b1586e0b..cc33184b1a 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -156,11 +156,11 @@ module Homebrew end if new_hash.present? && cask.language.blank? # avoid repeated replacement for multilanguage cask - hash_regex = old_hash == :no_check ? ":no_check" : "[\"']#{Regexp.escape(old_hash.to_s)}[\"']" + hash_regex = (old_hash == :no_check) ? ":no_check" : "[\"']#{Regexp.escape(old_hash.to_s)}[\"']" replacement_pairs << [ /sha256\s+#{hash_regex}/m, - "sha256 #{new_hash == :no_check ? ":no_check" : "\"#{new_hash}\""}", + "sha256 #{(new_hash == :no_check) ? ":no_check" : "\"#{new_hash}\""}", ] end diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index e8c7a631a3..d8fd97bead 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -401,7 +401,7 @@ module RuboCop info[:if_module], info[:if_method] = if ON_ARCH_OPTIONS.include?(on_system_option) ["Hardware::CPU", :"#{on_system_option}?"] elsif ON_BASE_OS_OPTIONS.include?(on_system_option) - ["OS", on_system_option == :macos ? :mac? : :linux?] + ["OS", (on_system_option == :macos) ? :mac? : :linux?] else ["MacOS", :version] end @@ -493,7 +493,7 @@ module RuboCop else_info = if else_node.present? { can_autocorrect: true, - on_system_method: on_system_option == :intel ? "on_arm" : "on_intel", + on_system_method: (on_system_option == :intel) ? "on_arm" : "on_intel", node: else_node, } end @@ -505,7 +505,7 @@ module RuboCop else_info = if else_node.present? { can_autocorrect: true, - on_system_method: on_system_option == :macos ? "on_linux" : "on_macos", + on_system_method: (on_system_option == :macos) ? "on_linux" : "on_macos", node: else_node, } end diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index f40cff066f..3ef98c0792 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -405,7 +405,7 @@ module Homebrew cmd = command.join(" ") options = [] - options << "Type=#{@launch_only_once == true ? "oneshot" : "simple"}" + options << "Type=#{(@launch_only_once == true) ? "oneshot" : "simple"}" options << "ExecStart=#{cmd}" options << "Restart=always" if @keep_alive.present? && @keep_alive[:always].present? @@ -441,8 +441,8 @@ module Homebrew options << "OnUnitActiveSec=#{@interval}" if @run_type == RUN_TYPE_INTERVAL if @run_type == RUN_TYPE_CRON - minutes = @cron[:Minute] == "*" ? "*" : format("%02d", @cron[:Minute]) - hours = @cron[:Hour] == "*" ? "*" : format("%02d", @cron[:Hour]) + minutes = (@cron[:Minute] == "*") ? "*" : format("%02d", @cron[:Minute]) + hours = (@cron[:Hour] == "*") ? "*" : format("%02d", @cron[:Hour]) options << "OnCalendar=#{@cron[:Weekday]}-*-#{@cron[:Month]}-#{@cron[:Day]} #{hours}:#{minutes}:00" end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 0a246d3469..6b4c15981e 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -582,7 +582,7 @@ class BottleSpecification tags = collector.tags.sort_by do |tag| version = tag.to_macos_version # Give arm64 bottles a higher priority so they are first - priority = tag.arch == :arm64 ? "2" : "1" + priority = (tag.arch == :arm64) ? "2" : "1" "#{priority}.#{version}_#{tag}" rescue MacOSVersionError # Sort non-MacOS tags below MacOS tags. diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 8b253c0f5f..ce38f1a1af 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -49,7 +49,7 @@ module Homebrew .partition { |f| f.realpath == HOMEBREW_BREW_FILE.realpath || f.extname == ".sh" } rubocop_result = if shell_files.any? && ruby_files.none? - output_type == :json ? [] : true + (output_type == :json) ? [] : true else run_rubocop(ruby_files, output_type, fix: fix, @@ -60,7 +60,7 @@ module Homebrew end shellcheck_result = if ruby_files.any? && shell_files.none? - output_type == :json ? [] : true + (output_type == :json) ? [] : true else run_shellcheck(shell_files, output_type, fix: fix) end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 7a2fba9256..c41753c6e7 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -252,7 +252,7 @@ class Tap if official? && DEPRECATED_OFFICIAL_TAPS.include?(repo) odie "#{name} was deprecated. This tap is now empty and all its contents were either deleted or migrated." elsif user == "caskroom" || name == "phinze/cask" - new_repo = repo == "cask" ? "cask" : "cask-#{repo}" + new_repo = (repo == "cask") ? "cask" : "cask-#{repo}" odie "#{name} was moved. Tap homebrew/#{new_repo} instead." end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb index 652ac08b8e..9dbddb789e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-depends-on-macos-failure.rb @@ -6,7 +6,7 @@ cask "with-depends-on-macos-failure" do homepage "https://brew.sh/with-depends-on-macos-failure" # guarantee a mismatched release - depends_on macos: MacOS.version == :catalina ? :mojave : :catalina + depends_on macos: (MacOS.version == :catalina) ? :mojave : :catalina app "Caffeine.app" end From 39071d5816dd3cb1848171cc88b38aecb9752029 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 10 Aug 2022 15:31:02 -0400 Subject: [PATCH 6/8] Remove `arch` from cask stanza ordering temporarily --- Library/Homebrew/rubocops/cask/constants/stanza.rb | 2 +- .../test/support/fixtures/cask/Casks/arch-arm-only.rb | 3 ++- .../support/fixtures/cask/Casks/invalid/invalid-two-arch.rb | 5 +++-- .../test/support/fixtures/cask/Casks/multiple-versions.rb | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/constants/stanza.rb b/Library/Homebrew/rubocops/cask/constants/stanza.rb index 959beda606..93a9b67d55 100644 --- a/Library/Homebrew/rubocops/cask/constants/stanza.rb +++ b/Library/Homebrew/rubocops/cask/constants/stanza.rb @@ -6,7 +6,7 @@ module RuboCop # Constants available globally for use in all cask cops. module Constants STANZA_GROUPS = [ - [:version, :sha256, :arch], + [:version, :sha256], [:language], [:url, :appcast, :name, :desc, :homepage], [:livecheck], diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/arch-arm-only.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/arch-arm-only.rb index c40235d15d..d6bc73d35e 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/arch-arm-only.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/arch-arm-only.rb @@ -1,7 +1,8 @@ cask "arch-arm-only" do + arch arm: "-arm" + version "1.2.3" sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" - arch arm: "-arm" url "file://#{TEST_FIXTURE_DIR}/cask/caffeine#{arch}.zip" homepage "https://brew.sh/" diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-arch.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-arch.rb index 15112831e6..117e59c3bc 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-arch.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/invalid/invalid-two-arch.rb @@ -1,9 +1,10 @@ cask "invalid-two-arch" do - version "1.2.3" - sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" arch arm: "arm", intel: "intel" arch arm: "amd64", intel: "x86_64" + version "1.2.3" + sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" + url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip" homepage "https://brew.sh/" diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/multiple-versions.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/multiple-versions.rb index f4e112f956..05a29fd20f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/multiple-versions.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/multiple-versions.rb @@ -1,9 +1,9 @@ cask "multiple-versions" do + arch arm: "arm", intel: "intel" + platform = on_arch_conditional arm: "darwin-arm64", intel: "darwin" + version "1.2.3" sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94" - arch arm: "arm", intel: "intel" - - platform = on_arch_conditional arm: "darwin-arm64", intel: "darwin" on_big_sur do version "1.2.0" From 43bbe2bcfcd6b196c88311dafd6f0707d4c90dbf Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 10 Aug 2022 17:15:37 -0400 Subject: [PATCH 7/8] Fix `nil` handling in `arch` cask DSL --- Library/Homebrew/extend/on_system.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/on_system.rb b/Library/Homebrew/extend/on_system.rb index 8ba6415b99..035940ba0b 100644 --- a/Library/Homebrew/extend/on_system.rb +++ b/Library/Homebrew/extend/on_system.rb @@ -66,7 +66,7 @@ module OnSystem end end - base.define_method(:on_arch_conditional) do |arm:, intel:| + base.define_method(:on_arch_conditional) do |arm: nil, intel: nil| @on_system_blocks_exist = true return arm if OnSystem.arch_condition_met? :arm From 74a8e5bb235cfdc476b84863e2eb1847fc3eec3e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 11 Aug 2022 10:57:19 +0100 Subject: [PATCH 8/8] dev-cmd/rubocop: use bundle check. It's not reliable enough to just check for the binary. --- Library/Homebrew/dev-cmd/rubocop.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/rubocop.sh b/Library/Homebrew/dev-cmd/rubocop.sh index bc1b8ca769..28e9df7a42 100644 --- a/Library/Homebrew/dev-cmd/rubocop.sh +++ b/Library/Homebrew/dev-cmd/rubocop.sh @@ -13,13 +13,16 @@ homebrew-rubocop() { GEM_VERSION="$("${HOMEBREW_RUBY_PATH}" "${RUBY_DISABLE_OPTIONS}" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')" GEM_HOME="${HOMEBREW_LIBRARY}/Homebrew/vendor/bundle/ruby/${GEM_VERSION}" + BUNDLE_GEMFILE="${HOMEBREW_LIBRARY}/Homebrew/Gemfile" - if ! [[ -f "${GEM_HOME}/bin/rubocop" ]] + export GEM_HOME + export BUNDLE_GEMFILE + + if ! bundle check &>/dev/null then "${HOMEBREW_BREW_FILE}" install-bundler-gems fi - export GEM_HOME export PATH="${GEM_HOME}/bin:${PATH}" RUBOCOP="${HOMEBREW_LIBRARY}/Homebrew/utils/rubocop.rb"