summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2016-01-04 03:03:16 +0100
committerAlex Legler <alex@a3li.li>2016-01-04 03:03:16 +0100
commit22d84ef992159bc671df8d1f103a008a15cc40de (patch)
tree8a3c2f00446994fc2809c8b04c8fa4976080fe23 /lib
parentAlso support relative HTTP/FTP distfile directories (diff)
downloadmirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.tar.gz
mirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.tar.bz2
mirror-toolkit-22d84ef992159bc671df8d1f103a008a15cc40de.zip
Support ftp (via curl for now)
Diffstat (limited to 'lib')
-rw-r--r--lib/mirror_toolkit.rb15
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