diff options
Diffstat (limited to 'Library')
35 files changed, 512 insertions, 141 deletions
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 2cc339a83..bb663537d 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -33,7 +33,6 @@ begin empty_argv = ARGV.empty? help_flag_list = %w[-h --help --usage -?] help_flag = !ENV["HOMEBREW_HELP"].nil? - internal_cmd = true cmd = nil ARGV.dup.each_with_index do |arg, i| @@ -50,11 +49,6 @@ begin path = PATH.new(ENV["PATH"]) homebrew_path = PATH.new(ENV["HOMEBREW_PATH"]) - # Add contributed commands to PATH before checking. - tap_cmds = Pathname.glob(Tap::TAP_DIRECTORY/"*/*/cmd") - path.append(tap_cmds) - homebrew_path.append(tap_cmds) - # Add SCM wrappers. path.append(HOMEBREW_SHIMS_PATH/"scm") homebrew_path.append(HOMEBREW_SHIMS_PATH/"scm") @@ -65,8 +59,9 @@ begin internal_cmd = require? HOMEBREW_LIBRARY_PATH/"cmd"/cmd unless internal_cmd - internal_cmd = require? HOMEBREW_LIBRARY_PATH/"dev-cmd"/cmd - if internal_cmd && !ARGV.homebrew_developer? + internal_dev_cmd = require? HOMEBREW_LIBRARY_PATH/"dev-cmd"/cmd + internal_cmd = internal_dev_cmd + if internal_dev_cmd && !ARGV.homebrew_developer? system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", "--replace-all", "homebrew.devcmdrun", "true" ENV["HOMEBREW_DEV_CMD_RUN"] = "1" @@ -93,20 +88,24 @@ begin system(HOMEBREW_BREW_FILE, "uninstall", "--force", "brew-cask") end - # External commands expect a normal PATH - ENV["PATH"] = homebrew_path unless internal_cmd + unless internal_cmd + # Add contributed commands to PATH before checking. + homebrew_path.append(Tap.cmd_directories) + + # External commands expect a normal PATH + ENV["PATH"] = homebrew_path + end if internal_cmd Homebrew.send cmd.to_s.tr("-", "_").downcase elsif which "brew-#{cmd}" - %w[CACHE LIBRARY_PATH].each do |e| - ENV["HOMEBREW_#{e}"] = Object.const_get("HOMEBREW_#{e}").to_s + %w[CACHE LIBRARY_PATH].each do |env| + ENV["HOMEBREW_#{env}"] = Object.const_get("HOMEBREW_#{env}").to_s end exec "brew-#{cmd}", *ARGV elsif (path = which("brew-#{cmd}.rb")) && require?(path) exit Homebrew.failed? ? 1 : 0 else - require "tap" possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } possible_tap = Tap.fetch(possible_tap.first) if possible_tap diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 241fa1c2e..1e2b0f3ed 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -69,9 +69,15 @@ then odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX" fi -# Save value to use for installing gems -export HOMEBREW_GEM_HOME="$GEM_HOME" -export HOMEBREW_GEM_PATH="$GEM_PATH" +# Save values to use for installing gems +if [[ -n "$GEM_HOME" ]] +then + export HOMEBREW_GEM_HOME="$GEM_HOME" +fi +if [[ -n "$GEM_PATH" ]] +then + export HOMEBREW_GEM_PATH="$GEM_PATH" +fi # Users may have these set, pointing the system Ruby # at non-system gem paths @@ -308,9 +314,6 @@ update-preinstall() { [[ -z "$HOMEBREW_NO_AUTO_UPDATE" ]] || return [[ -z "$HOMEBREW_UPDATE_PREINSTALL" ]] || return - # Allow auto-update migration now we have a fix in place (below in this function). - export HOMEBREW_ENABLE_AUTO_UPDATE_MIGRATION="1" - if [[ "$HOMEBREW_COMMAND" = "install" || "$HOMEBREW_COMMAND" = "upgrade" || "$HOMEBREW_COMMAND" = "tap" ]] then if [[ -z "$HOMEBREW_VERBOSE" ]] @@ -319,6 +322,9 @@ update-preinstall() { timer_pid=$! fi + # Allow auto-update migration now we have a fix in place (below in this function). + export HOMEBREW_ENABLE_AUTO_UPDATE_MIGRATION="1" + brew update --preinstall if [[ -n "$timer_pid" ]] diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 5180c5688..d757b0623 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -31,6 +31,8 @@ module Hbc check_generic_artifacts check_token_conflicts check_download + check_single_pre_postflight + check_single_uninstall_zap self rescue StandardError => e odebug "#{e.message}\n#{e.backtrace.join("\n")}" @@ -48,6 +50,36 @@ module Hbc private + def check_single_pre_postflight + odebug "Auditing preflight and postflight stanzas" + + if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:preflight) } > 1 + add_warning "only a single preflight stanza is allowed" + end + + return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:postflight) } > 1 + add_warning "only a single postflight stanza is allowed" + end + + def check_single_uninstall_zap + odebug "Auditing single uninstall_* and zap stanzas" + + if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Uninstall) } > 1 + add_warning "only a single uninstall stanza is allowed" + end + + if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:uninstall_preflight) } > 1 + add_warning "only a single uninstall_preflight stanza is allowed" + end + + if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:uninstall_postflight) } > 1 + add_warning "only a single uninstall_postflight stanza is allowed" + end + + return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Zap) } > 1 + add_warning "only a single zap stanza is allowed" + end + def check_required_stanzas odebug "Auditing required stanzas" [:version, :sha256, :url, :homepage].each do |sym| diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb index 39e8ba6fc..d964fa1a9 100644 --- a/Library/Homebrew/cmd/command.rb +++ b/Library/Homebrew/cmd/command.rb @@ -8,15 +8,16 @@ module Homebrew def command abort "This command requires a command argument" if ARGV.empty? - cmd = ARGV.first - cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - if (path = Commands.path(cmd)) - puts path - elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb")) - puts path - else - odie "Unknown command: #{cmd}" - end + cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(ARGV.first, ARGV.first) + + path = Commands.path(cmd) + + cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path + path ||= which("brew-#{cmd}", cmd_paths) + path ||= which("brew-#{cmd}.rb", cmd_paths) + + odie "Unknown command: #{cmd}" unless path + puts path end end diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb index 0dfc6c451..244373482 100644 --- a/Library/Homebrew/cmd/commands.rb +++ b/Library/Homebrew/cmd/commands.rb @@ -9,27 +9,30 @@ module Homebrew def commands if ARGV.include? "--quiet" - cmds = internal_commands + external_commands + cmds = internal_commands + cmds += external_commands cmds += internal_developer_commands cmds += HOMEBREW_INTERNAL_COMMAND_ALIASES.keys if ARGV.include? "--include-aliases" puts Formatter.columns(cmds.sort) - else - # Find commands in Homebrew/cmd - puts "Built-in commands" - puts Formatter.columns(internal_commands.sort) - - # Find commands in Homebrew/dev-cmd - puts - puts "Built-in developer commands" - puts Formatter.columns(internal_developer_commands.sort) - - # Find commands in the path - unless (exts = external_commands).empty? - puts - puts "External commands" - puts Formatter.columns(exts) - end + return end + + # Find commands in Homebrew/cmd + puts "Built-in commands" + puts Formatter.columns(internal_commands.sort) + + # Find commands in Homebrew/dev-cmd + puts + puts "Built-in developer commands" + puts Formatter.columns(internal_developer_commands.sort) + + exts = external_commands + return if exts.empty? + + # Find commands in the PATH + puts + puts "External commands" + puts Formatter.columns(exts) end def internal_commands @@ -41,11 +44,13 @@ module Homebrew end def external_commands - paths.each_with_object([]) do |path, cmds| + cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) + cmd_paths.each_with_object([]) do |path, cmds| Dir["#{path}/brew-*"].each do |file| next unless File.executable?(file) cmd = File.basename(file, ".rb")[5..-1] - cmds << cmd unless cmd.include?(".") + next if cmd.include?(".") + cmds << cmd end end.sort end diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index caf356b43..9f25f2a2e 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -1,13 +1,10 @@ module Commands def self.path(cmd) - if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb" - end + [ + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh", + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh", + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb", + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb", + ].find(&:exist?) end end diff --git a/Library/Homebrew/compat/macos.rb b/Library/Homebrew/compat/macos.rb index 3acd2f9ef..1f2c651c5 100644 --- a/Library/Homebrew/compat/macos.rb +++ b/Library/Homebrew/compat/macos.rb @@ -1,5 +1,10 @@ require "development_tools" +if OS.mac? + MACOS_FULL_VERSION = OS::Mac.full_version.to_s.freeze + MACOS_VERSION = OS::Mac.version.to_s.freeze +end + module OS module Mac module_function diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index be0ce9351..86abfab87 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -50,7 +50,6 @@ module Homebrew end def check_xcode_up_to_date - return unless MacOS::Xcode.installed? return unless MacOS::Xcode.outdated? # Travis CI images are going to end up outdated so don't complain when @@ -78,7 +77,6 @@ module Homebrew end def check_clt_up_to_date - return unless MacOS::CLT.installed? return unless MacOS::CLT.outdated? # Travis CI images are going to end up outdated so don't complain when @@ -108,7 +106,6 @@ module Homebrew end def check_xcode_minimum_version - return unless MacOS::Xcode.installed? return unless MacOS::Xcode.below_minimum_version? <<~EOS @@ -119,7 +116,6 @@ module Homebrew end def check_clt_minimum_version - return unless MacOS::CLT.installed? return unless MacOS::CLT.below_minimum_version? <<~EOS @@ -281,13 +277,8 @@ module Homebrew EOS end - def check_for_latest_xquartz - return unless MacOS::XQuartz.version - return if MacOS::XQuartz.provided_by_apple? - - installed_version = Version.create(MacOS::XQuartz.version) - latest_version = Version.create(MacOS::XQuartz.latest_version) - return if installed_version >= latest_version + def check_xquartz_up_to_date + return unless MacOS::XQuartz.outdated? <<~EOS Your XQuartz (#{installed_version}) is outdated. @@ -298,8 +289,7 @@ module Homebrew end def check_for_beta_xquartz - return unless MacOS::XQuartz.version - return unless MacOS::XQuartz.version.include? "beta" + return unless MacOS::XQuartz.version.to_s.include?("beta") <<~EOS The following beta release of XQuartz is installed: #{MacOS::XQuartz.version} diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index 5872c2264..ee0d2343c 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -91,18 +91,18 @@ module Superenv generic_setup_build_environment(formula) self["HOMEBREW_SDKROOT"] = effective_sysroot - if MacOS::Xcode.without_clt? || (MacOS::Xcode.installed? && MacOS::Xcode.version.to_i >= 7) + if MacOS::Xcode.without_clt? || MacOS::Xcode.version.to_i >= 7 self["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version.to_s self["SDKROOT"] = MacOS.sdk_path end # Filter out symbols known not to be defined since GNU Autotools can't # reliably figure this out with Xcode 8 and above. - if MacOS.version == "10.12" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "9.0" + if MacOS.version == "10.12" && MacOS::Xcode.version >= "9.0" %w[fmemopen futimens open_memstream utimensat].each do |s| ENV["ac_cv_func_#{s}"] = "no" end - elsif MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0" + elsif MacOS.version == "10.11" && MacOS::Xcode.version >= "8.0" %w[basename_r clock_getres clock_gettime clock_settime dirname_r getentropy mkostemp mkostemps timingsafe_bcmp].each do |s| ENV["ac_cv_func_#{s}"] = "no" diff --git a/Library/Homebrew/extend/os/mac/system_config.rb b/Library/Homebrew/extend/os/mac/system_config.rb index acee50ad0..796134781 100644 --- a/Library/Homebrew/extend/os/mac/system_config.rb +++ b/Library/Homebrew/extend/os/mac/system_config.rb @@ -4,7 +4,7 @@ class SystemConfig if instance_variable_defined?(:@xcode) @xcode elsif MacOS::Xcode.installed? - @xcode = MacOS::Xcode.version + @xcode = MacOS::Xcode.version.to_s @xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix? @xcode end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 607fdd5c4..4ac66ffc4 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1528,10 +1528,10 @@ class Formula "oldname" => oldname, "aliases" => aliases, "versions" => { - "stable" => stable&.version.to_s, + "stable" => stable&.version&.to_s, "bottle" => bottle ? true : false, - "devel" => devel&.version.to_s, - "head" => head&.version.to_s, + "devel" => devel&.version&.to_s, + "head" => head&.version&.to_s, }, "revision" => revision, "version_scheme" => version_scheme, diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb index 2867d8864..d35a49dd7 100644 --- a/Library/Homebrew/os.rb +++ b/Library/Homebrew/os.rb @@ -20,9 +20,6 @@ module OS ISSUES_URL = "https://docs.brew.sh/Troubleshooting.html".freeze end PATH_OPEN = "/usr/bin/open".freeze - # compatibility - ::MACOS_FULL_VERSION = OS::Mac.full_version.to_s.freeze - ::MACOS_VERSION = OS::Mac.version.to_s.freeze elsif OS.linux? ISSUES_URL = "https://github.com/Linuxbrew/brew/wiki/troubleshooting".freeze PATH_OPEN = "xdg-open".freeze diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index 1423a71bc..96be56e3b 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -36,15 +36,17 @@ module OS end def below_minimum_version? + return false unless installed? version < minimum_version end def outdated? - Version.new(version) < latest_version + return false unless installed? + version < latest_version end def without_clt? - installed? && Version.new(version) >= "4.3" && !MacOS::CLT.installed? + version >= "4.3" && !MacOS::CLT.installed? end # Returns a Pathname object corresponding to Xcode.app's Developer @@ -65,8 +67,7 @@ module OS end def toolchain_path - return unless installed? - return if Version.new(version) < "4.3" + return if version < "4.3" Pathname.new("#{prefix}/Toolchains/XcodeDefault.xctoolchain") end @@ -101,16 +102,17 @@ module OS # may return a version string # that is guessed based on the compiler, so do not # use it in order to check if Xcode is installed. - @version ||= uncached_version + if @version ||= detect_version + ::Version.new @version + else + ::Version::NULL + end end - def uncached_version + def detect_version # This is a separate function as you can't cache the value out of a block # if return is used in the middle, which we do many times in here. - - return "0" unless OS.mac? - - return nil if !MacOS::Xcode.installed? && !MacOS::CLT.installed? + return if !MacOS::Xcode.installed? && !MacOS::CLT.installed? %W[ #{prefix}/usr/bin/xcodebuild @@ -160,26 +162,20 @@ module OS end def provides_gcc? - installed? && Version.new(version) < "4.3" + version < "4.3" end def provides_cvs? - installed? && Version.new(version) < "5.0" + version < "5.0" end def default_prefix? - if Version.new(version) < "4.3" + if version < "4.3" prefix.to_s.start_with? "/Developer" else prefix.to_s == "/Applications/Xcode.app/Contents/Developer" end end - - class Version < ::Version - def <=>(other) - super(Version.new(other)) - end - end end module CLT @@ -194,7 +190,7 @@ module OS # Returns true even if outdated tools are installed, e.g. # tools from Xcode 4.x on 10.9 def installed? - !detect_version.nil? + !version.null? end def update_instructions @@ -238,43 +234,57 @@ module OS def below_minimum_version? # Lion was the first version of OS X to ship with a CLT return false if MacOS.version < :lion + return false unless installed? version < minimum_version end def outdated? + clang_version = detect_clang_version + return false unless clang_version + ::Version.new(clang_version) < latest_version + end + + def detect_clang_version # Lion was the first version of OS X to ship with a CLT - return false if MacOS.version < :lion + return if MacOS.version < :lion - if MacOS.version >= :mavericks - version = Utils.popen_read("#{PKG_PATH}/usr/bin/clang --version") + path = if MacOS.version >= :mavericks + "#{PKG_PATH}/usr/bin/clang" else - version = Utils.popen_read("/usr/bin/clang --version") + "/usr/bin/clang" end - version = version[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1] || "0" - Xcode::Version.new(version) < latest_version + + version_output = Utils.popen_read("#{path} --version") + version_output[/clang-(\d+\.\d+\.\d+(\.\d+)?)/, 1] end # Version string (a pretty long one) of the CLT package. # Note, that different ways to install the CLTs lead to different # version numbers. def version - @version ||= detect_version + if @version ||= detect_version + ::Version.new @version + else + ::Version::NULL + end end def detect_version # CLT isn't a distinct entity pre-4.3, and pkgutil doesn't exist # at all on Tiger, so just count it as installed if Xcode is installed - if MacOS::Xcode.installed? && Xcode::Version.new(MacOS::Xcode.version) < "3.0" + if MacOS::Xcode.installed? && MacOS::Xcode.version < "3.0" return MacOS::Xcode.version end - [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| + version = nil + [MAVERICKS_PKG_ID, MAVERICKS_NEW_PKG_ID, STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].each do |id| if MacOS.version >= :mavericks next unless File.exist?("#{PKG_PATH}/usr/bin/clang") end version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] - return version if version + break if version end + version end end end diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index 2fdf0abea..efbb5b738 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -26,13 +26,19 @@ module OS "2.7.73" => "2.7.7", "2.7.86" => "2.7.8", "2.7.94" => "2.7.9", + "2.7.108" => "2.7.10", + "2.7.112" => "2.7.11", }.freeze # This returns the version number of XQuartz, not of the upstream X.org. # The X11.app distributed by Apple is also XQuartz, and therefore covered # by this method. def version - @version ||= detect_version + if @version ||= detect_version + ::Version.new @version + else + ::Version::NULL + end end def detect_version @@ -52,7 +58,7 @@ module OS when "10.5" "2.6.3" else - "2.7.9" + "2.7.11" end end @@ -113,7 +119,13 @@ module OS end def installed? - !version.nil? && !prefix.nil? + !version.null? && !prefix.nil? + end + + def outdated? + return false unless installed? + return false if provided_by_apple? + version < latest_version end # If XQuartz and/or the CLT are installed, headers will be found under diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index a69c68466..95807d5ae 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -77,7 +77,11 @@ class Requirement def satisfied_result_parent return unless @satisfied_result.is_a?(Pathname) - @satisfied_result.resolved_path.parent + parent = @satisfied_result.resolved_path.parent + if parent.to_s =~ %r{^#{Regexp.escape(HOMEBREW_CELLAR)}/([\w+-.@]+)/[^/]+/(s?bin)/?$} + parent = HOMEBREW_PREFIX/"opt/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}" + end + parent end # Overriding #modify_build_environment is deprecated. @@ -94,8 +98,9 @@ class Requirement # PATH. parent = satisfied_result_parent return unless parent + return if ["#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/bin"].include?(parent.to_s) return if PATH.new(ENV["PATH"]).include?(parent.to_s) - ENV.append_path("PATH", parent) + ENV.prepend_path("PATH", parent) end def env diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index af7e1338e..dfa510035 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -105,25 +105,25 @@ module RuboCop find_instance_method_call(body_node, :build, :without?) do |method| arg = parameters(method).first - next unless match = regex_match_group(arg, /-?-?without-(.*)/) + next unless match = regex_match_group(arg, /^-?-?without-(.*)/) problem "Don't duplicate 'without': Use `build.without? \"#{match[1]}\"` to check for \"--without-#{match[1]}\"" end find_instance_method_call(body_node, :build, :with?) do |method| arg = parameters(method).first - next unless match = regex_match_group(arg, /-?-?with-(.*)/) + next unless match = regex_match_group(arg, /^-?-?with-(.*)/) problem "Don't duplicate 'with': Use `build.with? \"#{match[1]}\"` to check for \"--with-#{match[1]}\"" end find_instance_method_call(body_node, :build, :include?) do |method| arg = parameters(method).first - next unless match = regex_match_group(arg, /with(out)?-(.*)/) + next unless match = regex_match_group(arg, /^with(out)?-(.*)/) problem "Use build.with#{match[1]}? \"#{match[2]}\" instead of build.include? 'with#{match[1]}-#{match[2]}'" end find_instance_method_call(body_node, :build, :include?) do |method| arg = parameters(method).first - next unless match = regex_match_group(arg, /\-\-(.*)/) + next unless match = regex_match_group(arg, /^\-\-(.*)$/) problem "Reference '#{match[1]}' without dashes" end end @@ -145,7 +145,7 @@ module RuboCop # Check for long inreplace block vars find_all_blocks(body_node, :inreplace) do |node| block_arg = node.arguments.children.first - next unless block_arg.source.size>1 + next unless block_arg.source.size > 1 problem "\"inreplace <filenames> do |s|\" is preferred over \"|#{block_arg.source}|\"." end @@ -169,7 +169,7 @@ module RuboCop end find_instance_method_call(body_node, :man, :+) do |method| - next unless match = regex_match_group(parameters(method).first, /man[1-8]/) + next unless match = regex_match_group(parameters(method).first, /^man[1-8]$/) problem "\"#{method.source}\" should be \"#{match[0]}\"" end @@ -194,18 +194,18 @@ module RuboCop # Prefer formula path shortcuts in strings formula_path_strings(body_node, :share) do |p| - next unless match = regex_match_group(p, %r{(/(man))/?}) + next unless match = regex_match_group(p, %r{^(/(man))/?}) problem "\"\#{share}#{match[1]}\" should be \"\#{#{match[2]}}\"" end formula_path_strings(body_node, :prefix) do |p| - if match = regex_match_group(p, %r{(/share/(info|man))$}) + if match = regex_match_group(p, %r{^(/share/(info|man))$}) problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2]}}\"" end - if match = regex_match_group(p, %r{((/share/man/)(man[1-8]))}) + if match = regex_match_group(p, %r{^((/share/man/)(man[1-8]))}) problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[3]}}\"" end - if match = regex_match_group(p, %r{(/(bin|include|libexec|lib|sbin|share|Frameworks))}i) + if match = regex_match_group(p, %r{^(/(bin|include|libexec|lib|sbin|share|Frameworks))}i) problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2].downcase}}\"" end end @@ -213,12 +213,12 @@ module RuboCop find_every_method_call_by_name(body_node, :depends_on).each do |method| key, value = destructure_hash(parameters(method).first) next if key.nil? || value.nil? - next unless match = regex_match_group(value, /(lua|perl|python|ruby)(\d*)/) + next unless match = regex_match_group(value, /^(lua|perl|python|ruby)(\d*)/) problem "#{match[1]} modules should be vendored rather than use deprecated #{method.source}`" end find_every_method_call_by_name(body_node, :system).each do |method| - next unless match = regex_match_group(parameters(method).first, /(env|export)(\s+)?/) + next unless match = regex_match_group(parameters(method).first, /^(env|export)(\s+)?/) problem "Use ENV instead of invoking '#{match[1]}' to modify the environment" end @@ -243,7 +243,7 @@ module RuboCop find_instance_method_call(body_node, "ARGV", :include?) do |method| param = parameters(method).first - next unless match = regex_match_group(param, /--(HEAD|devel)/) + next unless match = regex_match_group(param, /^--(HEAD|devel)/) problem "Use \"if build.#{match[1].downcase}?\" instead" end @@ -258,14 +258,14 @@ module RuboCop conditional_dependencies(body_node) do |node, method, param, dep_node| dep = string_content(dep_node) if node.if? - if (method == :include? && regex_match_group(param, /with-#{dep}$/)) || - (method == :with? && regex_match_group(param, /#{dep}$/)) + if (method == :include? && regex_match_group(param, /^with-#{dep}$/)) || + (method == :with? && regex_match_group(param, /^#{dep}$/)) offending_node(dep_node.parent) problem "Replace #{node.source} with #{dep_node.parent.source} => :optional" end elsif node.unless? - if (method == :include? && regex_match_group(param, /without-#{dep}$/)) || - (method == :without? && regex_match_group(param, /#{dep}$/)) + if (method == :include? && regex_match_group(param, /^without-#{dep}$/)) || + (method == :without? && regex_match_group(param, /^#{dep}$/)) offending_node(dep_node.parent) problem "Replace #{node.source} with #{dep_node.parent.source} => :recommended" end @@ -276,7 +276,7 @@ module RuboCop problem "'fails_with :llvm' is now a no-op so should be removed" end - find_method_with_args(body_node, :system, /(otool|install_name_tool|lipo)/) do + find_method_with_args(body_node, :system, /^(otool|install_name_tool|lipo)/) do next if @formula_name == "cctools" problem "Use ruby-macho instead of calling #{@offensive_node.source}" end diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index 063f7f34f..e7e60c985 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -148,6 +148,15 @@ class SystemConfig "#{Utils.git_version} => #{Utils.git_path}" end + def describe_curl + curl_version_output = Utils.popen_read("#{curl_executable} --version", err: :close) + curl_version_output =~ /^curl ([\d\.]+)/ + curl_version = Regexp.last_match(1) + "#{curl_version} => #{curl_executable}" + rescue + "N/A" + end + def dump_verbose_config(f = $stdout) f.puts "HOMEBREW_VERSION: #{HOMEBREW_VERSION}" f.puts "ORIGIN: #{origin}" @@ -160,16 +169,54 @@ class SystemConfig else f.puts "Core tap: N/A" end + defaults_hash = { + HOMEBREW_PREFIX: "/usr/local", + HOMEBREW_REPOSITORY: "/usr/local/Homebrew", + HOMEBREW_CELLAR: "/usr/local/Cellar", + HOMEBREW_CACHE: "#{ENV["HOME"]}/Library/Caches/Homebrew", + }.freeze + boring_keys = %w[ + HOMEBREW_BROWSER + HOMEBREW_EDITOR + + HOMEBREW_ANALYTICS_ID + HOMEBREW_ANALYTICS_USER_UUID + HOMEBREW_BREW_FILE + HOMEBREW_COMMAND_DEPTH + HOMEBREW_CURL + HOMEBREW_LIBRARY + HOMEBREW_MACOS_VERSION + HOMEBREW_RUBY_PATH + HOMEBREW_SYSTEM + HOMEBREW_OS_VERSION + HOMEBREW_PATH + HOMEBREW_PROCESSOR + HOMEBREW_PRODUCT + HOMEBREW_USER_AGENT + HOMEBREW_USER_AGENT_CURL + HOMEBREW_VERSION + ].freeze f.puts "HOMEBREW_PREFIX: #{HOMEBREW_PREFIX}" - f.puts "HOMEBREW_REPOSITORY: #{HOMEBREW_REPOSITORY}" - f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" - f.puts "HOMEBREW_BOTTLE_DOMAIN: #{BottleSpecification::DEFAULT_DOMAIN}" + if defaults_hash[:HOMEBREW_REPOSITORY] != HOMEBREW_REPOSITORY.to_s + f.puts "HOMEBREW_REPOSITORY: #{HOMEBREW_REPOSITORY}" + end + if defaults_hash[:HOMEBREW_CELLAR] != HOMEBREW_CELLAR.to_s + f.puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" + end + ENV.sort.each do |key, value| + next unless key.start_with?("HOMEBREW_") + next if boring_keys.include?(key) + next if defaults_hash[key.to_sym] == value + value = "set" if key =~ /(cookie|key|token)/i + f.puts "#{key}: #{value}" + end f.puts hardware if hardware f.puts "Homebrew Ruby: #{describe_homebrew_ruby}" 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 "Curl: #{describe_curl}" f.puts "Perl: #{describe_perl}" f.puts "Python: #{describe_python}" f.puts "Ruby: #{describe_ruby}" diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 2d1c47e32..ed93e1266 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -503,6 +503,11 @@ class Tap map(&:name).sort end + # an array of all tap cmd directory {Pathname}s + def self.cmd_directories + Pathname.glob TAP_DIRECTORY/"*/*/cmd" + end + # @private def formula_file_to_name(file) "#{name}/#{file.basename(".rb")}" diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 7e140acb2..ec051c138 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -91,6 +91,120 @@ describe Hbc::Audit, :cask do end end + describe "preflight stanza checks" do + let(:error_msg) { "only a single preflight stanza is allowed" } + + context "when the cask has no preflight stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one preflight stanza" do + let(:cask_token) { "with-preflight" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple preflight stanzas" do + let(:cask_token) { "with-preflight-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + + describe "uninstall_postflight stanza checks" do + let(:error_msg) { "only a single postflight stanza is allowed" } + + context "when the cask has no postflight stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one postflight stanza" do + let(:cask_token) { "with-postflight" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple postflight stanzas" do + let(:cask_token) { "with-postflight-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + + describe "uninstall stanza checks" do + let(:error_msg) { "only a single uninstall stanza is allowed" } + + context "when the cask has no uninstall stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one uninstall stanza" do + let(:cask_token) { "with-uninstall-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple uninstall stanzas" do + let(:cask_token) { "with-uninstall-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + + describe "uninstall_preflight stanza checks" do + let(:error_msg) { "only a single uninstall_preflight stanza is allowed" } + + context "when the cask has no uninstall_preflight stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one uninstall_preflight stanza" do + let(:cask_token) { "with-uninstall-preflight" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple uninstall_preflight stanzas" do + let(:cask_token) { "with-uninstall-preflight-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + + describe "uninstall_postflight stanza checks" do + let(:error_msg) { "only a single uninstall_postflight stanza is allowed" } + + context "when the cask has no uninstall_postflight stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one uninstall_postflight stanza" do + let(:cask_token) { "with-uninstall-postflight" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple uninstall_postflight stanzas" do + let(:cask_token) { "with-uninstall-postflight-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + + describe "zap stanza checks" do + let(:error_msg) { "only a single zap stanza is allowed" } + + context "when the cask has no zap stanza" do + let(:cask_token) { "with-uninstall-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has only one zap stanza" do + let(:cask_token) { "with-zap-rmdir" } + it { should_not warn_with(error_msg) } + end + + context "when the cask has multiple zap stanzas" do + let(:cask_token) { "with-zap-multi" } + it { is_expected.to warn_with(error_msg) } + end + end + describe "version checks" do let(:error_msg) { "you should use version :latest instead of version 'latest'" } diff --git a/Library/Homebrew/test/requirement_spec.rb b/Library/Homebrew/test/requirement_spec.rb index 11a3da8f4..2d0d86c86 100644 --- a/Library/Homebrew/test/requirement_spec.rb +++ b/Library/Homebrew/test/requirement_spec.rb @@ -138,7 +138,7 @@ describe Requirement do end it "infers path from #satisfy result" do - expect(ENV).to receive(:append_path).with("PATH", Pathname.new("/foo/bar")) + expect(ENV).to receive(:prepend_path).with("PATH", Pathname.new("/foo/bar")) subject.satisfied? subject.modify_build_environment end diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index e65eff1fc..de79fd7de 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -762,8 +762,8 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do class Foo < Formula desc "foo" url 'http://example.com/foo-1.0.tgz' - depends_on "foo" if build.with? "with-foo" - ^^^^^^^^^^^^^^^^ Replace depends_on "foo" if build.with? "with-foo" with depends_on "foo" => :optional + depends_on "foo" if build.with? "foo" + ^^^^^^^^^^^^^^^^ Replace depends_on "foo" if build.with? "foo" with depends_on "foo" => :optional end RUBY end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index c40a72fcc..08766ea37 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -117,6 +117,7 @@ RSpec.configure do |config| HOMEBREW_PINNED_KEGS, HOMEBREW_PREFIX/".git", HOMEBREW_PREFIX/"bin", + HOMEBREW_PREFIX/"etc", HOMEBREW_PREFIX/"share", HOMEBREW_PREFIX/"opt", HOMEBREW_PREFIX/"Caskroom", diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb new file mode 100644 index 000000000..6d0d64798 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight-multi.rb @@ -0,0 +1,15 @@ +cask 'with-postflight-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + postflight do + end + + postflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb new file mode 100644 index 000000000..295a2534e --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-postflight.rb @@ -0,0 +1,12 @@ +cask 'with-postflight' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + postflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb new file mode 100644 index 000000000..d45480fac --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight-multi.rb @@ -0,0 +1,15 @@ +cask 'with-preflight-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + preflight do + end + + preflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb new file mode 100644 index 000000000..d7d1bef06 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-preflight.rb @@ -0,0 +1,12 @@ +cask 'with-preflight' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + preflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-multi.rb new file mode 100644 index 000000000..e4c2e22e1 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-multi.rb @@ -0,0 +1,13 @@ +cask 'with-uninstall-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall rmdir: "#{TEST_TMPDIR}/empty_directory_path" + + uninstall delete: "#{TEST_TMPDIR}/empty_directory_path" +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb new file mode 100644 index 000000000..58f096061 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight-multi.rb @@ -0,0 +1,15 @@ +cask 'with-uninstall-postflight-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall_postflight do + end + + uninstall_postflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb new file mode 100644 index 000000000..4beffe489 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-postflight.rb @@ -0,0 +1,12 @@ +cask 'with-uninstall-postflight' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall_postflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb new file mode 100644 index 000000000..f671da64f --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight-multi.rb @@ -0,0 +1,15 @@ +cask 'with-uninstall-preflight-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall_preflight do + end + + uninstall_preflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb new file mode 100644 index 000000000..2978ed527 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-preflight.rb @@ -0,0 +1,12 @@ +cask 'with-uninstall-preflight' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + uninstall_preflight do + end +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-multi.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-multi.rb new file mode 100644 index 000000000..775e106b4 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-multi.rb @@ -0,0 +1,13 @@ +cask 'with-zap-multi' do + version '1.2.3' + sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' + + url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyPkg.zip" + homepage 'http://example.com/fancy-pkg' + + pkg 'MyFancyPkg/Fancy.pkg' + + zap rmdir: "#{TEST_TMPDIR}/empty_directory_path" + + zap delete: "#{TEST_TMPDIR}/empty_directory_path" +end diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 0c875a8ab..1d16044da 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -189,8 +189,11 @@ module Homebrew def install_gem_setup_path!(name, version = nil, executable = name) # Respect user's preferences for where gems should be installed. - ENV["GEM_HOME"] = ENV["HOMEBREW_GEM_HOME"].to_s - ENV["GEM_HOME"] = Gem.user_dir if ENV["GEM_HOME"].empty? + ENV["GEM_HOME"] = if ENV["HOMEBREW_GEM_HOME"].to_s.empty? + Gem.user_dir + else + ENV["HOMEBREW_GEM_HOME"] + end unless ENV["HOMEBREW_GEM_PATH"].to_s.empty? ENV["GEM_PATH"] = ENV["HOMEBREW_GEM_PATH"] end diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 7807d2034..eaa81352c 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -34,7 +34,11 @@ def curl_args(*extra_args, show_output: false, user_agent: :default) end def curl(*args) - safe_system(*curl_args(*args)) + # SSL_CERT_FILE can be incorrectly set by users or portable-ruby and screw + # with SSL downloads so unset it here. + with_env SSL_CERT_FILE: nil do + safe_system(*curl_args(*args)) + end end def curl_download(*args, to: nil, continue_at: "-", **options) diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index d43e0c665..c2635f18c 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -431,6 +431,10 @@ class Version version.to_f end + def to_i + version.to_i + end + def to_s version.dup end |
