summaryrefslogtreecommitdiff
path: root/tool/extlibs.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-23 14:14:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-23 14:14:27 +0000
commite8c22d746b775a11a79ad304c6221f50b12bcc99 (patch)
treeac73b323efe19224957a8e4f3167e1fa4e42dbee /tool/extlibs.rb
parent840fa8086ee4ee2cccb11b92f9a69cb58a83b68f (diff)
extlibs.rb: separate commands
* tool/extlibs.rb (do_extract): separate expansion and extraction processes to each commands. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/extlibs.rb')
-rwxr-xr-xtool/extlibs.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/tool/extlibs.rb b/tool/extlibs.rb
index 116964c2af..aab08d0372 100755
--- a/tool/extlibs.rb
+++ b/tool/extlibs.rb
@@ -38,7 +38,30 @@ def do_extract(cache, dir)
$stdout.puts "extracting #{cache} into #{dir}"
$stdout.flush
end
- Process.wait(Process.spawn("tar", "xpf", "-", in: cache, chdir: dir))
+ ext = File.extname(cache)
+ case ext
+ when '.gz', '.tgz'
+ f = IO.popen(["gzip", "-c", cache])
+ cache = cache.chomp('.gz')
+ when '.bz2', '.tbz'
+ f = IO.popen(["bzip2", "-c", cache])
+ cache = cache.chomp('.bz2')
+ when '.xz', '.txz'
+ f = IO.popen(["xz", "-c", cache])
+ cache = cache.chomp('.xz')
+ else
+ inp = cache
+ end
+ inp ||= f
+ ext = File.extname(cache)
+ case ext
+ when '.tar', /\A\.t[gbx]z\z/
+ pid = Process.spawn("tar", "xpf", "-", in: inp, chdir: dir)
+ when '.zip'
+ pid = Process.spawn("unzip", inp, "-d", dir)
+ end
+ f.close if f
+ Process.wait(pid)
$?.success? or raise "failed to extract #{cache}"
end