aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/download_strategy.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 883ea6878..85acfd3d8 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -126,6 +126,23 @@ private
end
end
+# Detect and download from Apache Mirror
+class CurlApacheMirrorDownloadStrategy < CurlDownloadStrategy
+ def _fetch
+ # Fetch mirror list site
+ require 'open-uri'
+ mirror_list = open(@url).read()
+
+ # Parse out suggested mirror
+ # Yep, this is ghetto, grep the first <strong></strong> element content
+ mirror_url = mirror_list[/<strong>([^<]+)/, 1]
+
+ ohai "Actually downloading from mirror: #{mirror_url}"
+ # Start download from that mirror
+ curl mirror_url, '-o', @tarball_path
+ end
+end
+
# Download via an HTTP POST.
# Query parameters on the URL are converted into POST parameters
class CurlPostDownloadStrategy < CurlDownloadStrategy
@@ -514,6 +531,7 @@ def detect_download_strategy url
when %r[^https?://(.+?\.)?googlecode\.com/svn] then SubversionDownloadStrategy
when %r[^https?://(.+?\.)?sourceforge\.net/svnroot/] then SubversionDownloadStrategy
when %r[^http://svn.apache.org/repos/] then SubversionDownloadStrategy
+ when %r[^http://www.apache.org/dyn/closer.cgi] then CurlApacheMirrorDownloadStrategy
# Otherwise just try to download
else CurlDownloadStrategy
end