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,13 +203,12 @@ 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.
|
||||||
Run `brew update` to get the latest Homebrew updates!
|
Run `brew update` to get the latest Homebrew updates!
|
||||||
EOS
|
EOS
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -549,11 +549,10 @@ 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)
|
||||||
|
@ -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,9 +284,8 @@ 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
|
||||||
@ -350,9 +349,8 @@ 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
|
||||||
@ -485,9 +483,8 @@ 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
|
||||||
@ -564,9 +561,9 @@ 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?
|
||||||
problem "Unrecognized bottle modifier"
|
return if formula.bottle_disable_reason.valid?
|
||||||
end
|
problem "Unrecognized bottle modifier"
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_github_repository
|
def audit_github_repository
|
||||||
@ -594,9 +591,8 @@ 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
|
||||||
@ -736,9 +732,8 @@ 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)
|
||||||
@ -983,9 +978,8 @@ 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
|
||||||
@ -1115,9 +1109,8 @@ 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
|
||||||
@ -1183,9 +1176,8 @@ 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
|
||||||
|
@ -531,19 +531,19 @@ 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)
|
||||||
if retry_count >= max_retries
|
|
||||||
raise "Failed to find published #{f} bottle at #{url}!"
|
|
||||||
end
|
|
||||||
print(wrote_dots ? "." : "Waiting on Bintray.")
|
|
||||||
wrote_dots = true
|
|
||||||
sleep poll_retry_delay_seconds
|
|
||||||
retry_count += 1
|
|
||||||
else
|
|
||||||
raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
|
raise "Failed to find published #{f} bottle at #{url} (#{res.code} #{res.message})!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if retry_count >= max_retries
|
||||||
|
raise "Failed to find published #{f} bottle at #{url}!"
|
||||||
|
end
|
||||||
|
print(wrote_dots ? "." : "Waiting on Bintray.")
|
||||||
|
wrote_dots = true
|
||||||
|
sleep poll_retry_delay_seconds
|
||||||
|
retry_count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,13 +123,12 @@ 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
|
||||||
return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX
|
return Tap.fetch(url_path) if url_path =~ HOMEBREW_TAP_REGEX
|
||||||
rescue
|
rescue
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1001,10 +1000,9 @@ 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
|
||||||
@ -1053,13 +1051,12 @@ 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
|
||||||
|
@ -158,14 +158,13 @@ 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
|
||||||
raise <<-EOS.undent
|
return if current_revision == @revision
|
||||||
#{@ref} tag should be #{@revision}
|
raise <<-EOS.undent
|
||||||
but is actually #{current_revision}
|
#{@ref} tag should be #{@revision}
|
||||||
EOS
|
but is actually #{current_revision}
|
||||||
end
|
EOS
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_last_commit
|
def fetch_last_commit
|
||||||
@ -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
|
||||||
ohai "Trying a full download"
|
|
||||||
temporary_path.unlink
|
|
||||||
had_incomplete_download = false
|
|
||||||
retry
|
|
||||||
else
|
|
||||||
raise CurlDownloadStrategyError, @url
|
raise CurlDownloadStrategyError, @url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ohai "Trying a full download"
|
||||||
|
temporary_path.unlink
|
||||||
|
had_incomplete_download = false
|
||||||
|
retry
|
||||||
end
|
end
|
||||||
ignore_interrupts { temporary_path.rename(cached_location) }
|
ignore_interrupts { temporary_path.rename(cached_location) }
|
||||||
end
|
end
|
||||||
@ -717,12 +716,12 @@ 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?
|
|
||||||
quiet_safe_system "git", "fetch", "origin", "--unshallow"
|
if !shallow_clone? && shallow_dir?
|
||||||
else
|
quiet_safe_system "git", "fetch", "origin", "--unshallow"
|
||||||
quiet_safe_system "git", "fetch", "origin"
|
else
|
||||||
end
|
quiet_safe_system "git", "fetch", "origin"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -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,12 +289,11 @@ 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,9 +327,8 @@ 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)
|
||||||
|
@ -48,10 +48,9 @@ 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
|
||||||
|
|
||||||
@ -174,10 +173,10 @@ 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
|
||||||
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
|
return unless Hardware.is_32_bit?
|
||||||
replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
|
# Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
|
||||||
end
|
replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
|
||||||
end
|
end
|
||||||
|
|
||||||
def cxx11
|
def cxx11
|
||||||
|
@ -276,12 +276,12 @@ 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
|
||||||
self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
|
return unless Hardware::CPU.is_32_bit?
|
||||||
/-march=\S*/,
|
self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
|
||||||
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
|
/-march=\S*/,
|
||||||
)
|
"-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
|
||||||
end
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def permit_arch_flags
|
def permit_arch_flags
|
||||||
|
@ -89,10 +89,9 @@ 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
|
||||||
|
@ -20,14 +20,13 @@ 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.
|
||||||
# Our ld64 fixes many of those builds, though of course we can't
|
# Our ld64 fixes many of those builds, though of course we can't
|
||||||
# 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
|
||||||
@ -65,19 +64,18 @@ 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}"
|
||||||
remove "LDFLAGS", "-isysroot #{sdk}"
|
remove "LDFLAGS", "-isysroot #{sdk}"
|
||||||
if HOMEBREW_PREFIX.to_s == "/usr/local"
|
if HOMEBREW_PREFIX.to_s == "/usr/local"
|
||||||
delete("CMAKE_PREFIX_PATH")
|
delete("CMAKE_PREFIX_PATH")
|
||||||
else
|
else
|
||||||
# It was set in setup_build_environment, so we have to restore it here.
|
# It was set in setup_build_environment, so we have to restore it here.
|
||||||
self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
|
self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
|
||||||
end
|
|
||||||
remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
|
||||||
end
|
end
|
||||||
|
remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
|
||||||
end
|
end
|
||||||
|
|
||||||
def macosxsdk(version = MacOS.version)
|
def macosxsdk(version = MacOS.version)
|
||||||
@ -89,20 +87,19 @@ 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:
|
||||||
append_path "CPATH", "#{sdk}/usr/include"
|
append_path "CPATH", "#{sdk}/usr/include"
|
||||||
# The -isysroot is needed, too, because of the Frameworks
|
# The -isysroot is needed, too, because of the Frameworks
|
||||||
append_to_cflags "-isysroot #{sdk}"
|
append_to_cflags "-isysroot #{sdk}"
|
||||||
append "CPPFLAGS", "-isysroot #{sdk}"
|
append "CPPFLAGS", "-isysroot #{sdk}"
|
||||||
# And the linker needs to find sdk/usr/lib
|
# And the linker needs to find sdk/usr/lib
|
||||||
append "LDFLAGS", "-isysroot #{sdk}"
|
append "LDFLAGS", "-isysroot #{sdk}"
|
||||||
# Needed to build cmake itself and perhaps some cmake projects:
|
# Needed to build cmake itself and perhaps some cmake projects:
|
||||||
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
|
||||||
|
@ -64,13 +64,12 @@ 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
|
||||||
|
@ -31,10 +31,9 @@ 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,
|
||||||
|
@ -59,9 +59,8 @@ 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.
|
||||||
|
@ -224,10 +224,9 @@ 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)
|
||||||
@ -246,9 +245,8 @@ 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,10 +1063,9 @@ 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
|
||||||
@ -1094,10 +1091,11 @@ 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
|
||||||
@oldname_lock = FormulaLock.new(oldname)
|
return unless (oldname_rack = HOMEBREW_CELLAR/oldname).exist?
|
||||||
@oldname_lock.lock
|
return unless oldname_rack.resolved_path == rack
|
||||||
end
|
@oldname_lock = FormulaLock.new(oldname)
|
||||||
|
@oldname_lock.lock
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
@ -1427,10 +1425,9 @@ 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
|
||||||
|
@ -133,12 +133,10 @@ 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
|
||||||
@ -148,23 +146,24 @@ 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
|
|
||||||
unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
|
|
||||||
dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
|
|
||||||
end
|
|
||||||
raise CannotInstallFormulaError,
|
|
||||||
"You must `brew link #{unlinked_deps*" "}` before #{formula.full_name} can be installed" unless unlinked_deps.empty?
|
|
||||||
|
|
||||||
pinned_unsatisfied_deps = recursive_deps.select do |dep|
|
recursive_deps = formula.recursive_dependencies
|
||||||
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
|
unlinked_deps = recursive_deps.map(&:to_formula).select do |dep|
|
||||||
end
|
dep.installed? && !dep.keg_only? && !dep.linked_keg.directory?
|
||||||
|
|
||||||
unless pinned_unsatisfied_deps.empty?
|
|
||||||
raise CannotInstallFormulaError,
|
|
||||||
"You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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|
|
||||||
|
dep.to_formula.pinned? && !dep.satisfied?(inherited_options_for(dep))
|
||||||
|
end
|
||||||
|
|
||||||
|
return if pinned_unsatisfied_deps.empty?
|
||||||
|
raise CannotInstallFormulaError,
|
||||||
|
"You must `brew unpin #{pinned_unsatisfied_deps*" "}` as installing #{formula.full_name} requires the latest version of pinned dependencies"
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_bottle_preinstall
|
def build_bottle_preinstall
|
||||||
@ -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,10 +490,9 @@ 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
|
||||||
@ -706,13 +703,12 @@ 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
|
||||||
@ -804,10 +800,9 @@ 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
|
||||||
@ -823,22 +818,20 @@ 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?
|
||||||
@@locked.unshift(formula)
|
@@locked.unshift(formula)
|
||||||
@@locked.uniq!
|
@@locked.uniq!
|
||||||
@@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,16 +10,14 @@ 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
|
||||||
|
@ -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,10 +394,9 @@ 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!
|
||||||
@ -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?
|
||||||
return
|
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar"
|
||||||
end
|
end
|
||||||
|
return
|
||||||
dst.unlink unless mode.dry_run
|
|
||||||
keg.link_dir(src, mode) { :mkpath }
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dst.unlink unless mode.dry_run
|
||||||
|
keg.link_dir(src, mode) { :mkpath }
|
||||||
|
true
|
||||||
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,22 +182,21 @@ 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.
|
||||||
# To repin formula we need to update the link thus that it points to
|
# To repin formula we need to update the link thus that it points to
|
||||||
# the right directory.
|
# the right directory.
|
||||||
# NOTE: old_pin_record.realpath.sub(oldname, newname) is unacceptable
|
# NOTE: old_pin_record.realpath.sub(oldname, newname) is unacceptable
|
||||||
# here, because it resolves every symlink for old_pin_record and then
|
# here, because it resolves every symlink for old_pin_record and then
|
||||||
# substitutes oldname with newname. It breaks things like
|
# substitutes oldname with newname. It breaks things like
|
||||||
# Pathname#make_relative_symlink, where Pathname#relative_path_from
|
# Pathname#make_relative_symlink, where Pathname#relative_path_from
|
||||||
# is used to find relative path from source to destination parent and
|
# is used to find relative path from source to destination parent and
|
||||||
# it assumes no symlinks.
|
# it assumes no symlinks.
|
||||||
src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path
|
src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path
|
||||||
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
|
||||||
@ -254,10 +253,9 @@ 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
|
||||||
@ -316,23 +314,22 @@ 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
|
||||||
if old_linked_keg_record
|
if old_linked_keg_record
|
||||||
begin
|
begin
|
||||||
old_linked_keg.link
|
old_linked_keg.link
|
||||||
rescue Keg::LinkError
|
rescue Keg::LinkError
|
||||||
old_linked_keg.unlink
|
old_linked_keg.unlink
|
||||||
raise
|
raise
|
||||||
rescue Keg::AlreadyLinkedError
|
rescue Keg::AlreadyLinkedError
|
||||||
old_linked_keg.unlink
|
old_linked_keg.unlink
|
||||||
retry
|
retry
|
||||||
end
|
|
||||||
else
|
|
||||||
old_linked_keg.optlink
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
old_linked_keg.optlink
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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,12 +83,11 @@ 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)
|
|
||||||
ENV.append_path("PATH", parent)
|
return if ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
|
||||||
end
|
ENV.append_path("PATH", parent)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def env
|
def env
|
||||||
@ -199,11 +198,8 @@ 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
|
reqs << req
|
||||||
else
|
|
||||||
reqs << req
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -130,9 +130,8 @@ 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
|
||||||
@ -236,15 +235,16 @@ 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]
|
||||||
puts <<-EOS.undent
|
return unless private?
|
||||||
It looks like you tapped a private repository. To avoid entering your
|
return if quiet
|
||||||
credentials each time you update, you can use git HTTP credential
|
puts <<-EOS.undent
|
||||||
caching or issue the following command:
|
It looks like you tapped a private repository. To avoid entering your
|
||||||
cd #{path}
|
credentials each time you update, you can use git HTTP credential
|
||||||
git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
|
caching or issue the following command:
|
||||||
EOS
|
cd #{path}
|
||||||
end
|
git remote set-url origin git@github.com:#{user}/homebrew-#{repo}.git
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_manpages
|
def link_manpages
|
||||||
|
@ -45,9 +45,8 @@ 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
|
||||||
|
@ -39,9 +39,8 @@ 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
|
||||||
|
@ -57,9 +57,8 @@ 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
|
||||||
|
|
||||||
|
@ -218,13 +218,9 @@ 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 $?.inspect
|
||||||
raise "Aborted due to non-zero exit status (#{$?.exitstatus})"
|
|
||||||
else
|
|
||||||
raise $?.inspect
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
@ -325,13 +321,12 @@ 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
|
||||||
$times.sort_by { |_k, v| v }.each do |method, time|
|
$times.sort_by { |_k, v| v }.each do |method, time|
|
||||||
puts format("%-*s %0.4f sec", col_width, "#{method}:", time)
|
puts format("%-*s %0.4f sec", col_width, "#{method}:", time)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -608,14 +603,14 @@ 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?
|
|
||||||
onoe <<-EOS.undent
|
|
||||||
Could not link:
|
|
||||||
#{conflicts.join("\n")}
|
|
||||||
|
|
||||||
Please delete these paths and run `#{command}`.
|
return if conflicts.empty?
|
||||||
EOS
|
onoe <<-EOS.undent
|
||||||
end
|
Could not link:
|
||||||
|
#{conflicts.join("\n")}
|
||||||
|
|
||||||
|
Please delete these paths and run `#{command}`.
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_path_manpages(path, command)
|
def link_path_manpages(path, 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