Merge pull request #8012 from Bo98/formula-minor-refactor
formula: minor refactor to reduce line count
This commit is contained in:
commit
2ed1de48d5
@ -352,6 +352,8 @@ class Formula
|
|||||||
delegate desc: :"self.class"
|
delegate desc: :"self.class"
|
||||||
|
|
||||||
# The SPDX ID of the software license.
|
# The SPDX ID of the software license.
|
||||||
|
# @method license
|
||||||
|
# @see .license=
|
||||||
delegate license: :"self.class"
|
delegate license: :"self.class"
|
||||||
|
|
||||||
# The homepage for the software.
|
# The homepage for the software.
|
||||||
@ -941,14 +943,10 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def plist_manual
|
delegate plist_manual: :"self.class"
|
||||||
self.class.plist_manual
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def plist_startup
|
delegate plist_startup: :"self.class"
|
||||||
self.class.plist_startup
|
|
||||||
end
|
|
||||||
|
|
||||||
# A stable path for this formula, when installed. Contains the formula name
|
# A stable path for this formula, when installed. Contains the formula name
|
||||||
# but no version number. Only the active version will be linked here if
|
# but no version number. Only the active version will be linked here if
|
||||||
@ -1008,9 +1006,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def pour_bottle_check_unsatisfied_reason
|
delegate pour_bottle_check_unsatisfied_reason: :"self.class"
|
||||||
self.class.pour_bottle_check_unsatisfied_reason
|
|
||||||
end
|
|
||||||
|
|
||||||
# Can be overridden to run commands on both source and bottle installation.
|
# Can be overridden to run commands on both source and bottle installation.
|
||||||
def post_install; end
|
def post_install; end
|
||||||
@ -1080,9 +1076,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def keg_only_reason
|
delegate keg_only_reason: :"self.class"
|
||||||
self.class.keg_only_reason
|
|
||||||
end
|
|
||||||
|
|
||||||
# sometimes the formula cleaner breaks things
|
# sometimes the formula cleaner breaks things
|
||||||
# skip cleaning paths in a formula with a class method like this:
|
# skip cleaning paths in a formula with a class method like this:
|
||||||
@ -1139,17 +1133,15 @@ class Formula
|
|||||||
|
|
||||||
# Whether this {Formula} is deprecated (i.e. warns on installation).
|
# Whether this {Formula} is deprecated (i.e. warns on installation).
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
|
# @method deprecated?
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def deprecated?
|
delegate deprecated?: :"self.class"
|
||||||
self.class.deprecated?
|
|
||||||
end
|
|
||||||
|
|
||||||
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
# Whether this {Formula} is disabled (i.e. cannot be installed).
|
||||||
# Defaults to false.
|
# Defaults to false.
|
||||||
|
# @method disabled?
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def disabled?
|
delegate disabled?: :"self.class"
|
||||||
self.class.disabled?
|
|
||||||
end
|
|
||||||
|
|
||||||
def skip_cxxstdlib_check?
|
def skip_cxxstdlib_check?
|
||||||
false
|
false
|
||||||
@ -1312,29 +1304,19 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def pinnable?
|
delegate pinnable?: :@pin
|
||||||
@pin.pinnable?
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def pinned?
|
delegate pinned?: :@pin
|
||||||
@pin.pinned?
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def pinned_version
|
delegate pinned_version: :@pin
|
||||||
@pin.pinned_version
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def pin
|
delegate pin: :@pin
|
||||||
@pin.pin
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def unpin
|
delegate unpin: :@pin
|
||||||
@pin.unpin
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def ==(other)
|
def ==(other)
|
||||||
@ -1589,14 +1571,10 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def env
|
delegate env: :"self.class"
|
||||||
self.class.env
|
|
||||||
end
|
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def conflicts
|
delegate conflicts: :"self.class"
|
||||||
self.class.conflicts
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a list of Dependency objects in an installable order, which
|
# Returns a list of Dependency objects in an installable order, which
|
||||||
# means if a depends on b then b will be ordered before a in this list
|
# means if a depends on b then b will be ordered before a in this list
|
||||||
@ -1787,10 +1765,9 @@ class Formula
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
installed_kegs.each do |keg|
|
hsh["installed"] = installed_kegs.sort_by(&:version).map do |keg|
|
||||||
tab = Tab.for_keg keg
|
tab = Tab.for_keg keg
|
||||||
|
{
|
||||||
hsh["installed"] << {
|
|
||||||
"version" => keg.version.to_s,
|
"version" => keg.version.to_s,
|
||||||
"used_options" => tab.used_options.as_flags,
|
"used_options" => tab.used_options.as_flags,
|
||||||
"built_as_bottle" => tab.built_as_bottle,
|
"built_as_bottle" => tab.built_as_bottle,
|
||||||
@ -1801,8 +1778,6 @@ class Formula
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
hsh["installed"] = hsh["installed"].sort_by { |i| Version.create(i["version"]) }
|
|
||||||
|
|
||||||
hsh
|
hsh
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1821,17 +1796,13 @@ class Formula
|
|||||||
@prefix_returns_versioned_prefix = true
|
@prefix_returns_versioned_prefix = true
|
||||||
|
|
||||||
test_env = {
|
test_env = {
|
||||||
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
|
|
||||||
TMPDIR: HOMEBREW_TEMP,
|
TMPDIR: HOMEBREW_TEMP,
|
||||||
TEMP: HOMEBREW_TEMP,
|
TEMP: HOMEBREW_TEMP,
|
||||||
TMP: HOMEBREW_TEMP,
|
TMP: HOMEBREW_TEMP,
|
||||||
TERM: "dumb",
|
TERM: "dumb",
|
||||||
PATH: PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"),
|
PATH: PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"),
|
||||||
HOMEBREW_PATH: nil,
|
HOMEBREW_PATH: nil,
|
||||||
_JAVA_OPTIONS: "#{ENV["_JAVA_OPTIONS"]&.+(" ")}-Duser.home=#{HOMEBREW_CACHE}/java_cache",
|
}.merge(common_stage_test_env)
|
||||||
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
|
|
||||||
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
|
|
||||||
}
|
|
||||||
|
|
||||||
ENV.clear_sensitive_environment!
|
ENV.clear_sensitive_environment!
|
||||||
Utils.set_git_name_email!
|
Utils.set_git_name_email!
|
||||||
@ -2152,6 +2123,17 @@ class Formula
|
|||||||
exit! 1 # never gets here unless exec threw or failed
|
exit! 1 # never gets here unless exec threw or failed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Common environment variables used at both build and test time
|
||||||
|
def common_stage_test_env
|
||||||
|
{
|
||||||
|
_JAVA_OPTIONS: "#{ENV["_JAVA_OPTIONS"]&.+(" ")}-Duser.home=#{HOMEBREW_CACHE}/java_cache",
|
||||||
|
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
|
||||||
|
GOPATH: "#{HOMEBREW_CACHE}/go_mod_cache",
|
||||||
|
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
|
||||||
|
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
active_spec.stage do |staging|
|
active_spec.stage do |staging|
|
||||||
@source_modified_time = active_spec.source_modified_time
|
@source_modified_time = active_spec.source_modified_time
|
||||||
@ -2165,12 +2147,7 @@ class Formula
|
|||||||
|
|
||||||
unless Homebrew.args.interactive?
|
unless Homebrew.args.interactive?
|
||||||
stage_env[:HOME] = env_home
|
stage_env[:HOME] = env_home
|
||||||
stage_env[:_JAVA_OPTIONS] =
|
stage_env.merge!(common_stage_test_env)
|
||||||
"#{ENV["_JAVA_OPTIONS"]&.+(" ")}-Duser.home=#{HOMEBREW_CACHE}/java_cache"
|
|
||||||
stage_env[:GOCACHE] = "#{HOMEBREW_CACHE}/go_cache"
|
|
||||||
stage_env[:GOPATH] = "#{HOMEBREW_CACHE}/go_mod_cache"
|
|
||||||
stage_env[:CARGO_HOME] = "#{HOMEBREW_CACHE}/cargo_cache"
|
|
||||||
stage_env[:CURL_HOME] = ENV["CURL_HOME"] || ENV["HOME"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
setup_home env_home
|
setup_home env_home
|
||||||
|
Loading…
x
Reference in New Issue
Block a user