Created
February 3, 2010 21:00
-
-
Save fffergal/294015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SubversionDownloadStrategy <AbstractDownloadStrategy | |
def initialize url, name, version, specs | |
@name = name | |
super url, name, version, specs | |
end | |
def fetch | |
ohai "Exporting #{@url}" | |
@export = HOMEBREW_CACHE+@unique_token | |
if @spec == :revision | |
args = [svn, 'export', '--force', @url, @export] | |
args << '-r' << @ref if @ref | |
quiet_safe_system *args | |
elsif @spec == :revisions | |
externals = Hash.new | |
# Should I do forking and piping instead. Anyone have anything against | |
# backticks? | |
`#{svn} propget svn:externals #{@url}`.each_line do |external_line| | |
key, value = external_line.split /\s+/ | |
externals[key] = value | |
end | |
@ref.each_pair do |directory, revision| | |
if directory.to_s == @name | |
directory = '' | |
else | |
directory = directory.to_s | |
end | |
svnurl = @url | |
svnurl = externals[directory] unless directory == '' | |
args = [svn, 'export', '--force', '--ignore-externals', svnurl, @export+directory] | |
args << '-r' << revision | |
quiet_safe_system *args | |
end | |
else | |
args = [svn, 'export', '--force', @url, @export] | |
quiet_safe_system *args | |
end | |
end | |
def stage | |
# Would be nice if we could cache and verify the export, then copy it in | |
# stage without downloading it again if it was OK, but I cannot think how | |
# to verify the cache. No way sane, atleast. | |
FileUtils.cp_r @export.to_s + '/.', Dir.pwd | |
end | |
# Override this method in a DownloadStrategy to force the use of a non- | |
# sysetm svn binary. mplayer.rb uses this to require a svn that | |
# understands externals. | |
def svn | |
'/usr/bin/svn' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment