From 0ef3e1e0dcbcd5aa55408fe81d23613e1c2c5e79 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Sat, 3 Sep 2016 21:10:44 +0100 Subject: Preserve alias when installing formulae Part of #567 --- Library/Homebrew/formula.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/formula.rb') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 9e7bd21ca..479798829 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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. -- cgit v1.2.3 From 65ee5408c3d000393c1b73bfe8fb731a651ee281 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 01:11:36 +0100 Subject: Replace install_name/install_ref with alias_path --- Library/Homebrew/formula.rb | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'Library/Homebrew/formula.rb') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 479798829..90e6b2212 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -61,7 +61,7 @@ class Formula # 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 + attr_reader :alias_path # The fully-qualified name of this {Formula}. # For core formula it's the same as {#name}. @@ -148,10 +148,10 @@ class Formula attr_accessor :build # @private - def initialize(name, path, spec, install_name: name) + def initialize(name, path, spec, alias_path: nil) @name = name @path = path - @install_name = install_name + @alias_path = alias_path @revision = self.class.revision || 0 @version_scheme = self.class.version_scheme || 0 @@ -508,21 +508,6 @@ 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. -- cgit v1.2.3 From c58bbdc2138d2eb21ab7ea499beb6994a01891c4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 5 Sep 2016 22:13:55 +0100 Subject: Formula#specified_path --- Library/Homebrew/formula.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Library/Homebrew/formula.rb') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 90e6b2212..cc26a492e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -226,6 +226,11 @@ class Formula public + # The path that was specified to find/install this formula. + def specified_path + alias_path || path + end + # Is the currently active {SoftwareSpec} a {#stable} build? # @private def stable? -- cgit v1.2.3