From 204a83f5f3a3167815a1439e7e6652a7eec934f2 Mon Sep 17 00:00:00 2001 From: hsbt Date: Tue, 24 Jun 2014 01:26:21 +0000 Subject: * tool/downloader.rb: make Downloader class to general download utility. It can be used without config.guess and configu.sub. * tool/get-config_files: ditto. * tool/make-snapshot: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/downloader.rb | 16 ++++++++-------- tool/get-config_files | 3 ++- tool/make-snapshot | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'tool') diff --git a/tool/downloader.rb b/tool/downloader.rb index 83554fb19d..5d5efe541a 100644 --- a/tool/downloader.rb +++ b/tool/downloader.rb @@ -1,11 +1,11 @@ require 'open-uri' -Downloader = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" -def Downloader.download(name, dir = nil) - uri = URI(self % name) - data = uri.read - file = dir ? File.join(dir, name) : name - open(file, "wb", 0755) {|f| f.write(data)} -rescue => e - raise "failed to download #{name}\n#{e.message}: #{uri}" +class Downloader + def self.download(url, name, dir = nil) + data = URI(url).read + file = dir ? File.join(dir, name) : name + open(file, "wb", 0755) {|f| f.write(data)} + rescue => e + raise "failed to download #{name}\n#{e.message}: #{uri}" + end end diff --git a/tool/get-config_files b/tool/get-config_files index a849c2b1e3..a3fb6dfaf8 100755 --- a/tool/get-config_files +++ b/tool/get-config_files @@ -3,7 +3,8 @@ require File.expand_path('../downloader', __FILE__) ARGV.each {|n| STDOUT.print "Downloading #{n}..."; STDOUT.flush begin - Downloader.download(n) + url = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" % n + Downloader.download(url, n) STDOUT.puts rescue => e STDOUT.puts diff --git a/tool/make-snapshot b/tool/make-snapshot index 17be5eaed2..a4f0dadb37 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -222,7 +222,8 @@ def package(rev, destdir) rescue LoadError abort "Error!!! Copy 'downloader.rb' from 'tool' directory of the recent ruby repository!" end - Downloader.download(conf, "tool") + url = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" % conf + Downloader.download(url, conf, "tool") end File.open(clean.add("cross.rb"), "w") do |f| f.puts "Object.__send__(:remove_const, :CROSS_COMPILING) if defined?(CROSS_COMPILING)" -- cgit v1.2.3