summaryrefslogtreecommitdiff
path: root/tool/extlibs.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 16:45:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-21 16:45:35 +0000
commit48070cef9439edb613faf0950c1a95cd769e706c (patch)
tree3491391b74efd9117722c492c4bb099df4a8387a /tool/extlibs.rb
parent2ee57d5ff159d09719d71a4d636ddbd69c1c7abd (diff)
downloadruby-48070cef9439edb613faf0950c1a95cd769e706c.tar.gz
downloader cache
* tool/downloader.rb (Downloader.download): manage download cache. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/extlibs.rb')
-rwxr-xr-xtool/extlibs.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/tool/extlibs.rb b/tool/extlibs.rb
index 10609ebb16..a840724794 100755
--- a/tool/extlibs.rb
+++ b/tool/extlibs.rb
@@ -3,13 +3,16 @@
# Used to download, extract and patch extension libraries (extlibs)
# for Ruby. See common.mk for Ruby's usage.
-require 'fileutils'
require 'digest'
require_relative 'downloader'
class ExtLibs
- def do_download(url, base, cache_dir)
- Downloader.download(url, base, cache_dir, nil)
+ def cache_file(url, cache_dir)
+ Downloader.cache_file(url, nil, :cache_dir => cache_dir)
+ end
+
+ def do_download(url, cache_dir)
+ Downloader.download(url, nil, nil, nil, :cache_dir => cache_dir)
end
def do_checksum(cache, chksums)
@@ -77,22 +80,23 @@ class ExtLibs
end
def do_command(mode, dest, url, cache_dir, chksums)
- base = File.basename(url)
- cache = File.join(cache_dir, base)
- target = File.join(dest, base[/.*(?=\.tar(?:\.\w+)?\z)/])
-
extracted = false
+ base = /.*(?=\.tar(?:\.\w+)?\z)/
+
case mode
when :download
- do_download(url, base, cache_dir)
+ cache = do_download(url, cache_dir)
do_checksum(cache, chksums)
when :extract
+ cache = cache_file(url, cache_dir)
+ target = File.join(dest, File.basename(cache)[base])
unless File.directory?(target)
do_checksum(cache, chksums)
extracted = do_extract(cache, dest)
end
when :all
- do_download(url, base, cache_dir)
+ cache = do_download(url, cache_dir)
+ target = File.join(dest, File.basename(cache)[base])
unless File.directory?(target)
do_checksum(cache, chksums)
extracted = do_extract(cache, dest)
@@ -102,7 +106,7 @@ class ExtLibs
end
def run(argv)
- cache_dir = ENV['CACHE_DIR'] || ".downloaded-cache"
+ cache_dir = nil
mode = :all
until argv.empty?
case argv[0]
@@ -131,8 +135,6 @@ class ExtLibs
argv.shift
end
- FileUtils.mkdir_p(cache_dir)
-
success = true
argv.each do |dir|
Dir.glob("#{dir}/**/extlibs") do |list|