Permalink
Browse files

Bazaar download strategy

  • Loading branch information...
1 parent 9e5695a commit 38e1ee4b2fdadb7a6f23ac32b31834747e514e2b @0xffea 0xffea committed Feb 2, 2010
Showing with 35 additions and 0 deletions.
  1. +34 −0 Library/Homebrew/download_strategy.rb
  2. +1 −0 Library/Homebrew/formula.rb
@@ -274,3 +274,37 @@ def stage
end
end
end
+
+class BazaarDownloadStrategy <AbstractDownloadStrategy
+ def fetch
+ raise "You must install bazaar first" \
+ unless system "/usr/bin/which bzr"
+
+ ohai "Cloning #{@url}"
+ @clone=HOMEBREW_CACHE+@unique_token
+
+ url=@url.sub(%r[^bzr://], '')
+
+ unless @clone.exist?
+ # 'lightweight' means history-less
+ safe_system 'bzr', 'checkout', '--lightweight', url, @clone
+ else
+ puts "Updating #{@clone}"
+ Dir.chdir(@clone) { safe_system 'bzr', 'update' }
+ end
+ end
+
+ def stage
+ dst=Dir.getwd
+ Dir.chdir @clone do
+ if @spec and @ref
+ ohai "Checking out #{@spec} #{@ref}"
+ Dir.chdir @clone do
+ safe_system 'bzr', 'export', '-r', @ref, dst
+ end
+ else
+ safe_system 'bzr', 'export', dst
+ end
+ end
+ end
+end
@@ -159,6 +159,7 @@ def download_strategy
when %r[^svn://] then SubversionDownloadStrategy
when %r[^svn+http://] then SubversionDownloadStrategy
when %r[^git://] then GitDownloadStrategy
+ when %r[^bzr://] then BazaarDownloadStrategy
when %r[^https?://(.+?\.)?googlecode\.com/hg] then MercurialDownloadStrategy
when %r[^https?://(.+?\.)?googlecode\.com/svn] then SubversionDownloadStrategy
when %r[^https?://(.+?\.)?sourceforge\.net/svnroot/] then SubversionDownloadStrategy

0 comments on commit 38e1ee4

Please sign in to comment.