diff options
author | Alex Legler <alex@a3li.li> | 2016-01-04 03:03:16 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2016-01-04 03:03:16 +0100 |
commit | 22d84ef992159bc671df8d1f103a008a15cc40de (patch) | |
tree | 8a3c2f00446994fc2809c8b04c8fa4976080fe23 | |
parent | Also support relative HTTP/FTP distfile directories (diff) | |
download | mirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.tar.gz mirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.tar.bz2 mirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.zip |
Support ftp (via curl for now)
-rw-r--r-- | lib/mirror_toolkit.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/mirror_toolkit.rb b/lib/mirror_toolkit.rb index fd854e0..8e1cde5 100644 --- a/lib/mirror_toolkit.rb +++ b/lib/mirror_toolkit.rb @@ -25,13 +25,26 @@ module MirrorToolkit end end + def curl(uri) + stdin, stdout, stderr, wait_thr = Open3.popen3('curl', uri) + stdin.close + + if wait_thr.value == 0 + return stdout.gets + else + fail "curl call unsuccessful: '#{stderr.gets.chomp}'" + end + end + # Fetches a URI from any of the Gentoo mirror types def remote_fetch(url) case url.scheme when 'rsync' rsync_cat(url.to_s) - when 'http', 'https', 'ftp' + when 'http', 'https' Net::HTTP.get(url) + when 'ftp' + curl(url.to_s) else fail 'Unknown URI scheme.' end |