formula: rename installed_prefix to latest_installed_prefix
This commit is contained in:
parent
2b4f3646b7
commit
5acdcd26d0
@ -163,7 +163,7 @@ module Homebrew
|
|||||||
Formulary.from_rack(rack)
|
Formulary.from_rack(rack)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless (prefix = f.installed_prefix).directory?
|
unless (prefix = f.latest_installed_prefix).directory?
|
||||||
raise MultipleVersionsInstalledError, "#{rack.basename} has multiple installed versions"
|
raise MultipleVersionsInstalledError, "#{rack.basename} has multiple installed versions"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ module Homebrew
|
|||||||
puts HOMEBREW_PREFIX
|
puts HOMEBREW_PREFIX
|
||||||
else
|
else
|
||||||
puts args.named.to_resolved_formulae.map { |f|
|
puts args.named.to_resolved_formulae.map { |f|
|
||||||
f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix
|
f.opt_prefix.exist? ? f.opt_prefix : f.latest_installed_prefix
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -488,11 +488,11 @@ class Formula
|
|||||||
delegate compiler_failures: :active_spec
|
delegate compiler_failures: :active_spec
|
||||||
|
|
||||||
# If this {Formula} is installed.
|
# If this {Formula} is installed.
|
||||||
# This is actually just a check for if the {#installed_prefix} directory
|
# This is actually just a check for if the {#latest_installed_prefix} directory
|
||||||
# exists and is not empty.
|
# exists and is not empty.
|
||||||
# @private
|
# @private
|
||||||
def latest_version_installed?
|
def latest_version_installed?
|
||||||
(dir = installed_prefix).directory? && !dir.children.empty?
|
(dir = latest_installed_prefix).directory? && !dir.children.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# If at least one version of {Formula} is installed.
|
# If at least one version of {Formula} is installed.
|
||||||
@ -547,7 +547,7 @@ class Formula
|
|||||||
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
# The latest prefix for this formula. Checks for {#head}, then {#devel}
|
||||||
# and then {#stable}'s {#prefix}
|
# and then {#stable}'s {#prefix}
|
||||||
# @private
|
# @private
|
||||||
def installed_prefix
|
def latest_installed_prefix
|
||||||
if head && (head_version = latest_head_version) && !head_version_outdated?(head_version)
|
if head && (head_version = latest_head_version) && !head_version_outdated?(head_version)
|
||||||
latest_head_prefix
|
latest_head_prefix
|
||||||
elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory?
|
elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory?
|
||||||
@ -563,7 +563,7 @@ class Formula
|
|||||||
# if the formula is not installed.
|
# if the formula is not installed.
|
||||||
# @private
|
# @private
|
||||||
def installed_version
|
def installed_version
|
||||||
Keg.new(installed_prefix).version
|
Keg.new(latest_installed_prefix).version
|
||||||
end
|
end
|
||||||
|
|
||||||
# The directory in the cellar that the formula is installed to.
|
# The directory in the cellar that the formula is installed to.
|
||||||
|
|||||||
@ -145,7 +145,7 @@ class Tab < OpenStruct
|
|||||||
paths << dirs.first
|
paths << dirs.first
|
||||||
end
|
end
|
||||||
|
|
||||||
paths << f.installed_prefix
|
paths << f.latest_installed_prefix
|
||||||
|
|
||||||
path = paths.map { |pn| pn/FILENAME }.find(&:file?)
|
path = paths.map { |pn| pn/FILENAME }.find(&:file?)
|
||||||
|
|
||||||
|
|||||||
@ -28,17 +28,17 @@ describe Homebrew do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:kegs_by_rack) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } }
|
let(:kegs_by_rack) { { dependency.rack => [Keg.new(dependency.latest_installed_prefix)] } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
[dependency, dependent].each do |f|
|
[dependency, dependent].each do |f|
|
||||||
f.installed_prefix.mkpath
|
f.latest_installed_prefix.mkpath
|
||||||
Keg.new(f.installed_prefix).optlink
|
Keg.new(f.latest_installed_prefix).optlink
|
||||||
end
|
end
|
||||||
|
|
||||||
tab = Tab.empty
|
tab = Tab.empty
|
||||||
tab.homebrew_version = "1.1.6"
|
tab.homebrew_version = "1.1.6"
|
||||||
tab.tabfile = dependent.installed_prefix/Tab::FILENAME
|
tab.tabfile = dependent.latest_installed_prefix/Tab::FILENAME
|
||||||
tab.runtime_dependencies = [
|
tab.runtime_dependencies = [
|
||||||
{ "full_name" => "dependency", "version" => "1" },
|
{ "full_name" => "dependency", "version" => "1" },
|
||||||
]
|
]
|
||||||
|
|||||||
@ -282,23 +282,23 @@ describe Formula do
|
|||||||
describe "#latest_version_installed?" do
|
describe "#latest_version_installed?" do
|
||||||
let(:f) { Testball.new }
|
let(:f) { Testball.new }
|
||||||
|
|
||||||
it "returns false if the #installed_prefix is not a directory" do
|
it "returns false if the #latest_installed_prefix is not a directory" do
|
||||||
allow(f).to receive(:installed_prefix).and_return(double(directory?: false))
|
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: false))
|
||||||
expect(f).not_to be_latest_version_installed
|
expect(f).not_to be_latest_version_installed
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if the #installed_prefix does not have children" do
|
it "returns false if the #latest_installed_prefix does not have children" do
|
||||||
allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: []))
|
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: true, children: []))
|
||||||
expect(f).not_to be_latest_version_installed
|
expect(f).not_to be_latest_version_installed
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true if the #installed_prefix has children" do
|
it "returns true if the #latest_installed_prefix has children" do
|
||||||
allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: [double]))
|
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: true, children: [double]))
|
||||||
expect(f).to be_latest_version_installed
|
expect(f).to be_latest_version_installed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#installed prefix" do
|
describe "#latest_installed_prefix" do
|
||||||
let(:f) do
|
let(:f) do
|
||||||
formula do
|
formula do
|
||||||
url "foo"
|
url "foo"
|
||||||
@ -311,17 +311,17 @@ describe Formula do
|
|||||||
let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version }
|
let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version }
|
||||||
|
|
||||||
it "is the same as #prefix by default" do
|
it "is the same as #prefix by default" do
|
||||||
expect(f.installed_prefix).to eq(f.prefix)
|
expect(f.latest_installed_prefix).to eq(f.prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the stable prefix if it is installed" do
|
it "returns the stable prefix if it is installed" do
|
||||||
stable_prefix.mkpath
|
stable_prefix.mkpath
|
||||||
expect(f.installed_prefix).to eq(stable_prefix)
|
expect(f.latest_installed_prefix).to eq(stable_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the head prefix if it is installed" do
|
it "returns the head prefix if it is installed" do
|
||||||
head_prefix.mkpath
|
head_prefix.mkpath
|
||||||
expect(f.installed_prefix).to eq(head_prefix)
|
expect(f.latest_installed_prefix).to eq(head_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the stable prefix if head is outdated" do
|
it "returns the stable prefix if head is outdated" do
|
||||||
@ -332,12 +332,12 @@ describe Formula do
|
|||||||
tab.source["versions"] = { "stable" => "1.0" }
|
tab.source["versions"] = { "stable" => "1.0" }
|
||||||
tab.write
|
tab.write
|
||||||
|
|
||||||
expect(f.installed_prefix).to eq(stable_prefix)
|
expect(f.latest_installed_prefix).to eq(stable_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the head prefix if the active specification is :head" do
|
it "returns the head prefix if the active specification is :head" do
|
||||||
f.active_spec = :head
|
f.active_spec = :head
|
||||||
expect(f.installed_prefix).to eq(head_prefix)
|
expect(f.latest_installed_prefix).to eq(head_prefix)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -728,7 +728,7 @@ describe Formula do
|
|||||||
dependency = formula("dependency") { url "f-1.0" }
|
dependency = formula("dependency") { url "f-1.0" }
|
||||||
|
|
||||||
formula.brew { formula.install }
|
formula.brew { formula.install }
|
||||||
keg = Keg.for(formula.installed_prefix)
|
keg = Keg.for(formula.latest_installed_prefix)
|
||||||
keg.link
|
keg.link
|
||||||
|
|
||||||
linkage_checker = double("linkage checker", undeclared_deps: [dependency.name])
|
linkage_checker = double("linkage checker", undeclared_deps: [dependency.name])
|
||||||
@ -745,7 +745,7 @@ describe Formula do
|
|||||||
tab.runtime_dependencies = ["foo"]
|
tab.runtime_dependencies = ["foo"]
|
||||||
tab.write
|
tab.write
|
||||||
|
|
||||||
keg = Keg.for(formula.installed_prefix)
|
keg = Keg.for(formula.latest_installed_prefix)
|
||||||
keg.link
|
keg.link
|
||||||
|
|
||||||
expect(formula.runtime_dependencies.map(&:name)).to be_empty
|
expect(formula.runtime_dependencies.map(&:name)).to be_empty
|
||||||
@ -865,7 +865,7 @@ describe Formula do
|
|||||||
head("foo")
|
head("foo")
|
||||||
end
|
end
|
||||||
|
|
||||||
stable_prefix = f.installed_prefix
|
stable_prefix = f.latest_installed_prefix
|
||||||
stable_prefix.mkpath
|
stable_prefix.mkpath
|
||||||
|
|
||||||
[["000000_1", 1], ["111111", 2], ["111111_1", 2]].each do |pkg_version_suffix, stamp|
|
[["000000_1", 1], ["111111", 2], ["111111_1", 2]].each do |pkg_version_suffix, stamp|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ module Utils
|
|||||||
def built_as?(f)
|
def built_as?(f)
|
||||||
return false unless f.latest_version_installed?
|
return false unless f.latest_version_installed?
|
||||||
|
|
||||||
tab = Tab.for_keg(f.installed_prefix)
|
tab = Tab.for_keg(f.latest_installed_prefix)
|
||||||
tab.built_as_bottle
|
tab.built_as_bottle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user