diff options
| author | Austin Ziegler | 2009-09-27 19:30:39 -0400 |
|---|---|---|
| committer | Max Howell | 2009-09-30 18:52:12 +0100 |
| commit | c6958c5d7ec2456f2c030a5e16e165b08f791ebd (patch) | |
| tree | 66c85060a8ad05ca91014bfc5f1d557e3da069b4 /Library | |
| parent | a18bc0ffec12a35a13259b5bf56ca1832d4b3cd1 (diff) | |
| download | homebrew-c6958c5d7ec2456f2c030a5e16e165b08f791ebd.tar.bz2 | |
Adding CVS and Mercurial download strategies.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 67 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 2 |
2 files changed, 69 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 5d4afcdda..9ec0e3897 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -129,3 +129,70 @@ class GitDownloadStrategy <AbstractDownloadStrategy end end end + +class CVSDownloadStrategy <AbstractDownloadStrategy + def fetch + ohai "Checking out #{@url}" + @co=HOMEBREW_CACHE+@unique_token + + # URL of cvs cvs://:pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML:gccxml + # will become: + # cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML login + # cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML co gccxml + mod, url = split_url(@url) + + unless @co.exist? + Dir.chdir HOMEBREW_CACHE do + safe_system '/usr/bin/cvs', '-d', url, 'login' + safe_system '/usr/bin/cvs', '-d', url, 'checkout', '-d', @unique_token, mod + end + else + # TODO cvs up? + puts "Repository already checked out" + end + end + + def stage + FileUtils.cp_r(Dir[HOMEBREW_CACHE+@unique_token+"*"], Dir.pwd) + + require 'find' + + Find.find(Dir.pwd) do |path| + if FileTest.directory?(path) && File.basename(path) == "CVS" + Find.prune + FileUtil.rm_r path, :force => true + end + end + end + +private + def split_url(in_url) + parts=in_url.sub(%r[^cvs://], '').split(/:/) + mod=parts.pop + url=parts.join(':') + [ mod, url ] + end +end + +class MercurialDownloadStrategy <AbstractDownloadStrategy + def fetch + ohai "Cloning #{@url}" + @clone=HOMEBREW_CACHE+@unique_token + + url=@url.sub(%r[^hg://], '') + + unless @clone.exist? + safe_system 'hg', 'clone', url, @clone + else + # TODO hg pull? + puts "Repository already cloned" + end + end + def stage + dst=Dir.getwd + Dir.chdir @clone do + # http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export + safe_system 'hg', 'archive', '-y', '-t', 'files', dst + end + end +end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index c58630c98..4353bf0e0 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -101,6 +101,8 @@ class Formula # reimplement if we don't autodetect the download strategy you require def download_strategy case url + when %r[^cvs://] then CVSDownloadStrategy + when %r[^hg://] then MercurialDownloadStrategy when %r[^svn://] then SubversionDownloadStrategy when %r[^git://] then GitDownloadStrategy when %r[^http://(.+?\.)?googlecode\.com/svn] then SubversionDownloadStrategy |
