Replace install_name/install_ref with alias_path
This commit is contained in:
parent
c17664b124
commit
65ee5408c3
@ -61,7 +61,7 @@ class Formula
|
|||||||
# The name specified when installing this {Formula}.
|
# The name specified when installing this {Formula}.
|
||||||
# Could be the name of the {Formula}, or an alias.
|
# Could be the name of the {Formula}, or an alias.
|
||||||
# e.g. `another-name-for-this-formula`
|
# e.g. `another-name-for-this-formula`
|
||||||
attr_reader :install_name
|
attr_reader :alias_path
|
||||||
|
|
||||||
# The fully-qualified name of this {Formula}.
|
# The fully-qualified name of this {Formula}.
|
||||||
# For core formula it's the same as {#name}.
|
# For core formula it's the same as {#name}.
|
||||||
@ -148,10 +148,10 @@ class Formula
|
|||||||
attr_accessor :build
|
attr_accessor :build
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
def initialize(name, path, spec, install_name: name)
|
def initialize(name, path, spec, alias_path: nil)
|
||||||
@name = name
|
@name = name
|
||||||
@path = path
|
@path = path
|
||||||
@install_name = install_name
|
@alias_path = alias_path
|
||||||
@revision = self.class.revision || 0
|
@revision = self.class.revision || 0
|
||||||
@version_scheme = self.class.version_scheme || 0
|
@version_scheme = self.class.version_scheme || 0
|
||||||
|
|
||||||
@ -508,21 +508,6 @@ class Formula
|
|||||||
installed_prefixes.map { |dir| Keg.new(dir) }
|
installed_prefixes.map { |dir| Keg.new(dir) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Formula reference to use to get an identical installation of the formula.
|
|
||||||
#
|
|
||||||
# Usually, the formula's path is a good canonical identifier for the formula.
|
|
||||||
# Just using whatever was passed to `brew install` isn't a good idea, because
|
|
||||||
# if it was e.g. a URL, it could end up being downloaded twice.
|
|
||||||
#
|
|
||||||
# However, if the formula was installed with an alias (i.e. `install_name` is
|
|
||||||
# different from `name`), that should be used instead so that information is
|
|
||||||
# preserved. Aliases are looked up in repositories that have already been
|
|
||||||
# tapped, so we don't have to worry about doing extra HTTP requests, or other
|
|
||||||
# expensive operations, when looking them up again.
|
|
||||||
def install_ref
|
|
||||||
install_name == name ? path : install_name
|
|
||||||
end
|
|
||||||
|
|
||||||
# The directory where the formula's binaries should be installed.
|
# The directory where the formula's binaries should be installed.
|
||||||
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
|
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
|
||||||
# `brew link` for formulae that are not keg-only.
|
# `brew link` for formulae that are not keg-only.
|
||||||
|
|||||||
@ -589,7 +589,7 @@ class FormulaInstaller
|
|||||||
-I #{HOMEBREW_LOAD_PATH}
|
-I #{HOMEBREW_LOAD_PATH}
|
||||||
--
|
--
|
||||||
#{HOMEBREW_LIBRARY_PATH}/build.rb
|
#{HOMEBREW_LIBRARY_PATH}/build.rb
|
||||||
#{formula.install_ref}
|
#{formula.alias_path || formula.path}
|
||||||
].concat(build_argv)
|
].concat(build_argv)
|
||||||
|
|
||||||
Sandbox.print_sandbox_message if Sandbox.formula?(formula)
|
Sandbox.print_sandbox_message if Sandbox.formula?(formula)
|
||||||
|
|||||||
@ -69,17 +69,16 @@ class Formulary
|
|||||||
# The formula's ruby file's path or filename
|
# The formula's ruby file's path or filename
|
||||||
attr_reader :path
|
attr_reader :path
|
||||||
# The name used to install the formula
|
# The name used to install the formula
|
||||||
attr_reader :install_name
|
attr_reader :alias_path
|
||||||
|
|
||||||
def initialize(name, path)
|
def initialize(name, path)
|
||||||
@name = name
|
@name = name
|
||||||
@path = path.resolved_path
|
@path = path.resolved_path
|
||||||
@install_name = name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gets the formula instance.
|
# Gets the formula instance.
|
||||||
def get_formula(spec)
|
def get_formula(spec)
|
||||||
klass.new(name, path, spec, :install_name => install_name)
|
klass.new(name, path, spec, :alias_path => alias_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def klass
|
def klass
|
||||||
@ -121,7 +120,7 @@ class Formulary
|
|||||||
path = alias_path.resolved_path
|
path = alias_path.resolved_path
|
||||||
name = path.basename(".rb").to_s
|
name = path.basename(".rb").to_s
|
||||||
super name, path
|
super name, path
|
||||||
@install_name = alias_path.basename.to_s
|
@alias_path = alias_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class Tab < OpenStruct
|
|||||||
"time" => Time.now.to_i,
|
"time" => Time.now.to_i,
|
||||||
"source_modified_time" => formula.source_modified_time.to_i,
|
"source_modified_time" => formula.source_modified_time.to_i,
|
||||||
"HEAD" => HOMEBREW_REPOSITORY.git_head,
|
"HEAD" => HOMEBREW_REPOSITORY.git_head,
|
||||||
"install_name" => formula.install_name,
|
"alias_path" => formula.alias_path.to_s,
|
||||||
"compiler" => compiler,
|
"compiler" => compiler,
|
||||||
"stdlib" => stdlib,
|
"stdlib" => stdlib,
|
||||||
"source" => {
|
"source" => {
|
||||||
@ -162,7 +162,7 @@ class Tab < OpenStruct
|
|||||||
"time" => nil,
|
"time" => nil,
|
||||||
"source_modified_time" => 0,
|
"source_modified_time" => 0,
|
||||||
"HEAD" => nil,
|
"HEAD" => nil,
|
||||||
"install_name" => nil,
|
"alias_path" => nil,
|
||||||
"stdlib" => nil,
|
"stdlib" => nil,
|
||||||
"compiler" => DevelopmentTools.default_compiler,
|
"compiler" => DevelopmentTools.default_compiler,
|
||||||
"source" => {
|
"source" => {
|
||||||
@ -294,7 +294,7 @@ class Tab < OpenStruct
|
|||||||
"time" => time,
|
"time" => time,
|
||||||
"source_modified_time" => source_modified_time.to_i,
|
"source_modified_time" => source_modified_time.to_i,
|
||||||
"HEAD" => self.HEAD,
|
"HEAD" => self.HEAD,
|
||||||
"install_name" => install_name,
|
"alias_path" => alias_path,
|
||||||
"stdlib" => (stdlib.to_s if stdlib),
|
"stdlib" => (stdlib.to_s if stdlib),
|
||||||
"compiler" => (compiler.to_s if compiler),
|
"compiler" => (compiler.to_s if compiler),
|
||||||
"source" => source
|
"source" => source
|
||||||
|
|||||||
2
Library/Homebrew/test/fixtures/receipt.json
vendored
2
Library/Homebrew/test/fixtures/receipt.json
vendored
@ -11,7 +11,7 @@
|
|||||||
"poured_from_bottle": true,
|
"poured_from_bottle": true,
|
||||||
"time": 1403827774,
|
"time": 1403827774,
|
||||||
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
|
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
|
||||||
"install_name": "test-formula",
|
"alias_path": "test-formula",
|
||||||
"stdlib": "libcxx",
|
"stdlib": "libcxx",
|
||||||
"compiler": "clang",
|
"compiler": "clang",
|
||||||
"source": {
|
"source": {
|
||||||
|
|||||||
@ -8,30 +8,15 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
name = "formula_name"
|
name = "formula_name"
|
||||||
path = Formulary.core_path(name)
|
path = Formulary.core_path(name)
|
||||||
spec = :stable
|
spec = :stable
|
||||||
install_name = "formula_alias"
|
alias_path = "formula_alias"
|
||||||
|
|
||||||
f = klass.new(name, path, spec, :install_name => install_name)
|
f = klass.new(name, path, spec, :alias_path => alias_path)
|
||||||
assert_equal name, f.name
|
assert_equal name, f.name
|
||||||
assert_equal path, f.path
|
assert_equal path, f.path
|
||||||
assert_equal install_name, f.install_name
|
assert_equal alias_path, f.alias_path
|
||||||
assert_raises(ArgumentError) { klass.new }
|
assert_raises(ArgumentError) { klass.new }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_ref_with_alias
|
|
||||||
name = "formula_name"
|
|
||||||
path = Formulary.core_path(name)
|
|
||||||
spec = :stable
|
|
||||||
install_name = "formula_alias"
|
|
||||||
|
|
||||||
f = Testball.new(name, path, spec, :install_name => install_name)
|
|
||||||
assert_equal f.install_name, f.install_ref
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_install_ref_with_non_alias
|
|
||||||
f = Testball.new
|
|
||||||
assert_equal f.path, f.install_ref
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_prefix
|
def test_prefix
|
||||||
f = Testball.new
|
f = Testball.new
|
||||||
assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix
|
assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix
|
||||||
|
|||||||
@ -85,10 +85,11 @@ class FormularyFactoryTest < Homebrew::TestCase
|
|||||||
def test_factory_from_alias
|
def test_factory_from_alias
|
||||||
alias_dir = CoreTap.instance.alias_dir
|
alias_dir = CoreTap.instance.alias_dir
|
||||||
alias_dir.mkpath
|
alias_dir.mkpath
|
||||||
FileUtils.ln_s @path, alias_dir/"foo"
|
alias_path = alias_dir/"foo"
|
||||||
|
FileUtils.ln_s @path, alias_path
|
||||||
result = Formulary.factory("foo")
|
result = Formulary.factory("foo")
|
||||||
assert_kind_of Formula, result
|
assert_kind_of Formula, result
|
||||||
assert_equal "foo", result.install_name
|
assert_equal alias_path, result.alias_path
|
||||||
ensure
|
ensure
|
||||||
alias_dir.rmtree
|
alias_dir.rmtree
|
||||||
end
|
end
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class TabTests < Homebrew::TestCase
|
|||||||
assert_nil tab.stable_version
|
assert_nil tab.stable_version
|
||||||
assert_nil tab.devel_version
|
assert_nil tab.devel_version
|
||||||
assert_nil tab.head_version
|
assert_nil tab.head_version
|
||||||
assert_nil tab.install_name
|
assert_nil tab.alias_path
|
||||||
assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler
|
assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler
|
||||||
assert_nil tab.cxxstdlib.type
|
assert_nil tab.cxxstdlib.type
|
||||||
end
|
end
|
||||||
@ -117,7 +117,7 @@ class TabTests < Homebrew::TestCase
|
|||||||
assert_equal "2.14", tab.stable_version.to_s
|
assert_equal "2.14", tab.stable_version.to_s
|
||||||
assert_equal "2.15", tab.devel_version.to_s
|
assert_equal "2.15", tab.devel_version.to_s
|
||||||
assert_equal "HEAD-0000000", tab.head_version.to_s
|
assert_equal "HEAD-0000000", tab.head_version.to_s
|
||||||
assert_equal "test-formula", tab.install_name
|
assert_equal "test-formula", tab.alias_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_json
|
def test_to_json
|
||||||
@ -135,7 +135,7 @@ class TabTests < Homebrew::TestCase
|
|||||||
assert_equal @tab.stable_version, tab.stable_version
|
assert_equal @tab.stable_version, tab.stable_version
|
||||||
assert_equal @tab.devel_version, tab.devel_version
|
assert_equal @tab.devel_version, tab.devel_version
|
||||||
assert_equal @tab.head_version, tab.head_version
|
assert_equal @tab.head_version, tab.head_version
|
||||||
assert_equal @tab.install_name, tab.install_name
|
assert_equal @tab.alias_path, tab.alias_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remap_deprecated_options
|
def test_remap_deprecated_options
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, install_name: name)
|
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha256 TESTBALL_SHA256
|
stable.sha256 TESTBALL_SHA256
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
class TestballBottle < Formula
|
class TestballBottle < Formula
|
||||||
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, install_name: name)
|
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, alias_path: nil)
|
||||||
self.class.instance_eval do
|
self.class.instance_eval do
|
||||||
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||||
stable.sha256 TESTBALL_SHA256
|
stable.sha256 TESTBALL_SHA256
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user