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
This commit is contained in:
nobu 2014-12-23 14:14:27 +00:00
parent 840fa8086e
commit e8c22d746b
1 changed files with 24 additions and 1 deletions

View File

@ -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