From 22aec1d0d97ee20fdc31e2df278378fe17f9d07f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 9 Feb 2013 19:05:53 -0800 Subject: [PATCH] Add custom bottle URL support. Signed-off-by: Mike McQuaid --- Library/Homebrew/bottles.rb | 9 +++++++-- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/formula_support.rb | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index d474a6f65d..7962a50e1a 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -70,6 +70,11 @@ def bottle_regex Pathname::BOTTLE_EXTNAME_RX end -def bottle_base_url - "https://downloads.sf.net/project/machomebrew/Bottles/" +def bottle_root_url f + root_url = f.bottle.root_url + root_url ||= 'https://downloads.sf.net/project/machomebrew/Bottles' +end + +def bottle_url f + "#{bottle_root_url(f)}/#{bottle_filename(f)}" end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index eff006cdcd..d1ef58f50e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -39,7 +39,7 @@ class Formula # Ensure the bottle URL is set. If it does not have a checksum, # then a bottle is not available for the current platform. if @bottle and not (@bottle.checksum.nil? or @bottle.checksum.empty?) - @bottle.url ||= bottle_base_url + bottle_filename(self) + @bottle.url ||= bottle_url(self) if @bottle.cat_without_underscores @bottle.url.gsub!(MacOS.cat.to_s, MacOS.cat_without_underscores.to_s) end diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 2f3b10322b..c9355d6412 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -79,7 +79,7 @@ end class Bottle < SoftwareSpec attr_writer :url - attr_reader :revision + attr_reader :revision, :root_url # TODO: Can be removed when all bottles migrated to underscored cat symbols. attr_reader :cat_without_underscores @@ -113,6 +113,10 @@ class Bottle < SoftwareSpec } end + def root_url val=nil + val.nil? ? @root_url : @root_url = val + end + def revision val=nil val.nil? ? @revision : @revision = val end