diff options
| author | Mike McQuaid | 2017-05-03 11:25:12 +0100 |
|---|---|---|
| committer | GitHub | 2017-05-03 11:25:12 +0100 |
| commit | ffa45521f49eaa78fab93a409904cecc00d2af61 (patch) | |
| tree | 81606897be3e26adb72b4730ab4c87f5ed82e22d /Library | |
| parent | e1ef37953f87759775cbb577ce54c59a89a3013d (diff) | |
| parent | ffe1ee1636bba266b2d8180300375dc1a86794cd (diff) | |
| download | brew-ffa45521f49eaa78fab93a409904cecc00d2af61.tar.bz2 | |
Merge pull request #2406 from sjackman/install-bottle-url
Install a bottle from an URL
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formulary.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index f5e6a2eb9..446d5dc10 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -105,7 +105,18 @@ module Formulary # Loads formulae from bottles. class BottleLoader < FormulaLoader def initialize(bottle_name) - @bottle_filename = Pathname(bottle_name).realpath + case bottle_name + when %r{(https?|ftp|file)://} + # The name of the formula is found between the last slash and the last hyphen. + resource = Resource.new bottle_name[%r{([^/]+)-}, 1] { url bottle_name } + downloader = CurlBottleDownloadStrategy.new resource.name, resource + @bottle_filename = downloader.cached_location + cached = @bottle_filename.exist? + downloader.fetch + ohai "Pouring the cached bottle" if cached + else + @bottle_filename = Pathname(bottle_name).realpath + end name, full_name = Utils::Bottles.resolve_formula_names @bottle_filename super name, Formulary.path(full_name) end @@ -335,10 +346,10 @@ module Formulary def self.loader_for(ref, from: nil) case ref - when %r{(https?|ftp|file)://} - return FromUrlLoader.new(ref) when Pathname::BOTTLE_EXTNAME_RX return BottleLoader.new(ref) + when %r{(https?|ftp|file)://} + return FromUrlLoader.new(ref) when HOMEBREW_TAP_FORMULA_REGEX return TapLoader.new(ref, from: from) end |
