mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
install: fix HEAD
installations with HOMEBREW_INSTALL_FROM_API
This commit is contained in:
parent
12d5e70b87
commit
50fac1737a
@ -98,7 +98,8 @@ module Homebrew
|
|||||||
if verbose?
|
if verbose?
|
||||||
outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?)
|
outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?)
|
||||||
|
|
||||||
current_version = if ENV["HOMEBREW_INSTALL_FROM_API"].present? && (f.core_formula? || f.tap.blank?)
|
current_version = if !f.head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? &&
|
||||||
|
(f.core_formula? || f.tap.blank?)
|
||||||
Homebrew::API::Versions.latest_formula_version(f.name)&.to_s || f.pkg_version.to_s
|
Homebrew::API::Versions.latest_formula_version(f.name)&.to_s || f.pkg_version.to_s
|
||||||
elsif f.alias_changed? && !f.latest_formula.latest_version_installed?
|
elsif f.alias_changed? && !f.latest_formula.latest_version_installed?
|
||||||
latest = f.latest_formula
|
latest = f.latest_formula
|
||||||
|
@ -160,6 +160,7 @@ module Homebrew
|
|||||||
|
|
||||||
if ENV["HOMEBREW_INSTALL_FROM_API"].present?
|
if ENV["HOMEBREW_INSTALL_FROM_API"].present?
|
||||||
formulae_to_install.map! do |formula|
|
formulae_to_install.map! do |formula|
|
||||||
|
next formula if formula.head?
|
||||||
next formula if formula.tap.present? && !formula.core_formula?
|
next formula if formula.tap.present? && !formula.core_formula?
|
||||||
next formula unless Homebrew::API::Bottle.available?(formula.name)
|
next formula unless Homebrew::API::Bottle.available?(formula.name)
|
||||||
|
|
||||||
|
@ -77,6 +77,10 @@ class Formula
|
|||||||
# e.g. `this-formula`
|
# e.g. `this-formula`
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
|
|
||||||
|
# The path to the alias that was used to identify this {Formula}.
|
||||||
|
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
|
||||||
|
attr_reader :bottle_path
|
||||||
|
|
||||||
# The path to the alias that was used to identify this {Formula}.
|
# The path to the alias that was used to identify this {Formula}.
|
||||||
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
|
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
|
||||||
attr_reader :alias_path
|
attr_reader :alias_path
|
||||||
@ -308,9 +312,20 @@ class Formula
|
|||||||
full_name_with_optional_tap(installed_alias_name)
|
full_name_with_optional_tap(installed_alias_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefix_formula_file
|
||||||
|
return unless prefix.directory?
|
||||||
|
|
||||||
|
prefix/".brew/#{name}.rb"
|
||||||
|
end
|
||||||
|
|
||||||
# The path that was specified to find this formula.
|
# The path that was specified to find this formula.
|
||||||
def specified_path
|
def specified_path
|
||||||
alias_path || path
|
default_specified_path = alias_path || path
|
||||||
|
|
||||||
|
return default_specified_path if default_specified_path.present? && default_specified_path.exist?
|
||||||
|
return local_bottle_path if local_bottle_path.present? && local_bottle_path.exist?
|
||||||
|
|
||||||
|
default_specified_path
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name specified to find this formula.
|
# The name specified to find this formula.
|
||||||
@ -523,7 +538,7 @@ class Formula
|
|||||||
# exists and is not empty.
|
# exists and is not empty.
|
||||||
# @private
|
# @private
|
||||||
def latest_version_installed?
|
def latest_version_installed?
|
||||||
latest_prefix = if ENV["HOMEBREW_INSTALL_FROM_API"].present? &&
|
latest_prefix = if !head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? &&
|
||||||
(latest_pkg_version = Homebrew::API::Versions.latest_formula_version(name))
|
(latest_pkg_version = Homebrew::API::Versions.latest_formula_version(name))
|
||||||
prefix latest_pkg_version
|
prefix latest_pkg_version
|
||||||
else
|
else
|
||||||
@ -1343,7 +1358,7 @@ class Formula
|
|||||||
Formula.cache[:outdated_kegs][cache_key] ||= begin
|
Formula.cache[:outdated_kegs][cache_key] ||= begin
|
||||||
all_kegs = []
|
all_kegs = []
|
||||||
current_version = T.let(false, T::Boolean)
|
current_version = T.let(false, T::Boolean)
|
||||||
latest_version = if ENV["HOMEBREW_INSTALL_FROM_API"].present? && (core_formula? || tap.blank?)
|
latest_version = if !head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? && (core_formula? || tap.blank?)
|
||||||
Homebrew::API::Versions.latest_formula_version(name) || pkg_version
|
Homebrew::API::Versions.latest_formula_version(name) || pkg_version
|
||||||
else
|
else
|
||||||
pkg_version
|
pkg_version
|
||||||
|
@ -287,7 +287,7 @@ module FormulaCellarChecks
|
|||||||
def check_cpuid_instruction(formula)
|
def check_cpuid_instruction(formula)
|
||||||
return unless formula.prefix.directory?
|
return unless formula.prefix.directory?
|
||||||
# TODO: add methods to `utils/ast` to allow checking for method use
|
# TODO: add methods to `utils/ast` to allow checking for method use
|
||||||
return unless formula.path.read.include? "ENV.runtime_cpu_detection"
|
return unless formula.prefix_formula_file.read.include? "ENV.runtime_cpu_detection"
|
||||||
# Checking for `cpuid` only makes sense on Intel:
|
# Checking for `cpuid` only makes sense on Intel:
|
||||||
# https://en.wikipedia.org/wiki/CPUID
|
# https://en.wikipedia.org/wiki/CPUID
|
||||||
return unless Hardware::CPU.intel?
|
return unless Hardware::CPU.intel?
|
||||||
|
@ -41,7 +41,7 @@ class Tab < OpenStruct
|
|||||||
"source" => {
|
"source" => {
|
||||||
"path" => formula.specified_path.to_s,
|
"path" => formula.specified_path.to_s,
|
||||||
"tap" => formula.tap&.name,
|
"tap" => formula.tap&.name,
|
||||||
"tap_git_head" => formula.tap&.git_head,
|
"tap_git_head" => nil, # Filled in later if possible
|
||||||
"spec" => formula.active_spec_sym.to_s,
|
"spec" => formula.active_spec_sym.to_s,
|
||||||
"versions" => {
|
"versions" => {
|
||||||
"stable" => formula.stable&.version.to_s,
|
"stable" => formula.stable&.version.to_s,
|
||||||
@ -52,6 +52,9 @@ class Tab < OpenStruct
|
|||||||
"built_on" => DevelopmentTools.build_system_info,
|
"built_on" => DevelopmentTools.build_system_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# We can only get `tap_git_head` if the tap is installed locally
|
||||||
|
attributes["source"]["tap_git_head"] = formula.tap.git_head if formula.tap&.installed?
|
||||||
|
|
||||||
new(attributes)
|
new(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user