parent
9fd97dd3cf
commit
0ef3e1e0dc
@ -58,6 +58,11 @@ class Formula
|
||||
# e.g. `this-formula`
|
||||
attr_reader :name
|
||||
|
||||
# The name specified when installing this {Formula}.
|
||||
# Could be the name of the {Formula}, or an alias.
|
||||
# e.g. `another-name-for-this-formula`
|
||||
attr_reader :install_name
|
||||
|
||||
# The fully-qualified name of this {Formula}.
|
||||
# For core formula it's the same as {#name}.
|
||||
# e.g. `homebrew/tap-name/this-formula`
|
||||
@ -143,9 +148,10 @@ class Formula
|
||||
attr_accessor :build
|
||||
|
||||
# @private
|
||||
def initialize(name, path, spec)
|
||||
def initialize(name, path, spec, install_name: name)
|
||||
@name = name
|
||||
@path = path
|
||||
@install_name = install_name
|
||||
@revision = self.class.revision || 0
|
||||
@version_scheme = self.class.version_scheme || 0
|
||||
|
||||
@ -502,6 +508,21 @@ class Formula
|
||||
installed_prefixes.map { |dir| Keg.new(dir) }
|
||||
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.
|
||||
# This is symlinked into `HOMEBREW_PREFIX` after installation or with
|
||||
# `brew link` for formulae that are not keg-only.
|
||||
|
@ -589,7 +589,7 @@ class FormulaInstaller
|
||||
-I #{HOMEBREW_LOAD_PATH}
|
||||
--
|
||||
#{HOMEBREW_LIBRARY_PATH}/build.rb
|
||||
#{formula.path}
|
||||
#{formula.install_ref}
|
||||
].concat(build_argv)
|
||||
|
||||
Sandbox.print_sandbox_message if Sandbox.formula?(formula)
|
||||
|
@ -68,15 +68,18 @@ class Formulary
|
||||
attr_reader :name
|
||||
# The formula's ruby file's path or filename
|
||||
attr_reader :path
|
||||
# The name used to install the formula
|
||||
attr_reader :install_name
|
||||
|
||||
def initialize(name, path)
|
||||
@name = name
|
||||
@path = path.resolved_path
|
||||
@install_name = name
|
||||
end
|
||||
|
||||
# Gets the formula instance.
|
||||
def get_formula(spec)
|
||||
klass.new(name, path, spec)
|
||||
klass.new(name, path, spec, install_name: install_name)
|
||||
end
|
||||
|
||||
def klass
|
||||
@ -118,6 +121,7 @@ class Formulary
|
||||
path = alias_path.resolved_path
|
||||
name = path.basename(".rb").to_s
|
||||
super name, path
|
||||
@install_name = alias_path.basename.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,6 +27,7 @@ class Tab < OpenStruct
|
||||
"time" => Time.now.to_i,
|
||||
"source_modified_time" => formula.source_modified_time.to_i,
|
||||
"HEAD" => HOMEBREW_REPOSITORY.git_head,
|
||||
"install_name" => formula.install_name,
|
||||
"compiler" => compiler,
|
||||
"stdlib" => stdlib,
|
||||
"source" => {
|
||||
@ -161,6 +162,7 @@ class Tab < OpenStruct
|
||||
"time" => nil,
|
||||
"source_modified_time" => 0,
|
||||
"HEAD" => nil,
|
||||
"install_name" => nil,
|
||||
"stdlib" => nil,
|
||||
"compiler" => DevelopmentTools.default_compiler,
|
||||
"source" => {
|
||||
@ -292,6 +294,7 @@ class Tab < OpenStruct
|
||||
"time" => time,
|
||||
"source_modified_time" => source_modified_time.to_i,
|
||||
"HEAD" => self.HEAD,
|
||||
"install_name" => install_name,
|
||||
"stdlib" => (stdlib.to_s if stdlib),
|
||||
"compiler" => (compiler.to_s if compiler),
|
||||
"source" => source
|
||||
|
1
Library/Homebrew/test/fixtures/receipt.json
vendored
1
Library/Homebrew/test/fixtures/receipt.json
vendored
@ -11,6 +11,7 @@
|
||||
"poured_from_bottle": true,
|
||||
"time": 1403827774,
|
||||
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
|
||||
"install_name": "test-formula",
|
||||
"stdlib": "libcxx",
|
||||
"compiler": "clang",
|
||||
"source": {
|
||||
|
@ -8,13 +8,30 @@ class FormulaTests < Homebrew::TestCase
|
||||
name = "formula_name"
|
||||
path = Formulary.core_path(name)
|
||||
spec = :stable
|
||||
install_name = "formula_alias"
|
||||
|
||||
f = klass.new(name, path, spec)
|
||||
f = klass.new(name, path, spec, install_name: install_name)
|
||||
assert_equal name, f.name
|
||||
assert_equal path, f.path
|
||||
assert_equal install_name, f.install_name
|
||||
assert_raises(ArgumentError) { klass.new }
|
||||
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
|
||||
f = Testball.new
|
||||
assert_equal HOMEBREW_CELLAR/f.name/"0.1", f.prefix
|
||||
|
@ -86,7 +86,9 @@ class FormularyFactoryTest < Homebrew::TestCase
|
||||
alias_dir = CoreTap.instance.alias_dir
|
||||
alias_dir.mkpath
|
||||
FileUtils.ln_s @path, alias_dir/"foo"
|
||||
assert_kind_of Formula, Formulary.factory("foo")
|
||||
result = Formulary.factory("foo")
|
||||
assert_kind_of Formula, result
|
||||
assert_equal "foo", result.install_name
|
||||
ensure
|
||||
alias_dir.rmtree
|
||||
end
|
||||
|
@ -43,6 +43,7 @@ class TabTests < Homebrew::TestCase
|
||||
assert_nil tab.stable_version
|
||||
assert_nil tab.devel_version
|
||||
assert_nil tab.head_version
|
||||
assert_nil tab.install_name
|
||||
assert_equal DevelopmentTools.default_compiler, tab.cxxstdlib.compiler
|
||||
assert_nil tab.cxxstdlib.type
|
||||
end
|
||||
@ -116,6 +117,7 @@ class TabTests < Homebrew::TestCase
|
||||
assert_equal "2.14", tab.stable_version.to_s
|
||||
assert_equal "2.15", tab.devel_version.to_s
|
||||
assert_equal "HEAD-0000000", tab.head_version.to_s
|
||||
assert_equal "test-formula", tab.install_name
|
||||
end
|
||||
|
||||
def test_to_json
|
||||
@ -133,6 +135,7 @@ class TabTests < Homebrew::TestCase
|
||||
assert_equal @tab.stable_version, tab.stable_version
|
||||
assert_equal @tab.devel_version, tab.devel_version
|
||||
assert_equal @tab.head_version, tab.head_version
|
||||
assert_equal @tab.install_name, tab.install_name
|
||||
end
|
||||
|
||||
def test_remap_deprecated_options
|
||||
|
@ -1,5 +1,5 @@
|
||||
class Testball < Formula
|
||||
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable)
|
||||
def initialize(name = "testball", path = Pathname.new(__FILE__).expand_path, spec = :stable, install_name: name)
|
||||
self.class.instance_eval do
|
||||
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
stable.sha256 TESTBALL_SHA256
|
||||
|
@ -1,5 +1,5 @@
|
||||
class TestballBottle < Formula
|
||||
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable)
|
||||
def initialize(name = "testball_bottle", path = Pathname.new(__FILE__).expand_path, spec = :stable, install_name: name)
|
||||
self.class.instance_eval do
|
||||
stable.url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
stable.sha256 TESTBALL_SHA256
|
||||
|
Loading…
x
Reference in New Issue
Block a user