diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 13ed775901..50def92e50 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -46,4 +46,8 @@ end def old_bottle_regex /(-bottle\.tar\.gz)$/ -end \ No newline at end of file +end + +def bottle_base_url + "https://downloads.sf.net/project/machomebrew/Bottles/" +end diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 4a1cd0f36a..2ca0b87251 100755 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -17,7 +17,7 @@ module Homebrew extend self safe_system 'tar', 'czf', directory/filename, "#{f.name}/#{f.version}" puts "./#{filename}" puts "bottle do" - puts " url 'https://downloads.sf.net/project/machomebrew/Bottles/#{filename}'" + puts " url '#{bottle_base_url}#{filename}'" puts " sha1 '#{(directory/filename).sha1}'" puts "end" end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 50f7334682..6604bdad36 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -651,32 +651,35 @@ private end def bottle url=nil, &block - if block_given? - eval <<-EOCLASS - module BottleData - def self.url url; @url = url; end - def self.sha1 sha1 - case sha1 - when Hash - key, value = sha1.shift - @sha1 = key if value == MacOS.cat - when String - @sha1 = sha1 - end - end - def self.return_data - if @sha1 && @url - [@url,@sha1] - elsif @sha1 - [nil,@sha1] - end + return unless block_given? + + bottle_block = Class.new do + def self.url url + @url = url + end + + def self.sha1 sha1 + case sha1 + when Hash + key, value = sha1.shift + @sha1 = key if value == MacOS.cat + when String + @sha1 = sha1 + end + end + + def self.url_sha1 + if @sha1 && @url + return @url, @sha1 + elsif @sha1 + return nil, @sha1 end end - EOCLASS - BottleData.instance_eval &block - @bottle_url, @bottle_sha1 = BottleData.return_data - @bottle_url ||= "https://downloads.sf.net/project/machomebrew/Bottles/#{name.downcase}-#{@version||@standard.detect_version}.bottle-#{MacOS.cat}.tar.gz" if @bottle_sha1 end + + bottle_block.instance_eval &block + @bottle_url, @bottle_sha1 = bottle_block.url_sha1 + @bottle_url ||= "#{bottle_base_url}/#{name.downcase}-#{@version||@standard.detect_version}#{bottle_native_suffix}" if @bottle_sha1 end def mirror val, specs=nil