aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common.mk19
-rw-r--r--tool/downloader.rb51
-rwxr-xr-xtool/make-snapshot4
3 files changed, 40 insertions, 34 deletions
diff --git a/common.mk b/common.mk
index 158f9ec3ed..bb80ede536 100644
--- a/common.mk
+++ b/common.mk
@@ -1082,19 +1082,20 @@ $(srcdir)/tool/config.sub:
$(Q) $(BASERUBY) -C $(@D) get-config_files $(@F)
update-gems: PHONY
- $(Q) $(RUNRUBY) -I$(srcdir)/tool -rdownloader -ans \
+ $(ECHO) Downloading bundled gem files...
+ $(Q) $(RUNRUBY) -I$(srcdir)/tool -rdownloader -answ \
+ -C "$(srcdir)/gems" \
-e 'gem, ver = *$$F' \
-e 'gem = "#{gem}-#{ver}.gem"' \
- -e 'puts "updating #{gem}"' \
- -e 'Downloader.download(:rubygems, gem, $$gemdir)' \
- -- -gemdir=$(srcdir)/gems $(srcdir)/gems/bundled_gems
+ -e 'Downloader::RubyGems.download(gem)' \
+ bundled_gems
update-unicode:
- $(Q) $(BASERUBY) -I$(srcdir)/tool -rdownloader \
- -e 'puts "Downloading Unicode data files..."' \
- -e 'Downloader.download(:unicode, "UnicodeData.txt", "$(srcdir)/enc/unicode/data")' \
- -e 'Downloader.download(:unicode, "CompositionExclusions.txt", "$(srcdir)/enc/unicode/data")' \
- -e 'Downloader.download(:unicode, "NormalizationTest.txt", "$(srcdir)/enc/unicode/data")'
+ $(ECHO) Downloading Unicode data files...
+ $(Q) $(BASERUBY) -I$(srcdir)/tool -rdownloader -w \
+ -C "$(srcdir)/enc/unicode/data" \
+ -e 'ARGV.each{|f|Downloader::Unicode.download(f)}' \
+ UnicodeData.txt CompositionExclusions.txt NormalizationTest.txt
info: info-program info-libruby_a info-libruby_so info-arch
info-program:
diff --git a/tool/downloader.rb b/tool/downloader.rb
index 8eb60ac2fc..e909c10e45 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -1,33 +1,24 @@
require 'open-uri'
class Downloader
- def self.gnu(name)
- "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=#{name};hb=HEAD"
+ class GNU < self
+ def self.download(name, *rest)
+ super("http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=#{name};hb=HEAD", name, *rest)
+ end
end
- def self.rubygems(name)
- "https://rubygems.org/downloads/#{name}"
+ class RubyGems < self
+ def self.download(name, *rest)
+ super("https://rubygems.org/downloads/#{name}", name, *rest)
+ end
end
- def self.unicode(name)
- "http://www.unicode.org/Public/UCD/latest/ucd/#{name}"
- end
+ Gems = RubyGems
- def self.uri_to_download(url, name)
- from, url = url
- case from
- when :gnu
- url = gnu(url || name)
- when :rubygems, :gems
- url = rubygems(url || name)
- when :unicode
- url = unicode(url || name)
- when Symbol
- raise ArgumentError, "unkonwn site - #{from}"
- else
- url = from
+ class Unicode < self
+ def self.download(name, *rest)
+ super("http://www.unicode.org/Public/UCD/latest/ucd/#{name}", name, *rest)
end
- URI(url)
end
def self.mode_for(data)
@@ -62,11 +53,21 @@ class Downloader
# download :unicode, 'UnicodeData.txt', 'enc/unicode/data'
def self.download(url, name, dir = nil, ims = true)
file = dir ? File.join(dir, name) : name
- url = uri_to_download(url, name)
+ url = URI(url)
+ if $VERBOSE
+ $stdout.print "downloading #{name} ... "
+ $stdout.flush
+ end
begin
data = url.read(http_options(file, ims))
rescue OpenURI::HTTPError => http_error
- return true if http_error.message =~ /^304 / # 304 Not Modified
+ if http_error.message =~ /^304 / # 304 Not Modified
+ if $VERBOSE
+ $stdout.puts "not modified"
+ $stdout.flush
+ end
+ return true
+ end
raise
end
mtime = nil
@@ -79,6 +80,10 @@ class Downloader
mtime = Time.httpdate(mtime)
File.utime(mtime, mtime, file)
end
+ if $VERBOSE
+ $stdout.puts "done"
+ $stdout.flush
+ end
true
rescue => e
raise e.class, "failed to download #{name}\n#{e.message}: #{url}", e.backtrace
diff --git a/tool/make-snapshot b/tool/make-snapshot
index 555870da31..05e075c581 100755
--- a/tool/make-snapshot
+++ b/tool/make-snapshot
@@ -224,7 +224,7 @@ def package(rev, destdir)
rescue LoadError
abort "Error!!! Copy 'downloader.rb' from 'tool' directory of the recent ruby repository!"
end
- Downloader.download(:gnu, conf, "tool")
+ Downloader::GNU.download(conf, "tool")
end
File.open(clean.add("cross.rb"), "w") do |f|
f.puts "Object.__send__(:remove_const, :CROSS_COMPILING) if defined?(CROSS_COMPILING)"
@@ -282,7 +282,7 @@ def package(rev, destdir)
bundled_gems.split("\n").map(&:split).each do |gem, ver|
gem_name = "#{gem}-#{ver}.gem"
unless File.file?("gems/#{gem_name}")
- Downloader.download(:rubygems, gem_name, "gems")
+ Downloader::RubyGems.download(gem_name, "gems")
end
end
end