mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Fix Style/GuardClause.
This commit is contained in:
parent
bbc3f1c3a8
commit
58e36c7319
@ -118,43 +118,6 @@ Style/GlobalVars:
|
|||||||
- 'Homebrew/diagnostic.rb'
|
- 'Homebrew/diagnostic.rb'
|
||||||
- 'Homebrew/utils.rb'
|
- 'Homebrew/utils.rb'
|
||||||
|
|
||||||
# Offense count: 70
|
|
||||||
# Configuration parameters: MinBodyLength.
|
|
||||||
Style/GuardClause:
|
|
||||||
Exclude:
|
|
||||||
- 'Taps/**/*'
|
|
||||||
- 'Homebrew/cmd/update-report.rb'
|
|
||||||
- 'Homebrew/dependency_collector.rb'
|
|
||||||
- 'Homebrew/dev-cmd/audit.rb'
|
|
||||||
- 'Homebrew/dev-cmd/pull.rb'
|
|
||||||
- 'Homebrew/dev-cmd/test-bot.rb'
|
|
||||||
- 'Homebrew/download_strategy.rb'
|
|
||||||
- 'Homebrew/extend/ARGV.rb'
|
|
||||||
- 'Homebrew/extend/ENV/shared.rb'
|
|
||||||
- 'Homebrew/extend/ENV/std.rb'
|
|
||||||
- 'Homebrew/extend/ENV/super.rb'
|
|
||||||
- 'Homebrew/extend/fileutils.rb'
|
|
||||||
- 'Homebrew/extend/os/mac/extend/ENV/std.rb'
|
|
||||||
- 'Homebrew/extend/os/mac/formula_cellar_checks.rb'
|
|
||||||
- 'Homebrew/extend/os/mac/utils/bottles.rb'
|
|
||||||
- 'Homebrew/extend/string.rb'
|
|
||||||
- 'Homebrew/formula.rb'
|
|
||||||
- 'Homebrew/formula_installer.rb'
|
|
||||||
- 'Homebrew/formula_lock.rb'
|
|
||||||
- 'Homebrew/formulary.rb'
|
|
||||||
- 'Homebrew/keg.rb'
|
|
||||||
- 'Homebrew/migrator.rb'
|
|
||||||
- 'Homebrew/os/mac/xcode.rb'
|
|
||||||
- 'Homebrew/patch.rb'
|
|
||||||
- 'Homebrew/requirement.rb'
|
|
||||||
- 'Homebrew/tap.rb'
|
|
||||||
- 'Homebrew/test/test_cmd_testbot.rb'
|
|
||||||
- 'Homebrew/test/test_integration_cmds.rb'
|
|
||||||
- 'Homebrew/test/testing_env.rb'
|
|
||||||
- 'Homebrew/utils.rb'
|
|
||||||
- 'Homebrew/utils/popen.rb'
|
|
||||||
- 'Homebrew/version.rb'
|
|
||||||
|
|
||||||
# Offense count: 51
|
# Offense count: 51
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: MaxLineLength.
|
# Configuration parameters: MaxLineLength.
|
||||||
|
@ -203,7 +203,7 @@ module Homebrew
|
|||||||
# If they haven't updated in 48 hours (172800 seconds), that
|
# If they haven't updated in 48 hours (172800 seconds), that
|
||||||
# might explain the error
|
# might explain the error
|
||||||
master = HOMEBREW_REPOSITORY/".git/refs/heads/master"
|
master = HOMEBREW_REPOSITORY/".git/refs/heads/master"
|
||||||
if master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800
|
return unless master.exist? && (Time.now.to_i - File.mtime(master).to_i) > 172800
|
||||||
ohai "You haven't updated Homebrew in a while."
|
ohai "You haven't updated Homebrew in a while."
|
||||||
puts <<-EOS.undent
|
puts <<-EOS.undent
|
||||||
A formula for #{e.name} might have been added recently.
|
A formula for #{e.name} might have been added recently.
|
||||||
@ -212,7 +212,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def check_ppc
|
def check_ppc
|
||||||
case Hardware::CPU.type
|
case Hardware::CPU.type
|
||||||
|
@ -549,12 +549,11 @@ class ReporterHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless formulae.empty?
|
return if formulae.empty?
|
||||||
# Dump formula list.
|
# Dump formula list.
|
||||||
ohai title
|
ohai title
|
||||||
puts_columns(formulae)
|
puts_columns(formulae)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def installed?(formula)
|
def installed?(formula)
|
||||||
(HOMEBREW_CELLAR/formula.split("/").last).directory?
|
(HOMEBREW_CELLAR/formula.split("/").last).directory?
|
||||||
|
@ -128,11 +128,11 @@ class DependencyCollector
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_class_spec(spec, tags)
|
def parse_class_spec(spec, tags)
|
||||||
if spec < Requirement
|
unless spec < Requirement
|
||||||
spec.new(tags)
|
|
||||||
else
|
|
||||||
raise TypeError, "#{spec.inspect} is not a Requirement subclass"
|
raise TypeError, "#{spec.inspect} is not a Requirement subclass"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
spec.new(tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ant_dep(spec, tags)
|
def ant_dep(spec, tags)
|
||||||
|
@ -284,10 +284,9 @@ class FormulaAuditor
|
|||||||
problem "Should not have both `head` and `head do`"
|
problem "Should not have both `head` and `head do`"
|
||||||
end
|
end
|
||||||
|
|
||||||
if present.include?("bottle modifier") && present.include?("bottle block")
|
return unless present.include?("bottle modifier") && present.include?("bottle block")
|
||||||
problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
|
problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_class
|
def audit_class
|
||||||
if @strict
|
if @strict
|
||||||
@ -350,10 +349,9 @@ class FormulaAuditor
|
|||||||
|
|
||||||
same_name_tap_formulae.delete(full_name)
|
same_name_tap_formulae.delete(full_name)
|
||||||
|
|
||||||
unless same_name_tap_formulae.empty?
|
return if same_name_tap_formulae.empty?
|
||||||
problem "Formula name conflicts with #{same_name_tap_formulae.join ", "}"
|
problem "Formula name conflicts with #{same_name_tap_formulae.join ", "}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_deps
|
def audit_deps
|
||||||
@specs.each do |spec|
|
@specs.each do |spec|
|
||||||
@ -485,10 +483,9 @@ class FormulaAuditor
|
|||||||
problem "Description shouldn't start with an indefinite article (#{$1})"
|
problem "Description shouldn't start with an indefinite article (#{$1})"
|
||||||
end
|
end
|
||||||
|
|
||||||
if desc.downcase.start_with? "#{formula.name} "
|
return unless desc.downcase.start_with? "#{formula.name} "
|
||||||
problem "Description shouldn't include the formula name"
|
problem "Description shouldn't include the formula name"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_homepage
|
def audit_homepage
|
||||||
homepage = formula.homepage
|
homepage = formula.homepage
|
||||||
@ -564,10 +561,10 @@ class FormulaAuditor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def audit_bottle_spec
|
def audit_bottle_spec
|
||||||
if formula.bottle_disabled? && !formula.bottle_disable_reason.valid?
|
return unless formula.bottle_disabled?
|
||||||
|
return if formula.bottle_disable_reason.valid?
|
||||||
problem "Unrecognized bottle modifier"
|
problem "Unrecognized bottle modifier"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_github_repository
|
def audit_github_repository
|
||||||
return unless @online
|
return unless @online
|
||||||
@ -594,10 +591,9 @@ class FormulaAuditor
|
|||||||
problem "GitHub repository not notable enough (<20 forks, <20 watchers and <50 stars)"
|
problem "GitHub repository not notable enough (<20 forks, <20 watchers and <50 stars)"
|
||||||
end
|
end
|
||||||
|
|
||||||
if Date.parse(metadata["created_at"]) > (Date.today - 30)
|
return if Date.parse(metadata["created_at"]) <= (Date.today - 30)
|
||||||
problem "GitHub repository too new (<30 days old)"
|
problem "GitHub repository too new (<30 days old)"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_specs
|
def audit_specs
|
||||||
if head_only?(formula) && formula.tap.to_s.downcase !~ %r{[-/]head-only$}
|
if head_only?(formula) && formula.tap.to_s.downcase !~ %r{[-/]head-only$}
|
||||||
@ -736,10 +732,9 @@ class FormulaAuditor
|
|||||||
problem "Please set plist_options when using a formula-defined plist."
|
problem "Please set plist_options when using a formula-defined plist."
|
||||||
end
|
end
|
||||||
|
|
||||||
if text.include?('require "language/go"') && !text.include?("go_resource")
|
return unless text.include?('require "language/go"') && !text.include?("go_resource")
|
||||||
problem "require \"language/go\" is unnecessary unless using `go_resource`s"
|
problem "require \"language/go\" is unnecessary unless using `go_resource`s"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_line(line, lineno)
|
def audit_line(line, lineno)
|
||||||
if line =~ /<(Formula|AmazonWebServicesFormula|ScriptFileFormula|GithubGistFormula)/
|
if line =~ /<(Formula|AmazonWebServicesFormula|ScriptFileFormula|GithubGistFormula)/
|
||||||
@ -983,10 +978,9 @@ class FormulaAuditor
|
|||||||
problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
|
problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
|
return unless line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
|
||||||
problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
|
problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_caveats
|
def audit_caveats
|
||||||
return unless formula.caveats.to_s.include?("setuid")
|
return unless formula.caveats.to_s.include?("setuid")
|
||||||
@ -1115,10 +1109,9 @@ class ResourceAuditor
|
|||||||
problem "version #{version} should not have a leading 'v'"
|
problem "version #{version} should not have a leading 'v'"
|
||||||
end
|
end
|
||||||
|
|
||||||
if version.to_s =~ /_\d+$/
|
return unless version.to_s =~ /_\d+$/
|
||||||
problem "version #{version} should not end with an underline and a number"
|
problem "version #{version} should not end with an underline and a number"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_checksum
|
def audit_checksum
|
||||||
return unless checksum
|
return unless checksum
|
||||||
@ -1183,10 +1176,9 @@ class ResourceAuditor
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if url_strategy == DownloadStrategyDetector.detect("", using)
|
return unless url_strategy == DownloadStrategyDetector.detect("", using)
|
||||||
problem "Redundant :using value in URL"
|
problem "Redundant :using value in URL"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_urls
|
def audit_urls
|
||||||
# Check GNU urls; doesn't apply to mirrors
|
# Check GNU urls; doesn't apply to mirrors
|
||||||
|
@ -531,9 +531,12 @@ module Homebrew
|
|||||||
req = Net::HTTP::Head.new bottle_info.url
|
req = Net::HTTP::Head.new bottle_info.url
|
||||||
req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY
|
req.initialize_http_header "User-Agent" => HOMEBREW_USER_AGENT_RUBY
|
||||||
res = http.request req
|
res = http.request req
|
||||||
if res.is_a?(Net::HTTPSuccess)
|
break if res.is_a?(Net::HTTPSuccess)
|
||||||
break
|
|
||||||
elsif res.is_a?(Net::HTTPClientError)
|
unless res.is_a?(Net::HTTPClientError)
|
||||||
|
raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
|
||||||
|
end
|
||||||
|
|
||||||
if retry_count >= max_retries
|
if retry_count >= max_retries
|
||||||
raise "Failed to find published #{f} bottle at #{url}!"
|
raise "Failed to find published #{f} bottle at #{url}!"
|
||||||
end
|
end
|
||||||
@ -541,9 +544,6 @@ module Homebrew
|
|||||||
wrote_dots = true
|
wrote_dots = true
|
||||||
sleep poll_retry_delay_seconds
|
sleep poll_retry_delay_seconds
|
||||||
retry_count += 1
|
retry_count += 1
|
||||||
else
|
|
||||||
raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
|
return unless git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
|
||||||
# Also can get tap from Jenkins GIT_URL.
|
# Also can get tap from Jenkins GIT_URL.
|
||||||
url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(/\.git$/, "")
|
url_path = git_url.sub(%r{^https?://github\.com/}, "").chomp("/").sub(/\.git$/, "")
|
||||||
begin
|
begin
|
||||||
@ -131,7 +131,6 @@ module Homebrew
|
|||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Wraps command invocations. Instantiated by Test#test.
|
# Wraps command invocations. Instantiated by Test#test.
|
||||||
# Handles logging and pretty-printing.
|
# Handles logging and pretty-printing.
|
||||||
@ -1001,11 +1000,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if git_tag
|
return unless git_tag
|
||||||
safe_system "git", "tag", "--force", git_tag
|
safe_system "git", "tag", "--force", git_tag
|
||||||
safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}"
|
safe_system "git", "push", "--force", remote, "master:master", "refs/tags/#{git_tag}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def sanitize_argv_and_env
|
def sanitize_argv_and_env
|
||||||
if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup")
|
if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup")
|
||||||
@ -1053,14 +1051,13 @@ module Homebrew
|
|||||||
|
|
||||||
ARGV << "--fast" if ARGV.include?("--ci-master")
|
ARGV << "--fast" if ARGV.include?("--ci-master")
|
||||||
|
|
||||||
if ARGV.include? "--local"
|
return unless ARGV.include?("--local")
|
||||||
ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
|
ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
|
||||||
mkdir_p ENV["HOMEBREW_CACHE"]
|
mkdir_p ENV["HOMEBREW_CACHE"]
|
||||||
ENV["HOMEBREW_HOME"] = ENV["HOME"] = "#{Dir.pwd}/home"
|
ENV["HOMEBREW_HOME"] = ENV["HOME"] = "#{Dir.pwd}/home"
|
||||||
mkdir_p ENV["HOME"]
|
mkdir_p ENV["HOME"]
|
||||||
ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
|
ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_bot
|
def test_bot
|
||||||
sanitize_argv_and_env
|
sanitize_argv_and_env
|
||||||
|
@ -158,15 +158,14 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
|
|||||||
|
|
||||||
version.update_commit(last_commit) if head?
|
version.update_commit(last_commit) if head?
|
||||||
|
|
||||||
if @ref_type == :tag && @revision && current_revision
|
return unless @ref_type == :tag
|
||||||
unless current_revision == @revision
|
return unless @revision && current_revision
|
||||||
|
return if current_revision == @revision
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
#{@ref} tag should be #{@revision}
|
#{@ref} tag should be #{@revision}
|
||||||
but is actually #{current_revision}
|
but is actually #{current_revision}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch_last_commit
|
def fetch_last_commit
|
||||||
fetch
|
fetch
|
||||||
@ -336,14 +335,14 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
|||||||
rescue ErrorDuringExecution
|
rescue ErrorDuringExecution
|
||||||
# 33 == range not supported
|
# 33 == range not supported
|
||||||
# try wiping the incomplete download and retrying once
|
# try wiping the incomplete download and retrying once
|
||||||
if $?.exitstatus == 33 && had_incomplete_download
|
unless $?.exitstatus == 33 && had_incomplete_download
|
||||||
|
raise CurlDownloadStrategyError, @url
|
||||||
|
end
|
||||||
|
|
||||||
ohai "Trying a full download"
|
ohai "Trying a full download"
|
||||||
temporary_path.unlink
|
temporary_path.unlink
|
||||||
had_incomplete_download = false
|
had_incomplete_download = false
|
||||||
retry
|
retry
|
||||||
else
|
|
||||||
raise CurlDownloadStrategyError, @url
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
ignore_interrupts { temporary_path.rename(cached_location) }
|
ignore_interrupts { temporary_path.rename(cached_location) }
|
||||||
end
|
end
|
||||||
@ -717,14 +716,14 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_repo
|
def update_repo
|
||||||
if @ref_type == :branch || !ref?
|
return unless @ref_type == :branch || !ref?
|
||||||
|
|
||||||
if !shallow_clone? && shallow_dir?
|
if !shallow_clone? && shallow_dir?
|
||||||
quiet_safe_system "git", "fetch", "origin", "--unshallow"
|
quiet_safe_system "git", "fetch", "origin", "--unshallow"
|
||||||
else
|
else
|
||||||
quiet_safe_system "git", "fetch", "origin"
|
quiet_safe_system "git", "fetch", "origin"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def clone_repo
|
def clone_repo
|
||||||
safe_system "git", *clone_args
|
safe_system "git", *clone_args
|
||||||
@ -798,10 +797,10 @@ end
|
|||||||
class GitHubGitDownloadStrategy < GitDownloadStrategy
|
class GitHubGitDownloadStrategy < GitDownloadStrategy
|
||||||
def initialize(name, resource)
|
def initialize(name, resource)
|
||||||
super
|
super
|
||||||
if @url =~ %r{^https?://github\.com/([^/]+)/([^/]+)\.git$}
|
|
||||||
@user = $1
|
return unless %r{^https?://github\.com/(?<user>[^/]+)/(?<repo>[^/]+)\.git$} =~ @url
|
||||||
@repo = $2
|
@user = user
|
||||||
end
|
@repo = repo
|
||||||
end
|
end
|
||||||
|
|
||||||
def github_last_commit
|
def github_last_commit
|
||||||
|
@ -88,11 +88,11 @@ module HomebrewArgvExtension
|
|||||||
Formulary.from_rack(rack)
|
Formulary.from_rack(rack)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (prefix = f.installed_prefix).directory?
|
unless (prefix = f.installed_prefix).directory?
|
||||||
Keg.new(prefix)
|
|
||||||
else
|
|
||||||
raise MultipleVersionsInstalledError, rack.basename
|
raise MultipleVersionsInstalledError, rack.basename
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Keg.new(prefix)
|
||||||
end
|
end
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
|
@ -289,13 +289,12 @@ module SharedEnvExtension
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
unless gcc_formula.opt_prefix.exist?
|
return if gcc_formula.opt_prefix.exist?
|
||||||
raise <<-EOS.undent
|
raise <<-EOS.undent
|
||||||
The requested Homebrew GCC was not installed. You must:
|
The requested Homebrew GCC was not installed. You must:
|
||||||
brew install #{gcc_formula.full_name}
|
brew install #{gcc_formula.full_name}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def permit_arch_flags; end
|
def permit_arch_flags; end
|
||||||
|
|
||||||
@ -328,10 +327,9 @@ module SharedEnvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_for_compiler_universal_support
|
def check_for_compiler_universal_support
|
||||||
if homebrew_cc =~ GNU_GCC_REGEXP
|
return unless homebrew_cc =~ GNU_GCC_REGEXP
|
||||||
raise "Non-Apple GCC can't build universal binaries"
|
raise "Non-Apple GCC can't build universal binaries"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def gcc_with_cxx11_support?(cc)
|
def gcc_with_cxx11_support?(cc)
|
||||||
version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1]
|
version = cc[/^gcc-(\d+(?:\.\d+)?)$/, 1]
|
||||||
|
@ -48,11 +48,10 @@ module Stdenv
|
|||||||
|
|
||||||
send(compiler)
|
send(compiler)
|
||||||
|
|
||||||
if cc =~ GNU_GCC_REGEXP
|
return unless cc =~ GNU_GCC_REGEXP
|
||||||
gcc_formula = gcc_version_formula($&)
|
gcc_formula = gcc_version_formula($&)
|
||||||
append_path "PATH", gcc_formula.opt_bin.to_s
|
append_path "PATH", gcc_formula.opt_bin.to_s
|
||||||
end
|
end
|
||||||
end
|
|
||||||
alias generic_setup_build_environment setup_build_environment
|
alias generic_setup_build_environment setup_build_environment
|
||||||
|
|
||||||
def homebrew_extra_pkg_config_paths
|
def homebrew_extra_pkg_config_paths
|
||||||
@ -174,11 +173,11 @@ module Stdenv
|
|||||||
append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
|
append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
|
||||||
append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags
|
append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags
|
||||||
|
|
||||||
if compiler != :clang && Hardware.is_32_bit?
|
return if compiler == :clang
|
||||||
|
return unless Hardware.is_32_bit?
|
||||||
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
|
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
|
||||||
replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
|
replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def cxx11
|
def cxx11
|
||||||
if compiler == :clang
|
if compiler == :clang
|
||||||
|
@ -276,13 +276,13 @@ module Superenv
|
|||||||
self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
|
self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
|
||||||
|
|
||||||
# GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
|
# GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
|
||||||
if compiler != :clang && Hardware::CPU.is_32_bit?
|
return if compiler == :clang
|
||||||
|
return unless Hardware::CPU.is_32_bit?
|
||||||
self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
|
self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
|
||||||
/-march=\S*/,
|
/-march=\S*/,
|
||||||
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
|
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def permit_arch_flags
|
def permit_arch_flags
|
||||||
append "HOMEBREW_CCCFG", "K"
|
append "HOMEBREW_CCCFG", "K"
|
||||||
|
@ -89,12 +89,11 @@ module FileUtils
|
|||||||
# A version of mkdir that also changes to that folder in a block.
|
# A version of mkdir that also changes to that folder in a block.
|
||||||
def mkdir(name, &_block)
|
def mkdir(name, &_block)
|
||||||
old_mkdir(name)
|
old_mkdir(name)
|
||||||
if block_given?
|
return unless block_given?
|
||||||
chdir name do
|
chdir name do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
module_function :mkdir
|
module_function :mkdir
|
||||||
|
|
||||||
# Run `scons` using a Homebrew-installed version rather than whatever is in the `PATH`.
|
# Run `scons` using a Homebrew-installed version rather than whatever is in the `PATH`.
|
||||||
|
@ -20,7 +20,7 @@ module Stdenv
|
|||||||
|
|
||||||
# Leopard's ld needs some convincing that it's building 64-bit
|
# Leopard's ld needs some convincing that it's building 64-bit
|
||||||
# See: https://github.com/mistydemeo/tigerbrew/issues/59
|
# See: https://github.com/mistydemeo/tigerbrew/issues/59
|
||||||
if MacOS.version == :leopard && MacOS.prefer_64_bit?
|
return unless MacOS.version == :leopard && MacOS.prefer_64_bit?
|
||||||
append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
|
append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
|
||||||
|
|
||||||
# Many, many builds are broken thanks to Leopard's buggy ld.
|
# Many, many builds are broken thanks to Leopard's buggy ld.
|
||||||
@ -28,7 +28,6 @@ module Stdenv
|
|||||||
# depend on it already being installed to build itself.
|
# depend on it already being installed to build itself.
|
||||||
ld64 if Formula["ld64"].installed?
|
ld64 if Formula["ld64"].installed?
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def homebrew_extra_pkg_config_paths
|
def homebrew_extra_pkg_config_paths
|
||||||
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
||||||
@ -65,7 +64,7 @@ module Stdenv
|
|||||||
delete("CPATH")
|
delete("CPATH")
|
||||||
remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
|
remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
|
||||||
|
|
||||||
if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
|
return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
|
||||||
delete("SDKROOT")
|
delete("SDKROOT")
|
||||||
remove_from_cflags "-isysroot #{sdk}"
|
remove_from_cflags "-isysroot #{sdk}"
|
||||||
remove "CPPFLAGS", "-isysroot #{sdk}"
|
remove "CPPFLAGS", "-isysroot #{sdk}"
|
||||||
@ -78,7 +77,6 @@ module Stdenv
|
|||||||
end
|
end
|
||||||
remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def macosxsdk(version = MacOS.version)
|
def macosxsdk(version = MacOS.version)
|
||||||
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
|
# Sets all needed lib and include dirs to CFLAGS, CPPFLAGS, LDFLAGS.
|
||||||
@ -89,7 +87,7 @@ module Stdenv
|
|||||||
self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
|
self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
|
||||||
prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
|
prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
|
||||||
|
|
||||||
if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
|
return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
|
||||||
# Extra setup to support Xcode 4.3+ without CLT.
|
# Extra setup to support Xcode 4.3+ without CLT.
|
||||||
self["SDKROOT"] = sdk
|
self["SDKROOT"] = sdk
|
||||||
# Tell clang/gcc where system include's are:
|
# Tell clang/gcc where system include's are:
|
||||||
@ -103,7 +101,6 @@ module Stdenv
|
|||||||
append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
|
append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
|
||||||
append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Some configure scripts won't find libxml2 without help
|
# Some configure scripts won't find libxml2 without help
|
||||||
def libxml2
|
def libxml2
|
||||||
|
@ -64,14 +64,13 @@ module FormulaCellarChecks
|
|||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
checker = LinkageChecker.new(keg, formula)
|
checker = LinkageChecker.new(keg, formula)
|
||||||
|
|
||||||
if checker.broken_dylibs?
|
return unless checker.broken_dylibs?
|
||||||
audit_check_output <<-EOS.undent
|
audit_check_output <<-EOS.undent
|
||||||
The installation was broken.
|
The installation was broken.
|
||||||
Broken dylib links found:
|
Broken dylib links found:
|
||||||
#{checker.broken_dylibs.to_a * "\n "}
|
#{checker.broken_dylibs.to_a * "\n "}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_installed
|
def audit_installed
|
||||||
generic_audit_installed
|
generic_audit_installed
|
||||||
|
@ -31,11 +31,10 @@ module Utils
|
|||||||
# sometimes a formula has just :tiger_altivec, other times it has
|
# sometimes a formula has just :tiger_altivec, other times it has
|
||||||
# :tiger_g4, :tiger_g5, etc.
|
# :tiger_g4, :tiger_g5, etc.
|
||||||
def find_altivec_tag(tag)
|
def find_altivec_tag(tag)
|
||||||
if tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
|
return unless tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
|
||||||
altivec_tag = "#{$1}_altivec".to_sym
|
altivec_tag = "#{$1}_altivec".to_sym
|
||||||
altivec_tag if key?(altivec_tag)
|
altivec_tag if key?(altivec_tag)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Allows a bottle tag to specify a specific OS or later,
|
# Allows a bottle tag to specify a specific OS or later,
|
||||||
# so the same bottle can target multiple OSs.
|
# so the same bottle can target multiple OSs.
|
||||||
|
@ -59,10 +59,9 @@ module StringInreplaceExtension
|
|||||||
# Looks for Makefile style variable defintions and replaces the
|
# Looks for Makefile style variable defintions and replaces the
|
||||||
# value with "new_value", or removes the definition entirely.
|
# value with "new_value", or removes the definition entirely.
|
||||||
def change_make_var!(flag, new_value)
|
def change_make_var!(flag, new_value)
|
||||||
unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
|
return if gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
|
||||||
errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
|
errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Removes variable assignments completely.
|
# Removes variable assignments completely.
|
||||||
def remove_make_var!(flags)
|
def remove_make_var!(flags)
|
||||||
|
@ -224,11 +224,10 @@ class Formula
|
|||||||
|
|
||||||
def set_spec(name)
|
def set_spec(name)
|
||||||
spec = self.class.send(name)
|
spec = self.class.send(name)
|
||||||
if spec.url
|
return unless spec.url
|
||||||
spec.owner = self
|
spec.owner = self
|
||||||
instance_variable_set("@#{name}", spec)
|
instance_variable_set("@#{name}", spec)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def determine_active_spec(requested)
|
def determine_active_spec(requested)
|
||||||
spec = send(requested) || stable || devel || head
|
spec = send(requested) || stable || devel || head
|
||||||
@ -246,10 +245,9 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
val = version.respond_to?(:to_str) ? version.to_str : version
|
val = version.respond_to?(:to_str) ? version.to_str : version
|
||||||
if val.nil? || val.empty? || val =~ /\s/
|
return unless val.nil? || val.empty? || val =~ /\s/
|
||||||
raise FormulaValidationError.new(full_name, :version, val)
|
raise FormulaValidationError.new(full_name, :version, val)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
@ -1065,11 +1063,10 @@ class Formula
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def patch
|
def patch
|
||||||
unless patchlist.empty?
|
return if patchlist.empty?
|
||||||
ohai "Patching"
|
ohai "Patching"
|
||||||
patchlist.each(&:apply)
|
patchlist.each(&:apply)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# yields |self,staging| with current working directory set to the uncompressed tarball
|
# yields |self,staging| with current working directory set to the uncompressed tarball
|
||||||
# where staging is a Mktemp staging context
|
# where staging is a Mktemp staging context
|
||||||
@ -1094,11 +1091,12 @@ class Formula
|
|||||||
def lock
|
def lock
|
||||||
@lock = FormulaLock.new(name)
|
@lock = FormulaLock.new(name)
|
||||||
@lock.lock
|
@lock.lock
|
||||||
if oldname && (oldname_rack = HOMEBREW_CELLAR/oldname).exist? && oldname_rack.resolved_path == rack
|
return unless oldname
|
||||||
|
return unless (oldname_rack = HOMEBREW_CELLAR/oldname).exist?
|
||||||
|
return unless oldname_rack.resolved_path == rack
|
||||||
@oldname_lock = FormulaLock.new(oldname)
|
@oldname_lock = FormulaLock.new(oldname)
|
||||||
@oldname_lock.lock
|
@oldname_lock.lock
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def unlock
|
def unlock
|
||||||
@ -1427,11 +1425,10 @@ class Formula
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def print_tap_action(options = {})
|
def print_tap_action(options = {})
|
||||||
if tap?
|
return unless tap?
|
||||||
verb = options[:verb] || "Installing"
|
verb = options[:verb] || "Installing"
|
||||||
ohai "#{verb} #{name} from #{tap}"
|
ohai "#{verb} #{name} from #{tap}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def env
|
def env
|
||||||
|
@ -133,13 +133,11 @@ class FormulaInstaller
|
|||||||
begin
|
begin
|
||||||
compute_dependencies
|
compute_dependencies
|
||||||
rescue TapFormulaUnavailableError => e
|
rescue TapFormulaUnavailableError => e
|
||||||
if e.tap.installed?
|
raise if e.tap.installed?
|
||||||
raise
|
|
||||||
else
|
|
||||||
e.tap.install
|
e.tap.install
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
end
|
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
e.dependent = formula.full_name
|
e.dependent = formula.full_name
|
||||||
raise
|
raise
|
||||||
@ -148,24 +146,25 @@ class FormulaInstaller
|
|||||||
def check_install_sanity
|
def check_install_sanity
|
||||||
raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula)
|
raise FormulaInstallationAlreadyAttemptedError, formula if @@attempted.include?(formula)
|
||||||
|
|
||||||
unless skip_deps_check?
|
return if skip_deps_check?
|
||||||
|
|
||||||
recursive_deps = formula.recursive_dependencies
|
recursive_deps = formula.recursive_dependencies
|
||||||
unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
|
unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
|
||||||
dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
|
dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
|
||||||
end
|
end
|
||||||
raise CannotInstallFormulaError,
|
|
||||||
"You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" unless unlinked_deps.empty?
|
unless unlinked_deps.empty?
|
||||||
|
raise CannotInstallFormulaError, "You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed"
|
||||||
|
end
|
||||||
|
|
||||||
pinned_unsatisfied_deps = recursive_deps.select do |dep|
|
pinned_unsatisfied_deps = recursive_deps.select do |dep|
|
||||||
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
|
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
|
||||||
end
|
end
|
||||||
|
|
||||||
unless pinned_unsatisfied_deps.empty?
|
return if pinned_unsatisfied_deps.empty?
|
||||||
raise CannotInstallFormulaError,
|
raise CannotInstallFormulaError,
|
||||||
"You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
|
"You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_bottle_preinstall
|
def build_bottle_preinstall
|
||||||
@etc_var_glob ||= "#{HOMEBREW_PREFIX}/{etc,var}/**/*"
|
@etc_var_glob ||= "#{HOMEBREW_PREFIX}/{etc,var}/**/*"
|
||||||
@ -285,11 +284,10 @@ class FormulaInstaller
|
|||||||
#{formula}: #{e.message}
|
#{formula}: #{e.message}
|
||||||
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
|
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
|
||||||
EOS
|
EOS
|
||||||
if ARGV.homebrew_developer?
|
|
||||||
raise
|
raise if ARGV.homebrew_developer?
|
||||||
else
|
|
||||||
$stderr.puts "Please report this to the #{formula.tap} tap!"
|
$stderr.puts "Please report this to the #{formula.tap} tap!"
|
||||||
end
|
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
f.linked_keg.exist? && f.opt_prefix.exist?
|
f.linked_keg.exist? && f.opt_prefix.exist?
|
||||||
@ -492,11 +490,10 @@ class FormulaInstaller
|
|||||||
|
|
||||||
c = Caveats.new(formula)
|
c = Caveats.new(formula)
|
||||||
|
|
||||||
unless c.empty?
|
return if c.empty?
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
ohai "Caveats", c.caveats
|
ohai "Caveats", c.caveats
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def finish
|
def finish
|
||||||
return if only_deps?
|
return if only_deps?
|
||||||
@ -706,14 +703,13 @@ class FormulaInstaller
|
|||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
unless link_overwrite_backup.empty?
|
return if link_overwrite_backup.empty?
|
||||||
opoo "These files were overwritten during `brew link` step:"
|
opoo "These files were overwritten during `brew link` step:"
|
||||||
puts link_overwrite_backup.keys
|
puts link_overwrite_backup.keys
|
||||||
puts
|
puts
|
||||||
puts "They have been backed up in #{backup_dir}"
|
puts "They have been backed up in #{backup_dir}"
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def install_plist
|
def install_plist
|
||||||
return unless formula.plist
|
return unless formula.plist
|
||||||
@ -804,11 +800,10 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def audit_check_output(output)
|
def audit_check_output(output)
|
||||||
if output
|
return unless output
|
||||||
opoo output
|
opoo output
|
||||||
@show_summary_heading = true
|
@show_summary_heading = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def audit_installed
|
def audit_installed
|
||||||
audit_check_output(check_env_path(formula.bin))
|
audit_check_output(check_env_path(formula.bin))
|
||||||
@ -823,7 +818,7 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lock
|
def lock
|
||||||
if (@@locked ||= []).empty?
|
return unless (@@locked ||= []).empty?
|
||||||
formula.recursive_dependencies.each do |dep|
|
formula.recursive_dependencies.each do |dep|
|
||||||
@@locked << dep.to_formula
|
@@locked << dep.to_formula
|
||||||
end unless ignore_deps?
|
end unless ignore_deps?
|
||||||
@ -832,13 +827,11 @@ class FormulaInstaller
|
|||||||
@@locked.each(&:lock)
|
@@locked.each(&:lock)
|
||||||
@hold_locks = true
|
@hold_locks = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def unlock
|
def unlock
|
||||||
if hold_locks?
|
return unless hold_locks?
|
||||||
@@locked.each(&:unlock)
|
@@locked.each(&:unlock)
|
||||||
@@locked.clear
|
@@locked.clear
|
||||||
@hold_locks = false
|
@hold_locks = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -10,17 +10,15 @@ class FormulaLock
|
|||||||
def lock
|
def lock
|
||||||
HOMEBREW_LOCK_DIR.mkpath
|
HOMEBREW_LOCK_DIR.mkpath
|
||||||
@lockfile = get_or_create_lockfile
|
@lockfile = get_or_create_lockfile
|
||||||
unless @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
|
return if @lockfile.flock(File::LOCK_EX | File::LOCK_NB)
|
||||||
raise OperationInProgressError, @name
|
raise OperationInProgressError, @name
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def unlock
|
def unlock
|
||||||
unless @lockfile.nil? || @lockfile.closed?
|
return if @lockfile.nil? || @lockfile.closed?
|
||||||
@lockfile.flock(File::LOCK_UN)
|
@lockfile.flock(File::LOCK_UN)
|
||||||
@lockfile.close
|
@lockfile.close
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def with_lock
|
def with_lock
|
||||||
lock
|
lock
|
||||||
|
@ -314,7 +314,9 @@ class Formulary
|
|||||||
possible_tap_formulae = tap_paths(ref)
|
possible_tap_formulae = tap_paths(ref)
|
||||||
if possible_tap_formulae.size > 1
|
if possible_tap_formulae.size > 1
|
||||||
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
|
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
|
||||||
elsif possible_tap_formulae.size == 1
|
end
|
||||||
|
|
||||||
|
if possible_tap_formulae.size == 1
|
||||||
path = possible_tap_formulae.first.resolved_path
|
path = possible_tap_formulae.first.resolved_path
|
||||||
name = path.basename(".rb").to_s
|
name = path.basename(".rb").to_s
|
||||||
return FormulaLoader.new(name, path)
|
return FormulaLoader.new(name, path)
|
||||||
@ -336,7 +338,9 @@ class Formulary
|
|||||||
|
|
||||||
if possible_tap_newname_formulae.size > 1
|
if possible_tap_newname_formulae.size > 1
|
||||||
raise TapFormulaWithOldnameAmbiguityError.new(ref, possible_tap_newname_formulae)
|
raise TapFormulaWithOldnameAmbiguityError.new(ref, possible_tap_newname_formulae)
|
||||||
elsif !possible_tap_newname_formulae.empty?
|
end
|
||||||
|
|
||||||
|
unless possible_tap_newname_formulae.empty?
|
||||||
return TapLoader.new(possible_tap_newname_formulae.first)
|
return TapLoader.new(possible_tap_newname_formulae.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -368,7 +372,9 @@ class Formulary
|
|||||||
possible_pinned_tap_formulae = tap_paths(ref, Dir["#{HOMEBREW_LIBRARY}/PinnedTaps/*/*/"]).map(&:realpath)
|
possible_pinned_tap_formulae = tap_paths(ref, Dir["#{HOMEBREW_LIBRARY}/PinnedTaps/*/*/"]).map(&:realpath)
|
||||||
if possible_pinned_tap_formulae.size > 1
|
if possible_pinned_tap_formulae.size > 1
|
||||||
raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae)
|
raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae)
|
||||||
elsif possible_pinned_tap_formulae.size == 1
|
end
|
||||||
|
|
||||||
|
if possible_pinned_tap_formulae.size == 1
|
||||||
selected_formula = factory(possible_pinned_tap_formulae.first, spec)
|
selected_formula = factory(possible_pinned_tap_formulae.first, spec)
|
||||||
if core_path(ref).file?
|
if core_path(ref).file?
|
||||||
opoo <<-EOS.undent
|
opoo <<-EOS.undent
|
||||||
|
@ -394,11 +394,10 @@ class Keg
|
|||||||
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
||||||
make_relative_symlink(opt_record, path, mode)
|
make_relative_symlink(opt_record, path, mode)
|
||||||
|
|
||||||
if oldname_opt_record
|
return unless oldname_opt_record
|
||||||
oldname_opt_record.delete
|
oldname_opt_record.delete
|
||||||
make_relative_symlink(oldname_opt_record, path, mode)
|
make_relative_symlink(oldname_opt_record, path, mode)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def delete_pyc_files!
|
def delete_pyc_files!
|
||||||
find { |pn| pn.delete if %w[.pyc .pyo].include?(pn.extname) }
|
find { |pn| pn.delete if %w[.pyc .pyo].include?(pn.extname) }
|
||||||
@ -423,18 +422,19 @@ class Keg
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if stat.directory?
|
return unless stat.directory?
|
||||||
begin
|
begin
|
||||||
keg = Keg.for(src)
|
keg = Keg.for(src)
|
||||||
rescue NotAKegError
|
rescue NotAKegError
|
||||||
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
|
if ARGV.verbose?
|
||||||
|
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar"
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
dst.unlink unless mode.dry_run
|
dst.unlink unless mode.dry_run
|
||||||
keg.link_dir(src, mode) { :mkpath }
|
keg.link_dir(src, mode) { :mkpath }
|
||||||
return true
|
true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_relative_symlink(dst, src, mode)
|
def make_relative_symlink(dst, src, mode)
|
||||||
@ -462,9 +462,8 @@ class Keg
|
|||||||
dst.delete if mode.overwrite && (dst.exist? || dst.symlink?)
|
dst.delete if mode.overwrite && (dst.exist? || dst.symlink?)
|
||||||
dst.make_relative_symlink(src)
|
dst.make_relative_symlink(src)
|
||||||
rescue Errno::EEXIST => e
|
rescue Errno::EEXIST => e
|
||||||
if dst.exist?
|
raise ConflictError.new(self, src.relative_path_from(path), dst, e) if dst.exist?
|
||||||
raise ConflictError.new(self, src.relative_path_from(path), dst, e)
|
if dst.symlink?
|
||||||
elsif dst.symlink?
|
|
||||||
dst.unlink
|
dst.unlink
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
@ -182,7 +182,7 @@ class Migrator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def repin
|
def repin
|
||||||
if pinned?
|
return unless pinned?
|
||||||
# old_pin_record is a relative symlink and when we try to to read it
|
# old_pin_record is a relative symlink and when we try to to read it
|
||||||
# from <dir> we actually try to find file
|
# from <dir> we actually try to find file
|
||||||
# <dir>/../<...>/../Cellar/name/version.
|
# <dir>/../<...>/../Cellar/name/version.
|
||||||
@ -198,7 +198,6 @@ class Migrator
|
|||||||
new_pin_record.make_relative_symlink(src_oldname.sub(oldname, newname))
|
new_pin_record.make_relative_symlink(src_oldname.sub(oldname, newname))
|
||||||
old_pin_record.delete
|
old_pin_record.delete
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def unlink_oldname
|
def unlink_oldname
|
||||||
oh1 "Unlinking #{Tty.green}#{oldname}#{Tty.reset}"
|
oh1 "Unlinking #{Tty.green}#{oldname}#{Tty.reset}"
|
||||||
@ -254,11 +253,10 @@ class Migrator
|
|||||||
|
|
||||||
# Link keg to opt if it was linked before migrating.
|
# Link keg to opt if it was linked before migrating.
|
||||||
def link_oldname_opt
|
def link_oldname_opt
|
||||||
if old_opt_record
|
return unless old_opt_record
|
||||||
old_opt_record.delete if old_opt_record.symlink?
|
old_opt_record.delete if old_opt_record.symlink?
|
||||||
old_opt_record.make_relative_symlink(new_linked_keg_record)
|
old_opt_record.make_relative_symlink(new_linked_keg_record)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# After migtaion every INSTALL_RECEIPT.json has wrong path to the formula
|
# After migtaion every INSTALL_RECEIPT.json has wrong path to the formula
|
||||||
# so we must update INSTALL_RECEIPTs
|
# so we must update INSTALL_RECEIPTs
|
||||||
@ -316,7 +314,7 @@ class Migrator
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless old_linked_keg.nil?
|
return if old_linked_keg.nil?
|
||||||
# The keg used to be linked and when we backup everything we restore
|
# The keg used to be linked and when we backup everything we restore
|
||||||
# Cellar/oldname, the target also gets restored, so we are able to
|
# Cellar/oldname, the target also gets restored, so we are able to
|
||||||
# create a keg using its old path
|
# create a keg using its old path
|
||||||
@ -334,7 +332,6 @@ class Migrator
|
|||||||
old_linked_keg.optlink
|
old_linked_keg.optlink
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def backup_oldname_cellar
|
def backup_oldname_cellar
|
||||||
FileUtils.mv(new_cellar, old_cellar) unless old_cellar.exist?
|
FileUtils.mv(new_cellar, old_cellar) unless old_cellar.exist?
|
||||||
|
@ -18,12 +18,10 @@ module OS
|
|||||||
when "10.11" then "8.0"
|
when "10.11" then "8.0"
|
||||||
when "10.12" then "8.0"
|
when "10.12" then "8.0"
|
||||||
else
|
else
|
||||||
|
raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease?
|
||||||
|
|
||||||
# Default to newest known version of Xcode for unreleased macOS versions.
|
# Default to newest known version of Xcode for unreleased macOS versions.
|
||||||
if OS::Mac.prerelease?
|
|
||||||
"8.0"
|
"8.0"
|
||||||
else
|
|
||||||
raise "macOS '#{MacOS.version}' is invalid"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,14 +130,13 @@ class ExternalPatch
|
|||||||
patch_dir = Pathname.pwd
|
patch_dir = Pathname.pwd
|
||||||
if patch_files.empty?
|
if patch_files.empty?
|
||||||
children = patch_dir.children
|
children = patch_dir.children
|
||||||
if children.length == 1 && children.first.file?
|
if children.length != 1 || !children.first.file?
|
||||||
patch_files << children.first.basename
|
|
||||||
else
|
|
||||||
raise MissingApplyError, <<-EOS.undent
|
raise MissingApplyError, <<-EOS.undent
|
||||||
There should be exactly one patch file in the staging directory unless
|
There should be exactly one patch file in the staging directory unless
|
||||||
the "apply" method was used one or more times in the patch-do block.
|
the "apply" method was used one or more times in the patch-do block.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
patch_files << children.first.basename
|
||||||
end
|
end
|
||||||
dir.cd do
|
dir.cd do
|
||||||
patch_files.each do |patch_file|
|
patch_files.each do |patch_file|
|
||||||
|
@ -83,13 +83,12 @@ class Requirement
|
|||||||
# PATH.
|
# PATH.
|
||||||
# This is undocumented magic and it should be removed, but we need to add
|
# 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.
|
# a way to declare path-based requirements that work with superenv first.
|
||||||
if @satisfied_result.is_a?(Pathname)
|
return unless @satisfied_result.is_a?(Pathname)
|
||||||
parent = @satisfied_result.parent
|
parent = @satisfied_result.parent
|
||||||
unless ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
|
|
||||||
|
return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
|
||||||
ENV.append_path("PATH", parent)
|
ENV.append_path("PATH", parent)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def env
|
def env
|
||||||
self.class.env
|
self.class.env
|
||||||
@ -199,13 +198,10 @@ class Requirement
|
|||||||
|
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
f.requirements.each do |req|
|
f.requirements.each do |req|
|
||||||
if prune?(f, req, &block)
|
next if prune?(f, req, &block)
|
||||||
next
|
|
||||||
else
|
|
||||||
reqs << req
|
reqs << req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
reqs
|
reqs
|
||||||
end
|
end
|
||||||
|
@ -130,10 +130,9 @@ class Tap
|
|||||||
# The issues URL of this {Tap}.
|
# The issues URL of this {Tap}.
|
||||||
# e.g. `https://github.com/user/homebrew-repo/issues`
|
# e.g. `https://github.com/user/homebrew-repo/issues`
|
||||||
def issues_url
|
def issues_url
|
||||||
if official? || !custom_remote?
|
return unless official? || !custom_remote?
|
||||||
"https://github.com/#{user}/homebrew-#{repo}/issues"
|
"https://github.com/#{user}/homebrew-#{repo}/issues"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
@ -236,7 +235,9 @@ class Tap
|
|||||||
puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" unless quiet
|
puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{path.abv})" unless quiet
|
||||||
Descriptions.cache_formulae(formula_names)
|
Descriptions.cache_formulae(formula_names)
|
||||||
|
|
||||||
if !options[:clone_target] && private? && !quiet
|
return if options[:clone_target]
|
||||||
|
return unless private?
|
||||||
|
return if quiet
|
||||||
puts <<-EOS.undent
|
puts <<-EOS.undent
|
||||||
It looks like you tapped a private repository. To avoid entering your
|
It looks like you tapped a private repository. To avoid entering your
|
||||||
credentials each time you update, you can use git HTTP credential
|
credentials each time you update, you can use git HTTP credential
|
||||||
@ -245,7 +246,6 @@ class Tap
|
|||||||
git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
|
git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def link_manpages
|
def link_manpages
|
||||||
link_path_manpages(path, "brew tap --repair")
|
link_path_manpages(path, "brew tap --repair")
|
||||||
|
@ -45,10 +45,9 @@ class TestbotStepTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
unless passed?
|
return if passed?
|
||||||
raise "INFO: Previous test failed with ENV['TRAVIS'] = #{ENV["TRAVIS"].inspect}"
|
raise "INFO: Previous test failed with ENV['TRAVIS'] = #{ENV["TRAVIS"].inspect}"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def stub_test_instance
|
def stub_test_instance
|
||||||
stub(
|
stub(
|
||||||
|
@ -39,10 +39,9 @@ class IntegrationCommandTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def needs_test_cmd_taps
|
def needs_test_cmd_taps
|
||||||
unless ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
|
return if ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"]
|
||||||
skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
|
skip "HOMEBREW_TEST_OFFICIAL_CMD_TAPS is not set"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def needs_macos
|
def needs_macos
|
||||||
skip "Not on MacOS" unless OS.mac?
|
skip "Not on MacOS" unless OS.mac?
|
||||||
|
@ -57,11 +57,10 @@ module Homebrew
|
|||||||
super
|
super
|
||||||
files_after_test = []
|
files_after_test = []
|
||||||
Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") }
|
Find.find(TEST_TMPDIR) { |f| files_after_test << f.sub(TEST_TMPDIR, "") }
|
||||||
if @__files_before_test != files_after_test
|
return if @__files_before_test == files_after_test
|
||||||
@@log.puts location, diff(@__files_before_test, files_after_test)
|
@@log.puts location, diff(@__files_before_test, files_after_test)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
class TestCase < ::Minitest::Test
|
class TestCase < ::Minitest::Test
|
||||||
require "test/helper/shutup"
|
require "test/helper/shutup"
|
||||||
|
@ -218,14 +218,10 @@ def interactive_shell(f = nil)
|
|||||||
|
|
||||||
Process.wait fork { exec ENV["SHELL"] }
|
Process.wait fork { exec ENV["SHELL"] }
|
||||||
|
|
||||||
if $?.success?
|
return if $?.success?
|
||||||
return
|
raise "Aborted due to non-zero exit status (#{$?.exitstatus})" if $?.exited?
|
||||||
elsif $?.exited?
|
|
||||||
raise "Aborted due to non-zero exit status (#{$?.exitstatus})"
|
|
||||||
else
|
|
||||||
raise $?.inspect
|
raise $?.inspect
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def self._system(cmd, *args)
|
def self._system(cmd, *args)
|
||||||
@ -325,7 +321,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if $times.nil?
|
return unless $times.nil?
|
||||||
$times = {}
|
$times = {}
|
||||||
at_exit do
|
at_exit do
|
||||||
col_width = [$times.keys.map(&:size).max + 2, 15].max
|
col_width = [$times.keys.map(&:size).max + 2, 15].max
|
||||||
@ -335,7 +331,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def with_system_path
|
def with_system_path
|
||||||
old_path = ENV["PATH"]
|
old_path = ENV["PATH"]
|
||||||
@ -608,7 +603,8 @@ def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
|
|||||||
dst_dir.parent.mkpath
|
dst_dir.parent.mkpath
|
||||||
dst.make_relative_symlink(src)
|
dst.make_relative_symlink(src)
|
||||||
end
|
end
|
||||||
unless conflicts.empty?
|
|
||||||
|
return if conflicts.empty?
|
||||||
onoe <<-EOS.undent
|
onoe <<-EOS.undent
|
||||||
Could not link:
|
Could not link:
|
||||||
#{conflicts.join("\n")}
|
#{conflicts.join("\n")}
|
||||||
@ -616,7 +612,6 @@ def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
|
|||||||
Please delete these paths and run `#{command}`.
|
Please delete these paths and run `#{command}`.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def link_path_manpages(path, command)
|
def link_path_manpages(path, command)
|
||||||
link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share/man", command)
|
link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share/man", command)
|
||||||
|
@ -14,11 +14,8 @@ module Utils
|
|||||||
def self.popen(args, mode)
|
def self.popen(args, mode)
|
||||||
IO.popen("-", mode) do |pipe|
|
IO.popen("-", mode) do |pipe|
|
||||||
if pipe
|
if pipe
|
||||||
if block_given?
|
return pipe.read unless block_given?
|
||||||
yield pipe
|
yield pipe
|
||||||
else
|
|
||||||
return pipe.read
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
$stderr.reopen("/dev/null", "w")
|
$stderr.reopen("/dev/null", "w")
|
||||||
exec(*args)
|
exec(*args)
|
||||||
|
@ -192,11 +192,10 @@ class Version
|
|||||||
end
|
end
|
||||||
|
|
||||||
def initialize(val)
|
def initialize(val)
|
||||||
if val.respond_to?(:to_str)
|
unless val.respond_to?(:to_str)
|
||||||
@version = val.to_str
|
|
||||||
else
|
|
||||||
raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
|
raise TypeError, "Version value must be a string; got a #{val.class} (#{val})"
|
||||||
end
|
end
|
||||||
|
@version = val.to_str
|
||||||
end
|
end
|
||||||
|
|
||||||
def detected_from_url?
|
def detected_from_url?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user